Navigating the Timeline |
| Stop the timeline |
stop(); |
| Play the timeline |
play(); |
| Play from frame 10 on the timeline |
gotoAndPlay(10); |
| Stop the timeline on frame 20 |
gotoAndStop(20); |
| Play the timeline from the frame labeled "main" |
gotoAndPlay("main"); |
| Go to "Scene 5" and play from frame 1 |
gotoAndPlay("Scene 5", 1); |
| Go to the scene named "Opening" and stop on frame 30 |
gotoAndStop("Opening", 30); |
| |
|
Scripting Buttons |
| Go to and play from frame 10 on release of a button |
on (release) {
gotoAndPlay(10);
} |
| Go to and stop on the next frame on the roll over of a button |
on (rollOver) {
nextFrame();
} |
| Go to and stop on the previous frame on the roll out of a button |
on (rollOut) {
prevFrame();
} |
| Go to a URL on the release of a button |
on (release) {
getURL ("http://karlcleveland.com");
} |
| Play the timeline on button press or the pressing of the "p" key on the keyboard |
on (press, keyPress "p") {
play();
} |
| Scripting a button instance to stop the timeline on frame 20 using a frame action |
myButtonInstanceName.onRelease = function () {
gotoAndStop(20);
} |
| |
|
Movie Clips |
| Play from frame 5 of the movieclip "myClipName" |
_root.myClipName.gotoAndPlay(5); |
| Stop on frame 10 of the movieclip "myClipName2" that is inside the movieclip "myClipName1" |
_root.myClipName1.myClipName2.gotoAndStop(10); |
| Load a .swf movie into the movieclip "myClipName" |
_root.myClipName.loadMovie("myMovieName.swf"); |
| |
|
Sound |
| Loading and starting an external mp3 sound file |
var my_sound:Sound = new Sound();
// creates sound object
my_sound.loadSound("trackname.mp3",true);
// loads track and streams
my_sound.start();
//starts the sound |
| Stopping a sound that was started using the previous script |
my_sound.stop(); |
| Stopping all sounds |
stopAllSounds(); |
| |
|
Video |
| Using a video object on the stage to play an external .flv video file |
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
myVideo.attachVideo(ns);
ns.play("myMovie.flv"); // myVideo is the instance name of the Video Object on the Stage
//myMovie.flv is the name of your video file |
| Scripting a play/pause button for the video above |
on (release) {
ns.pause();
} |
| Scripiting a rewind button for the video above |
on (release) {
ns.seek(0);
} |
| Scripiting a fast forward button for the video above that will move the video 5 seconds forward. |
on (release) {
ns.seek(ns.time + 5);
} |
| Tracing a possible cuepoint Using cuepoints to play a movieclip instance (called "myMovieClip") that is on the stage |
_root.onMouseDown=function(){
trace(myVideo.playheadTime);
} myObj=new Object();
myObj.cuePoint=function(p){
trace("received sync cue point named: "+ p.target.name);
myMovieClip.gotoAndPlay(p.target.name);
}
myVideo.addEventListener("cuePoint", myObj); |
| |
|
FS Commands for Projector Files |
| Make the screen size fullscreen |
fscommand("fullscreen", "true"); |
| Allow the movie to scale to the screen size |
fscommand("allowscale", "true"); |
| Don't allow the movie to scale |
fscommand("allowscale", "false"); |
| Script for a "quit" or "exit" button |
on (release) {
fscommand("quit");
} |
| |
|