0 Replies - 3524 Views - Last Post: 17 March 2014 - 07:13 PM

#1 Fo4ty5`  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 05-June 13

AS3 Animation Help

Posted 17 March 2014 - 07:13 PM

Hello guys!

I am new to Action Script, and I am using AS3 with my code. What I am doing is just playing a animation with a mouse click to activate it. The code does play the animation. however after a few times of the animation being played with so many mouse clicks the animation gets really slow and lagy? I want to know is that me, am I not keeping things clean enough may be? here is my code for the animation.

package {

	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class PlayField extends MovieClip{
		public var gameTimer:Timer;
		public var player:PlayerObject;
		public var isPlaying:Boolean = false;
		public function PlayField(){
			addEventListener(Event.ADDED_TO_STAGE, onaddToStage);
			//timer set up
			gameTimer  = new Timer(25);
			gameTimer.addEventListener( TimerEvent.TIMER, onTick );
		public function onTick(timerEvent:TimerEvent):void{
			player = new PlayerObject;
			player.x = 250;
			player.y = 200 ;
		public function onaddToStage(event:Event):void{
			removeEventListener(Event.ADDED_TO_STAGE, onaddToStage);
			stage.addEventListener(MouseEvent.CLICK, onMouseClick);
		public function onMouseClick(mouseEvent:MouseEvent):void{
			isPlaying = true;
			mouseEvent.target.player.addEventListener(Event.ENTER_FRAME, playingPlayerMove);
		public function playingPlayerMove(event:Event):void{
			if(event.target.currentFrame == event.target.totalFrames){
				event.target.removeEventListener(Event.ENTER_FRAME, playingPlayerMove);
				isPlaying = false;
	}// Class Ends

}// package ends

Is This A Good Question/Topic? 0
  • +

Page 1 of 1