lootbox
create new movie clip symbol called box that animates a box opening:
insert box movie clip to stage layer 1 frame 1, give it instance name lootbox:
add actions to layer 1 frame 1:
//Stop lootbox instance on first frame:
lootbox.stop()
//Register event handlers on creation:
lootbox.addEventListener(MouseEvent.CLICK, clicked);
lootbox.addEventListener(Event.ENTER_FRAME, step);
//Open when clicked:
function clicked(event:MouseEvent):void
{
//Start playing:
lootbox.play();
}
//Listen each frame:
function step(event:Event):void
{
//Calculate when lootbox finishes opening:
if (lootbox.currentFrame == lootbox.totalFrames){
lootbox.removeEventListener(Event.ENTER_FRAME, step);
removeChild(lootbox);
trace("Complete.");
}
}