Javascript and flash

  • shikozel
  • Beginner
  • Beginner
  • shikozel
  • Posts: 49

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

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
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

i removed your other post in the programming forum. Please do
not cross post. You post in in the right place here.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

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
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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?
  • shikozel
  • Beginner
  • Beginner
  • shikozel
  • Posts: 49

Post 3+ Months Ago

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
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

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
  • shikozel
  • Posts: 49

Post 3+ Months Ago

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
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Thanks l-in-b -- that gives me the answer to my question.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

scratch that. sorry.
  • Sulfin
  • Graduate
  • Graduate
  • User avatar
  • Posts: 129
  • Loc: canada

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

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.

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 12 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.