|
||||||
|
||||||
Flash Tutorial - Text Scroll using simple ActionScript

Free
Flash Tutorial
Step Six: Adding ActionScript for the Buttons
//Events during mouse click
on(press) {
play();
}
//Events after mouse click
on(release) {
stop();
}
Action
Script Explained:
The Movie will stop in
the first frame itself due to the stop(); in
frame 1 of the Actions Layer. When the Top
Button is pressed the Movie will start to play, i.e. the text would move
in it's path as a motion tween. The masked layer gives the effect of text being
scrolled downwards. When the Top Button is
released the playhead will stop in that frame and the text will stop
scrolling.
//Events during mouse click
on(press) {
_root.controller.gotoAndPlay (2);
}
//Events after mouse click
on(release) {
_root.controller.gotoAndStop (1);
}
Action Script
Explained:
What needs to be done is
to get the Movie to play backwards so that the text will scroll back up to
the start position. The problem with this is that there is no ActionScript to
make a Movie play backwards. This is why you needed to create the Controller
Movie Clip. This enables the movie to play backwards. When some one clicks the Bottom Button it sends the Playhead to Frame
2 of the Controller Movie Clip:
_root.controller.gotoAndPlay(2);
The Controller Movie Clip in turn sends the Play Head on the Main Stage back one space.
_root.prevFrame();
If you recall the ActionScript on Frame 3 of the Controller Movie Clip send the Controllers Play Head back to Frame 2:
gotoAndPlay(2);
This makes the above script loop so that the Play Head on the Main Stage continually goes back one space. This is a ridiculously complicated way to get the Movie to play backwards but there is no simple way. So when the bottom button is kept pressed the entire Motion Tween goes in the reverse direction from the current frame until frame 1 is reached. The Motion Tween will in effect play in the reverse direction to give the effect of the text being scrolled upwards.
When the Bottom Button is released the Play Head in the Controller Movie Clip is sent back to Frame 1 and stopped:
_root.controller.gotoAndStop(1);
This stops the loop and the Movie will stop playing in reverse.
End of the tutorial
I hope this tutorial will have helped you to create a text scroll function. The text field can be changed to dynamic text in the Property Inspector. This means that text can be loaded from an external text file with a little help from some ActionScript. This makes the Movie more flexible.
I hope you found this tutorial useful.
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
114272 visitors to this page since
Feb 05•
|
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|