Javascript and flash

  • shikozel
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 25, 2004
  • Posts: 49
  • Status: Offline

Post February 1st, 2004, 6:45 am

I am trying to control flash movie with javascript. I have few buttons that communicate through javascript my flash movie. My movie is built from few scenes so I am trying to assingn every button to a different scene. Is anybody know if there is any command to control the scenes.

here is my code:
Code: [ Select ]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>
<head>
<title>moock&gt;&gt; web&gt;&gt; flash&gt;&gt; fs command&gt;&gt; javascript to flash</title>
<style type="text/css">
<!--
.imageButton
{
background-image: url(file:///C|/Documents%20and%20Settings/Owner/Desktop/abc.gif);
height: 30;
width: 100;
}
//-->
</style>
<script LANGUAGE="JavaScript">
<!--
var movieName = "testcommand";
function stopSubmit() {
return false;
}
function thisMovie(movieName) {
// IE and Netscape refer to the movie object differently.
// This function returns the appropriate syntax depending on the browser.
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[movieName]
} else {
return document[movieName]
}
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
if (typeof(theMovie) != "undefined") {
return theMovie.PercentLoaded() == 100;
} else {
return false;
}
}


function playmovie() {
if (movieIsLoaded(thisMovie(movieName))) {
thisMovie(movieName).Play();


}
}

function stopmovie() {
if (movieIsLoaded(thisMovie(movieName))) {
thisMovie(movieName).StopPlay();
}
}




function go(theFrame) {
if (movieIsLoaded(thisMovie(movieName))) {
thisMovie(movieName).GotoFrame(theFrame);
}
}

function golabel() {
if (movieIsLoaded(thisMovie(movieName))) {
thisMovie(movieName).TGotoLabel("_level0/","redframe");
}
}


//-->
</SCRIPT>

</head>

<body BGCOLOR="#FFFFFF">

<div ALIGN="CENTER"> <embed
name="testcommand"
src="special2.swf"
width="600"
height="500"
play="false"
loop="false"
quality="high"
scale="SHOWALL"
swliveconnect="true"
pluginspage="http://www.macromedia.com/go/flashplayer/">
 </embed>
<form onsubmit="return stopSubmit()">

  <input class="imageButton" onFocus="blur()" type="image" src="but.gif" onClick="  playmovie();" name="button">
  <input class="imageButton" onfocus="blur()" type="button" value="Stop" onclick="stopmovie()">
</form>



</div></body>
</html>
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html>
  3. <head>
  4. <title>moock&gt;&gt; web&gt;&gt; flash&gt;&gt; fs command&gt;&gt; javascript to flash</title>
  5. <style type="text/css">
  6. <!--
  7. .imageButton
  8. {
  9. background-image: url(file:///C|/Documents%20and%20Settings/Owner/Desktop/abc.gif);
  10. height: 30;
  11. width: 100;
  12. }
  13. //-->
  14. </style>
  15. <script LANGUAGE="JavaScript">
  16. <!--
  17. var movieName = "testcommand";
  18. function stopSubmit() {
  19. return false;
  20. }
  21. function thisMovie(movieName) {
  22. // IE and Netscape refer to the movie object differently.
  23. // This function returns the appropriate syntax depending on the browser.
  24. if (navigator.appName.indexOf ("Microsoft") !=-1) {
  25. return window[movieName]
  26. } else {
  27. return document[movieName]
  28. }
  29. }
  30. // Checks if movie is completely loaded.
  31. // Returns true if yes, false if no.
  32. function movieIsLoaded (theMovie) {
  33. if (typeof(theMovie) != "undefined") {
  34. return theMovie.PercentLoaded() == 100;
  35. } else {
  36. return false;
  37. }
  38. }
  39. function playmovie() {
  40. if (movieIsLoaded(thisMovie(movieName))) {
  41. thisMovie(movieName).Play();
  42. }
  43. }
  44. function stopmovie() {
  45. if (movieIsLoaded(thisMovie(movieName))) {
  46. thisMovie(movieName).StopPlay();
  47. }
  48. }
  49. function go(theFrame) {
  50. if (movieIsLoaded(thisMovie(movieName))) {
  51. thisMovie(movieName).GotoFrame(theFrame);
  52. }
  53. }
  54. function golabel() {
  55. if (movieIsLoaded(thisMovie(movieName))) {
  56. thisMovie(movieName).TGotoLabel("_level0/","redframe");
  57. }
  58. }
  59. //-->
  60. </SCRIPT>
  61. </head>
  62. <body BGCOLOR="#FFFFFF">
  63. <div ALIGN="CENTER"> <embed
  64. name="testcommand"
  65. src="special2.swf"
  66. width="600"
  67. height="500"
  68. play="false"
  69. loop="false"
  70. quality="high"
  71. scale="SHOWALL"
  72. swliveconnect="true"
  73. pluginspage="http://www.macromedia.com/go/flashplayer/">
  74.  </embed>
  75. <form onsubmit="return stopSubmit()">
  76.   <input class="imageButton" onFocus="blur()" type="image" src="but.gif" onClick="  playmovie();" name="button">
  77.   <input class="imageButton" onfocus="blur()" type="button" value="Stop" onclick="stopmovie()">
  78. </form>
  79. </div></body>
  80. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 1st, 2004, 6:45 am

  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post February 1st, 2004, 8:01 am

I am not much help on this particular subject. I'm interested to see what
others might have to say.

this info might help you in the meantime--
http://www.moock.org/webdesign/flash/fscommand/
UNFLUX.FOTO
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 6382
  • Loc: twitter.com/unflux
  • Status: Offline

Post February 1st, 2004, 10:38 am

i removed your other post in the programming forum. Please do
not cross post. You post in in the right place here.
UNFLUX.FOTO
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post February 1st, 2004, 11:15 am

My guess is you got this code from Colin Moock? (guess comes from the text between the TITLE tags)

If so, do you have a link to where you got this. Does it come with instructions, or any explanation at all how it works?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post February 1st, 2004, 11:53 am

Being a beginner at Flash...I'm just curious why the need for javascript controls? I guess my question is wouldn't it be easier to control the movie within the movie itself?
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • shikozel
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 25, 2004
  • Posts: 49
  • Status: Offline

Post February 1st, 2004, 12:20 pm

This is a combination of someone code and mine. I am using javascript because I am working on a project that the content need to change often. Instead of changing the movie with the buttons all the time I am using gif buttuns that control the movie. It seems to me that this will be easier to update whenever it needs.
The idea: working on gif button seperate from the movie. and then conect the two.
Does it make sense??? :roll:
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Joined: Jun 26, 2003
  • Posts: 1402
  • Loc: Philadelphia, PA
  • Status: Offline

Post February 1st, 2004, 12:33 pm

You know what will be easier than this? (well easier if all the movies will be the same dimensions)

Have one main container movie, this movie will contain the buttons you need.

Then use loadMovie() to load correct movies into the main container movie file.

You can then use the buttons in the main container movie to manipulate the content in the loaded movie (just make sure your targeting is correct).

IMO that will be a lot easier than what you are trying to do now.
  • shikozel
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 25, 2004
  • Posts: 49
  • Status: Offline

Post February 1st, 2004, 1:02 pm

this is basically my idea. instead of container of button, I put few gifs. I am new in flash so I am not that sharp. Do you have a sample program that do what you said.
thanx
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post February 1st, 2004, 1:43 pm

Thanks l-in-b -- that gives me the answer to my question.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post February 4th, 2004, 7:37 pm

scratch that. sorry.
- dM
  • Sulfin
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 12, 2004
  • Posts: 129
  • Loc: canada
  • Status: Offline

Post June 14th, 2004, 5:25 pm

You wan't a function for gotoAndStop() to a different scene with javascript?
Step 1:
Make a frame in your movie with a gotoAndStop action to the scene you want.
Step 2:
Use your go(theFrame) js function to send the movie to the frame in step 1.

It should work, and it's very simple.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post June 14th, 2004, 6:06 pm

Quote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">


:shock: Though I would do so anyway, after seeing that i'm seconding (or thirding, lost count) emerals err I mean lostinbetas :wink: suggestion.
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 77 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.