Okay so I am learning to write with with ActionScript for a flash project. First of all I hate this language and can't figure out how to solve my problem. I am trying to play the frames so that they appear 1 second apart but stop at a certain frame.

Right now I pause it on the first frame right away with the command

gotoAndStop(1);

But then after the user clicks a button I want it to play until frame 5 and stop, each frmae in between is used to show different things appearing on the screen. THe problem is I can't figure out how to make it stop on the fifth frame. I mean I tried code that would pause the time line but wouldn't pause the code itse;f, so althought the timeline was paused the code kept going on, and I tried creating a while look to check if had reached the current frame but that just locked up the system

var testVar:Boolean = false;

while(testVar == false)
{
	gotoAndPlay(2);
	trace("What");
	testVar = checkCurrentFrame(testVar);
}
			
function checkCurrentFrame(testVar:Boolean):Boolean
{
	if(currentFrame >= 4)
	{
		trace("found it");
		stop();
		testVar = true;
				
	}
	else
	{
		trace("not yet");
	}
			
	return testVar;
}

Above is the while loop that locks up the code, below is the pause play method I tried

var theTimer:Timer = new Timer(2000);
theTimer.addEventListener(TimerEvent.TIMER, timerStart);

gotoAndStop(2);
trace("Step 2");
theTimer.start();
gotoAndStop(3);
trace("Step 3");	  
theTimer.start();
gotoAndStop(4);
trace("Step 4");	  
theTimer.start();
gotoAndStop(5);
//I used these trace methods to see if the code would stop...it didn't

function timerStart(e:TimerEvent):void
{
	play();
	theTimer.reset();
}

Okay so I feel like I could be asking a really stupid question but I hate this language it's written poorly and I just hate it. I haven't yell at a code this bad in a long time (Last time was when I first leared to program)

So in the end is there anyway to stop the code for say a second at a time or use the timeline's Frames per second and detect when a frame is reached in which then I could pause the code cause I just can't figure it out and it's realy pissing me off.

Thanks in advance

Bump, I really need some help really soon with this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.