Archive for the ‘as 3.0’ Tag
TweenEvent : Basic Tweening
For all the beginning Flashers (Flash AS 3.0) ,
here’s a little post how to make a tween using the standard Tweening Class in Flash CS3 (not yet the Tweener class: that’s for later… , let’s just first give a little info before using this open-source tweening Class)
The Tweenables class provides constant values for the names of animation properties used in the Motion and Keyframe classes.
A tween is writen as following
var tweenName = new Tween([attribute],”[constant]“,[kind of tween],[from value],[to value],[time],[true: use second, False: use frames]);
Attribute: a movieclip, button
Constant: wich sort of movement … [ALPHA, ROTATION, SCALE_X, SCALE_Y, SKEW_X,SKEW_Y, X , Y, WIDTH and HEIGHT]
From Value: from value (also possible the attribute.x, attribute.y, attribute.alpha …… , to get the absolute value of a object )
To Value: from value (also possible the attribute.x, attribute.y, attribute.alpha …… , to get the absolute value of a object )
Kind Of Tween: how is the tween motioned…
True/False: True: use seconds, False: use keyframes ( this is the tweening time taken… )
Now having discussed the variables of a tween , let’s make a simple tween, asume we have a movieclip on our stage with instance name: box_mc, let’s make a new tween wich enables to fade the box_mc from nothing to alpha 1….
var TweenFadeIn = new Tween(box_mc,”alpha”,Bounce.easeInOut,0,1,1,true);
var TweenFadeIn = new Tween(box_mc,”alpha”,Bounce.easeInOut,box_mc.alpha,1,1,true);
Both tweens fill do the same IF we have set the alpha of our box_mc to 0 when starting up….
If we have not , than the difference is that the first tween wil reset the alpha of our box_mc to 0 before executing this tween… With the second tween , we will take the actual alpha value of the box_mc at the moment of executing ….
For whom who haven’t met the Tweener Class , please, please, please …. do SO!
The tweening possibilities have reached another level, Test & Learn, ….
LiveDocs Documentation on the fl.transistions…
Tweener Class: Download & Documentation
KeyBoard Events
This little tut shows you how to capture keyboard events…
First we will need to add a eventlistener to the stage, with the folowing function: downHandler …
stage.addEventListener(KeyboardEvent.KEY_DOWN, downHandler);
function downHandler(evt:KeyboardEvent):void{
trace(evt);
}
Like you see we trace the KeyBoardEvent, …
This will give something like this:

Using the keyCode attribute we can check witch key is pressed…
Example, if the left arrow key is pressed we want to trace a little message… , this we do inside the downHandler, a other okace in the actionscript code wouldn’t recognize these keyCodes….
function downHandler(evt:KeyboardEvent):void{
if(evt.keyCode == 37){
trace(“Arrow Left”)
}
}Roads are endless, but with this little introduction , the road is now under you feet….
You can chose how far you tend to go…
Leave a Comment

Leave a Comment



Leave a Comment