2013年5月24日 星期五

Action Script Advance Function 1

stage: root of display list hierachy
Display object containers:an object that is capable of containing child display
objects,  Sprite, MovieClip, and Shape,  a display object container is
removed from the display list, all its children are removed as well

Display objects: a visual element,  Some classes function as both display
objects and display object containers

Display Object List (Children)
Child 0 is the deepest (will be occluded by other objects)
Children indices must be continuous :0,2 is not allowed, must be 0,1,2
addChild(Object_Name)//equals to stage.addChild(Object_name)
addChildAt(Object_Name, index) other objects indices will shift by 1

reparenting
container1.addChild(Object1);
container2.addChild(Object2);
now container1 does not have Object1

removeChild(Object_name);
removeChildAt(index);

numChildren:check number of Children

ascb.util.DisplayObjectUtilities class:

DisplayObjectUtilities.removeAllChildren( this );

Move Object:
setChildIndex(Object_name,index);

getChildAt(index)

load resource: 6.6 (Loader class)

mouse 6.8

Filter: image filter (e.g. convolution filter)


String:

var attendance:int = 24;
// Results in a single value of "There are 24 people"
var output:String = "There are " + attendance + " people";


var first:int = 24;
var second:int = 42;
// Results in a string value of "2442"
var result:String = "" + first + second;


var first:int = 24;
var second:int = 42;
// Results in a string value of "66"
var result:String = first + second + "";


var first:int = 24;
var second:int = 42;
var third:int = 21;
// Results in a string value of "6621"
var result:String = first + second + String( third );


var first:int = 24;
var second:int = 42;
var third:int = 21;
// Results in a string value of "244221"
var result:String = first.toString( ) + second + third;


var first:int = 24;
var second:int = 42;
// Results in "There are 66 people"
var result:String = "There are " + ( first + second ) + " people";

new line,tab... 12.3

Timer:
var timer:Timer=new Timer(1000); exec every 1 second

timer.addEventListener(TimerEvent.TIMER, onTimer); onTimer: function name

function onTimer(event:TimerEvent):void {
trace("on timer");
}
timer.start( );


Sound:

_sound = new Sound(new URLRequest("song.mp3"));
_sound.play(delay, loop_times );

buffer sound 5 second

var request:URLRequest = new URLRequest("song.mp3");
var buffer:SoundLoaderContext = new SoundLoaderContext(5000);
_sound = new Sound(request, buffer);
_sound.play( );

SoundChannel->addEventListener(Event.SOUND_COMPLETE,onComplete); //handle sound finish event

Sound.length, Sound.position

SoundChannel.leftPeak/rightPeak :control volume

SoundTransform.volume=0.0~1.0
SoundTransform.pan=-1.0~1.0 (left to right)








沒有留言:

張貼留言