954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Beginner's Problem! Looping a Script

Hello! I'm just beginning to use Adobe Flash - in fact, I only started a few hours ago - so, I'm still learning the basics and am still tripping my own feet trying to understand how to script when all I want to do is make a flash comic. I'm trying to loop a few frames over and over again, until either a button that takes the reader to the next frame or another button that takes the reader to the previous frame is pressed. I want the looped frames (frames 2-21, to be specific) to loop for an infinite number of times, but I'm not sure if that's even possible with cs5. Haha.

I'm using the following code:

while (x<100) {
2;

movieClip_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);

function fl_ClickToGoToNextFrame(event:MouseEvent):void
{
nextFrame();


movieClip_2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);

function fl_ClickToGoToPreviousFrame(event:MouseEvent):void
{
prevFrame();


}
}


stop();

}


And I'm getting the following error:

Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at Part1_fla::MainTimeline/frame21()

Thank you for taking the time to read this! My scripting is probably horrible, but please have mercy on me. XD

FOOLY
Newbie Poster
6 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

No need of any code to utilize the frame from 2 to 21 for an continuous loop.

Create a new layer. Name it actions.

on 21st frame add a keyframe at the layer of actions and add gotoAndPlay(2);

Hence, when the frame reachest 21 the actions again repeat the frame from 2. Thats it!

rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

No need of any code to utilize the frame from 2 to 21 for an continuous loop.

Create a new layer. Name it actions.

on 21st frame add a keyframe at the layer of actions and add gotoAndPlay(2);

Hence, when the frame reachest 21 the actions again repeat the frame from 2. Thats it!


Thank you so much! That fixed it perfectly!

FOOLY
Newbie Poster
6 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: