Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

problem with flash coding

Guest
May 08, 2014 May 08, 2014

i have issue with this coding . i want to make the duck move horitontally but i dun know whats wrong with the code.The function for that is suppose to be moveDuck1. i would appreciate any constructive helps thanks

package  {

  import flash.display.MovieClip;

  import flash.events.TimerEvent;

  import flash.utils.Timer;

  import flash.events.MouseEvent;

  import flash.events.Event;

  public class Duck extends MovieClip {

  var moveDuck:Timer = new Timer(10);

  var timer:Timer = new Timer(100);//

  var removeTimer:Timer = new Timer(2000);//

  var speedX:Number

  public function Duck() {

  removeTimer.addEventListener(TimerEvent.TIMER,removeDuck);//

  removeTimer.start();

  this.addEventListener(MouseEvent.CLICK,killDuck);//

  //timer.addEventListener(TimerEvent.TIMER,moveDuck1);

  timer.start();//

  speedX = 10;

  }

  function killDuck(evt:MouseEvent):void

  {

  removeTimer.stop();//

  removeTimer.removeEventListener(TimerEvent.TIMER,removeDuck);//

  this.removeEventListener(MouseEvent.CLICK,killDuck);//

  moveDuck.addEventListener(TimerEvent.TIMER,duckFly);//

  moveDuck.start();//

  }

  function removeDuck(evt:TimerEvent):void

  {

  removeTimer:stop();//

  removeTimer.removeEventListener(TimerEvent.TIMER,removeDuck);//

  this.removeEventListener(MouseEvent.CLICK,killDuck);//

  this.parent.removeChild(this);//

  }

  function duckFly(evt:TimerEvent):void

  {

  this.y -= 5;//

  this.rotation += 10;//

  if (this.y < 0)//

  {

  var p:MovieClip = this.parent as MovieClip;//

  p.setScore();//

  moveDuck.stop();//

  moveDuck.removeEventListener(TimerEvent.TIMER,duckFly);//

  this.parent.removeChild(this);//

  }

  function moveDuck1(evt:TimerEvent):void

  {

  this.x += speedX;

  if (this.x <=0)

  {

  moveDuck.stop();

  moveDuck.removeEventListener(TimerEvent.TIMER,moveDuck1);

  this.parent.removeChild(this);

  }

  }

  }

}

}

TOPICS
ActionScript
371
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 08, 2014 May 08, 2014

The place where you add the event listener that should be moving the duck is commented out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 08, 2014 May 08, 2014

u mean this?

i have error if i enable that

timer.addEventListener(TimerEvent.TIMER,moveDuck1);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 09, 2014 May 09, 2014
LATEST

That would be the chap. You should be able to avoid the error if you change the function it's calling to the function you need to have called when the event happens.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines