step 1: Draw a rectangle
step 2: Convert to symbol (press F8) or go to modify -> select convert to symbol
step 3 : Under the ActionScript Linkage and select the "Export for ActionScript"
step 4: Give the class name "mc" and press OK.
step 5: Delete the movieClip from the stage.
ActionScript :
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
function attachBox(){
for(var i:int =0; i<3 ; i++){
var randomColor:ColorTransform = new ColorTransform();
randomColor.color = (Math.random()* 0xFFFFFF);
var myMc:mc = new mc();
myMc.x =((i*myMc.width/1.5)+150);
myMc.y = 100;
myMc.transform.colorTransform = randomColor;
myMc.buttonMode = true;
this.addChild(myMc);
myMc.addEventListener(MouseEvent.MOUSE_OVER,hDepth);
}
}
attachBox();
function hDepth(e:MouseEvent){
this.setChildIndex(mc(e.target), (this.numChildren - 1));
}
step 2: Convert to symbol (press F8) or go to modify -> select convert to symbol
step 3 : Under the ActionScript Linkage and select the "Export for ActionScript"
step 4: Give the class name "mc" and press OK.
step 5: Delete the movieClip from the stage.
ActionScript :
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
function attachBox(){
for(var i:int =0; i<3 ; i++){
var randomColor:ColorTransform = new ColorTransform();
randomColor.color = (Math.random()* 0xFFFFFF);
var myMc:mc = new mc();
myMc.x =((i*myMc.width/1.5)+150);
myMc.y = 100;
myMc.transform.colorTransform = randomColor;
myMc.buttonMode = true;
this.addChild(myMc);
myMc.addEventListener(MouseEvent.MOUSE_OVER,hDepth);
}
}
attachBox();
function hDepth(e:MouseEvent){
this.setChildIndex(mc(e.target), (this.numChildren - 1));
}
No comments:
Post a Comment