dimanche 27 décembre 2015

change movie clip when click, Actionscript 3

I want to change rat_mc (movie clip) into a new movie clip when rat_mc (beaten), for example into another movie clip. then, I want to be when rat_mc (movie clip) has appeared 20 times, it will move to frame 3. how can I do?

stop();
import flash.events.Event;

hammerMC.startDrag(true);

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

var myTimer:Timer = new Timer(1000,20);
myTimer.addEventListener(TimerEvent.TIMER, showRat);
myTimer.start();

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;
}

var num_count:Number=0;
var rat_mc: MovieClip ;

addChild( rat_mc);
rat_mc. buttonMode = true;
rat_mc. addEventListener (MouseEvent. CLICK, clickHandler);

var txt_score: TextField;

function clickHandler(e: MouseEvent):void{
txt_score. text = String (num_count += 10);

} 

import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.Sprite;

function TimerExample() {
        var myTimer:Timer = new Timer(1000, 2);
        myTimer.addEventListener("timer", timerHandler);
        myTimer.start();
    }

function timerHandler(event:TimerEvent):void {
        trace("timerHandler: " + event);
    }

var secs:Number = 30;
var waktu:Timer = new Timer(1000);

detik_txt.text=""+secs;

waktu.addEventListener(TimerEvent.TIMER,handTimer);
waktu.start();
function handTimer(e:TimerEvent):void{
     if(secs==0){
              waktu.stop();
               gotoAndStop(3);
          }else{
             secs--;
             detik_txt.text=""+secs;
           }
  }

Aucun commentaire:

Enregistrer un commentaire