Difference between revisions of "Actionscript 3 Sandbox"
From Wikicliki
(→Basics of AS3) |
|||
Line 30: | Line 30: | ||
* trace("long text comment"); | * trace("long text comment"); | ||
* function thing():void - the void means no return argument | * function thing():void - the void means no return argument | ||
− | * <pre>function moveObj(thing:MovieClip):void { | + | * <pre>function moveObj(thing:MovieClip):void |
− | thing.y -= 50; // mc moves 50px up | + | { thing.y -= 50; // mc moves 50px up |
thing.rotation += 45; // mc rotates 45 degrees right | thing.rotation += 45; // mc rotates 45 degrees right | ||
} | } | ||
moveObj(thing1_mc);</pre> | moveObj(thing1_mc);</pre> | ||
− | * <pre>function moveObj(thing:MovieClip, movement:Number, rotationAmount:Number):void { | + | * <pre>function moveObj(thing:MovieClip, movement:Number, rotationAmount:Number):void |
− | thing.y -= movement; // mc moves 50px up | + | {thing.y -= movement; // mc moves 50px up |
thing.rotation += rotationAmount; // mc rotates 45 degrees right | thing.rotation += rotationAmount; // mc rotates 45 degrees right | ||
} | } | ||
moveObj(thing1_mc, 50, 45);</pre> | moveObj(thing1_mc, 50, 45);</pre> | ||
* <pre>function moveObj():Number // the number here defines what kind of thing is returned | * <pre>function moveObj():Number // the number here defines what kind of thing is returned | ||
− | { | + | { thing1_mc.y -= 50; |
− | thing1_mc.y -= 50; | ||
thing1_mc.scaleY = 2; | thing1_mc.scaleY = 2; | ||
return thing1_mc.y; | return thing1_mc.y; |
Revision as of 03:47, 5 July 2009
AS3 brings the core language aspects of AS2 into complianace with ECMAScript standard (the international standardized programming language for scripting).
- http://www.flashandmath.com/
- http://www.learningactionscript3.com/2009/06/30/as3-tips-tricks-and-experiments/#more-61
- http://www.adobe.com/devnet/flash/quickstart/creating_class_as3/
- interesting collection of as3 classes
- http://www.bytearray.org/?page_id=82
Basics of AS3
OPTION F9 == Actions Panel
- The difference between AS2 and AS3:
AS2: my_MC.createTextField("instance_name", 10,0,0 Stage.width, 22); my_MC.attachMovie("MC_name", "moviename_mc, this.getNextHighestDepth()); 10,0,0,Stage.width == dimensions 22 == depth Versus AS3: var myText:TextField = new TextField(); var myMC:MovieClip = new MovieClip(); now in AS3 you dont have to createTextField or attachMovie, and you can define all the variables later.
- select the property (highlighted in blue in the Actions panel), and press F1 to see a help menu telling you about what values the property can have.
- strings must be in quotation marks (var userName:<DataType> = "Data";)
- you assign data type to the variable so you dont lose track of what it is.
- trace(variableName);
- trace("long text comment");
- function thing():void - the void means no return argument
-
function moveObj(thing:MovieClip):void
-
function moveObj(thing:MovieClip, movement:Number, rotationAmount:Number):void
{thing.y -= movement; // mc moves 50px up thing.rotation += rotationAmount; // mc rotates 45 degrees right }
moveObj(thing1_mc, 50, 45);-
function moveObj():Number // the number here defines what kind of thing is returned
{ thing1_mc.y -= 50; thing1_mc.scaleY = 2; return thing1_mc.y; }
border2_mc.y = moveObj();- events must have listeners