?
Solved

Go to another frame when a frame is reached

Posted on 2005-04-02
6
Medium Priority
?
241 Views
Last Modified: 2008-03-17
I'm waaaaay over my head here, but I'm in it too far to back out.  Here's the situation I need help with,

I need to have a series of transitions set up, click a button and run through x number of frames, and upon reaching the last frame, go to another frame depending on what button was clicked.

In other words, if you click "product" you go to frame 50 and play, it runs to frame 70, then based on what button you clicked, goes to like frame 90 and plays, or 110 and plays, or 130 and plays, then stops when it gets to the end.

Now, in pseudocode, I'd write it out like this,

home = 1, news = 2, product = 3, support = 4

product is clicked, set variable to 3, go to frame 50, play to 70, at frame 70 determine what variable is, then if 1 go to and play frame 30, if 2...if 3 gotoAndPlay frame 130, if 4....

Basically, I need to know what action to put in the button, and what action to put at frame 70 to determine the above pseudocode.  500 because I'm an idiot that got in over my head and need bailed out fast.
0
Comment
Question by:AcydTrip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
onFocus earned 2000 total points
ID: 13687136
Hi.
You should set a variable that holds the pseudocode.
For example:

In the frame where your buttons are:
var myVar=1;
products_btn.onPress=function(){
      myVar=3;
      gotoAndPlay(50);
}
//the same for the other buttons with the correct values for myVar and gotoAndPlay()


In frame 70:
if(myVar==1){
      gotoAndPlay(30);
}else if(myVar==2){
      gotoAndPlay(80);
}else if(myVar==3){
      gotoAndPlay(130);
}else if(myVar==4){
      gotoAndPlay(180);
}
0
 

Author Comment

by:AcydTrip
ID: 13687162
THANKS!!!  YOU ROCK!!!  Thank you very much for the quick answer.  I'm finding Flash interesting, but intimidating.
0
 

Author Comment

by:AcydTrip
ID: 13687399
PROBLEM!!

I put this in place, and when I go to test it, I get

**Error** Scene=Scene 1, layer=nav, frame=1:Line 2: Operator '=' must be followed by an operand
          myVar=1;

**Error** Scene=Scene 1, layer=nav, frame=1:Line 1: Statement must appear within on handler
     btn_image.onPress=function(){

**Error** Scene=Scene 1, layer=nav, frame=1:Line 3: Syntax error.
          gotoAndPlay(20);

**Error** Scene=Scene 1, layer=nav, frame=1:Line 2: Operator '=' must be followed by an operand
          myVar=2;

**Error** Scene=Scene 1, layer=nav, frame=1:Line 1: Statement must appear within on handler
     btn_image.onPress=function(){

**Error** Scene=Scene 1, layer=nav, frame=1:Line 3: Syntax error.
          gotoAndPlay(40);

**Error** Scene=Scene 1, layer=nav, frame=1:Line 2: Operator '=' must be followed by an operand
          myVar=3;

**Error** Scene=Scene 1, layer=nav, frame=1:Line 1: Statement must appear within on handler
     btn_image.onPress=function() {

**Error** Scene=Scene 1, layer=nav, frame=1:Line 3: Syntax error.
          gotoAndPlay(60);

**Error** Scene=Scene 1, layer=nav, frame=1:Line 2: Operator '=' must be followed by an operand
          myVar=4;

**Error** Scene=Scene 1, layer=nav, frame=1:Line 1: Statement must appear within on handler
     btn_image.onPress=function(){

**Error** Scene=Scene 1, layer=nav, frame=1:Line 3: Syntax error.
          gotoAndPlay(80);

**Error** Scene=Scene 1, layer=nav, frame=1:Line 2: Operator '=' must be followed by an operand
          myVar=5;

**Error** Scene=Scene 1, layer=nav, frame=1:Line 1: Statement must appear within on handler
     btn_image.onPress=function(){

**Error** Scene=Scene 1, layer=nav, frame=1:Line 3: Syntax error.
          gotoAndPlay(100);

**Error** Scene=Scene 1, layer=actions, frame=29:Line 2: Syntax error.
          gotoAndPlay(10);

**Error** Scene=Scene 1, layer=actions, frame=29:Line 3: Unexpected '}' encountered
     }else if(myVar==2){

**Error** Scene=Scene 1, layer=actions, frame=49:Line 2: Syntax error.
          gotoAndPlay(10);

**Error** Scene=Scene 1, layer=actions, frame=49:Line 3: Unexpected '}' encountered
     }else if(myVar==2){

**Error** Scene=Scene 1, layer=actions, frame=69:Line 2: Syntax error.
          gotoAndPlay(10);

**Error** Scene=Scene 1, layer=actions, frame=69:Line 3: Unexpected '}' encountered
     }else if(myVar==2){

**Error** Scene=Scene 1, layer=actions, frame=89:Line 2: Syntax error.
          gotoAndPlay(10);

**Error** Scene=Scene 1, layer=actions, frame=89:Line 3: Unexpected '}' encountered
     }else if(myVar==2){

**Error** Scene=Scene 1, layer=actions, frame=109:Line 2: Syntax error.
          gotoAndPlay(10);

**Error** Scene=Scene 1, layer=actions, frame=109:Line 3: Unexpected '}' encountered
     }else if(myVar==2){

Total ActionScript Errors: 25        Reported Errors: 25
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:onFocus
ID: 13687477
Paste your entire code here.
0
 

Author Comment

by:AcydTrip
ID: 13687526
Forgive my ignorance, but I'm not sure how to display it all in one shot.

What I have is this

if(myVar==1){
     gotoAndPlay(10);
}else if(myVar==2){
     gotoAndPlay(30);
}else if(myVar==3){
     gotoAndPlay(50);
}else if(myVar==4){
     gotoAndPlay(70);
}
in 5 frames

and this in 5 others.

on(release){
     gotoAndPlay(20);
      myVar=1; 
}


I changed it to this while trying things out, I dropped 5 errors I'm down to 20 now.

If there's a way to display all of the script from the whole thing, please let me know, I'd be more than happy to post it.
0
 

Author Comment

by:AcydTrip
ID: 13690107
Hey, no worries, it works.  I don't know what the deal is, I got errors, I got errors, I typed EXACTLY the same code into a new file, worked perfect.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question