mercredi 30 décembre 2015

change movie clip when click to other movie clip, Actionscript 3

I want to change rat_mc MovieClip into a new MovieClip when rat_mc is beaten, for example by another MovieClip. How can I do it?

import flash.events.Event;

hammerMC.startDrag(true);

var allHoles:Array = new Array(hole1_mc, hole2_mc, hole3_mc);
rat_mc.visible = false;

var num_count:Number = 0;
var rat_mc:MovieClip;
addChild(rat_mc);
rat_mc.buttonMode = true;
var txt_score:TextField;

function showRat(e:Event):void {

var rand = Math.floor(Math.random() * 3);
var randomHole = allHoles[rand];

rat_mc.visible = true;
rat_mc.x = randomHole.x;
rat_mc.y = randomHole.y;

}

rat_mc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(e:MouseEvent):void {
txt_score.text = String (num_count += 10);
} 

enter image description here

Aucun commentaire:

Enregistrer un commentaire