| Calling a flash movie's
methods from javascript is very simple. There is a list
of flash methods callable from javascript, please refer
to Macromedia
Flash Support Center for the complete list. In this
tutorial, we will demonstrate some of them (SetVariable,
Play & StopPlay,
...etc)..
Example 2 - Play & StopPlay
click on the following buttons to start
and stop playing the flash movie below:
Step 1
The flash movie being used in this example
is similar to that in the previous
example except that we added the text motion part
(on the main stage, insert a key frame at around frame
15; move the text object on frame 1 to the left such
that it is just out of screen; move the text object
on frame 15 to the right such that is is just out of
screen; motion tween from frame 1 to frame 15 so the
text will moving from left to right in the final movie).
Insert the flash movie into your HTML
page, assign the ID/NAME "moving_text" to
the movie as in the previoue
example.
Step 2
Implement a javascript function for playing
& stopping the moive:
| <script language="JavaScript">
<!-- no script
function playmovie(flag)
{
if(flag == 1)
document.getElementById("moving_text").Play();
else
document.getElementById("moving_text").StopPlay();
}
-->
</script>
|
Step 3
Add the onclick action for the "Play" &
"Stop" buttons, so they will call the javascript
function when being clicked:
| onclick="playmovie(1)" |
for the "Play" button |
onclick="playmovie(0)" |
for the "Stop" button |
Done! Test your code!
< Tutorials
Index - Download
this tutorial - Post
suggestions >
|