Wednesday, April 20, 2011

AS3 Code: Export from Library [movieclip follows mouse]

//create a movieclip, delete from stage
//edit Linkage (in library)
//check "Export for ActionScript"
//give it Class name of Bubble

//every time you move the mouse it calls the event
stage.addEventListener(MouseEvent.MOUSE_MOVE,addBubble,false,0,true);
function addBubble(e:MouseEvent):void{
    var myBubble:MovieClip = new Bubble(); //creates a new instance
    addChild(myBubble); //adds it to the stage
    myBubble.x = mouseX;
    myBubble.y = mouseY;
}

//animate movieclip with frames
//add this code to final frame of movieclip
stop();
parent.removeChild(this); //kills itself


//see also: For Loop


0 comments:

Post a Comment