Flash Tutorials - Herong's Tutorial Examples - v3.03, by Dr. Herong Yang
Space Explorer v.1 - Space Car Running
This section provides a tutorial example on how to use ActionScript 3 statement blocks in SWFC script file to build my Space Explorer - Version 1: the space car is running!
Let's try to build a simple Flash animation with the use of ActionScript 3.0 statement blocks in a SWFC script file:
Here is Space Explorer Version 1, space_explorer_1.sc:
#- space_explorer_1.sc #- Copyright (c) 2014 by Dr. Herong Yang, herongyang.com # .flash bbox=400x400 background=#000044 fps=12 .circle space_car r=6 line=8 color=#cccccc fill=#ff0000 .frame 1 .put space_car .action: _root.x_pos = 6; _root.y_pos = 6; _root.x_speed = 1.0; _root.y_speed = 0.5; _x = _root.x_pos; _y = _root.y_pos; .end .frame 2 .action: _root.x_pos += _root.x_speed; _root.y_pos += _root.y_speed; _x = _root.x_pos; _y = _root.y_pos; .end .frame 3 .action: gotoFrame(1); // index=0 is for frame 1 play(); .end .end
Note that the argument value of function gotoFrame(n) is zero based. gotoFrame(1) is equivalent to "Go to frame 2".
Compile space_explorer_1.sc and generate the HTML code:
C:\herong>\local\SWFTools\swfc.exe space_explorer_1.sc -o space_explorer_1.swf C:\herong>\local\SWFTools\swfdump.exe -E space_explorer_1.swf > space_explorer_1.html
Open space_explorer_1.html in a Web browser. You will see that my space car is running correctly with a constant speed!
If you are reading the Web version of this book,
you will see the Flash running here.
Otherwise, you will see a static image.
Table of Contents
Adobe Flash Player Plugin for Firefox
Adobe Flash Player Plugin for Chrome
Adobe Flash Player Plugin for Safari
Adobe Flash Player ActiveX for IE
Using "object" Elements for Flash Files
Using "embed" Elements for Flash Files
"mp3player" - MP3 Music Player
SWFObject - Hidding "object" behind JavaScript
SWFTools - SWF File Manipulation Tools
SWFC Script to Generate Flash SWF Files
►ActionScript Embedded in SWFC Script
Using ActionScript in SWFC Scripts
►Space Explorer v.1 - Space Car Running
Space Explorer v.2 - Space Car Wondering
Space Explorer v.3 - Space Car Bouncing
Space Explorer v.4 - Space Car Stabilized
AS3Compile - ActionScript 3 Compiler