Skip to main content
Participant
Aug 11, 2006 2:46 AM UTC
Answered

on (release) help

I am real new to Flash. I have been working on a site http://d9wc.com on of many problems I am currently having difficulty in figuring out is - when you click on a button you can send it to a particular frame number (for this instance frame 99. I want it to play 99 through159. I then want it to play frame 160. The problem is that I have 4 additional buttons I also want to play those same frames 99 through 159, but then jump to 161, 162, 163 or 164. There is probably and easy way to do this but I am stuck. to see what I am tring to do got to http://d9wc.com/servicetest.html then click on special wallcoverings you will see the menu move over to the left and then expand out sub menu Items. What I want is when they click on another item not in the sub menu for everything to repack and go back to original place then the info appear below. I am sure that my file organization method is all messed up, but it is working so far. And Like I said I am new to flash (This is my first project) so any help would be great.

Thanks

the fla file is located at http://d9wc.com/service menu.fla 2,448 kb
the swf file is located at http://www.d9wc.com/images/buttons/services menu.swf 92 kb
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
Aug 11, 2006 4:41 AM UTC
whyitsme,

> The problem is that I have 4 additional buttons I also
> want to play those same frames 99 through 159, but
> then jump to 161, 162, 163 or 164. There is probably
> and easy way to do this but I am stuck.

For something like this, I would use a variable in the main timeline.
Use the var statement to declare a variable, then set the value of that
variable with your buttons. Later on, you can check the variable's value
and use an if() statement to decide which frame to send the playhead to.

// In frame 1 of the main timeline
var guidePost:String = "";

Here, we have an arbitrarily named variable, guidePost, that will ...
well, that will lead the way, like a guide post. ;) If you're publishing
to ActionScript 2.0, the next part -- :String -- means that this variable is
a string (as opposed to a number, for example). If you're publishing to
ActionScript 1.0, leave that part off. Then there's an assignment operator
(the equals sign), and finally an empty string, "". Because this is
declared in frame 1, the variable now exists for all other frames after it;
in other words, for the whole timeline.

// On each of your buttons
// Button A
on (release) {
guidePost = "a";
gotoAndPlay(99);
}
// Button B
on (release) {
guidePost = "b";
gotoAndPlay(99);
}
// etc.

You with me? Each button sends the playhead to frame 99, and yet each
button sets that variable to something different.

Now, on frame 159, you'll put another frame script:

// In frame 159 of the main timeline
if (guidePost == "a") {
gotoAndStop(160);
}
if (guidePost == "b") {
gotoAndStop(161);
}
// etc.

Not too hard, right? Notice that the operator has changed. This time,
it's the equality operator (two equals signs), rather than the assignment
operator. Don't confuse those.

That's the most basic approach I can think of. If you want to get
fancy, you can use a switch() statement instead. Just for grins ... erase
the series of if() statements and use this intead:

// In frame 159 of the main timeline
switch(guidePost) {
case "a":
gotoAndStop(160);
break;
case "b":
gotoAndStop(161);
break;
// etc.
}

Similar approach. Maybe that one makes more sense to you.

It's always bewildering at first, but if you get yourself grounded, and
if you get comfortable reading the built-in documentation, you'll find that
things begin to fall into place.

http://www.quip.net/blog/first-time-here/


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


3 replies

kglad
Community Expert
Community Expert
Aug 11, 2006 4:57 AM UTC
each button can set a variable (say yourVar =161 for your first button) that indicates the frame to goto after 159. attached to frame 159 you can use a _root.gotoAndPlay(yourVar) statement.
Translate
Newsgroup_UserCorrect answer
Inspiring
Aug 11, 2006 4:41 AM UTC
whyitsme,

> The problem is that I have 4 additional buttons I also
> want to play those same frames 99 through 159, but
> then jump to 161, 162, 163 or 164. There is probably
> and easy way to do this but I am stuck.

For something like this, I would use a variable in the main timeline.
Use the var statement to declare a variable, then set the value of that
variable with your buttons. Later on, you can check the variable's value
and use an if() statement to decide which frame to send the playhead to.

// In frame 1 of the main timeline
var guidePost:String = "";

Here, we have an arbitrarily named variable, guidePost, that will ...
well, that will lead the way, like a guide post. ;) If you're publishing
to ActionScript 2.0, the next part -- :String -- means that this variable is
a string (as opposed to a number, for example). If you're publishing to
ActionScript 1.0, leave that part off. Then there's an assignment operator
(the equals sign), and finally an empty string, "". Because this is
declared in frame 1, the variable now exists for all other frames after it;
in other words, for the whole timeline.

// On each of your buttons
// Button A
on (release) {
guidePost = "a";
gotoAndPlay(99);
}
// Button B
on (release) {
guidePost = "b";
gotoAndPlay(99);
}
// etc.

You with me? Each button sends the playhead to frame 99, and yet each
button sets that variable to something different.

Now, on frame 159, you'll put another frame script:

// In frame 159 of the main timeline
if (guidePost == "a") {
gotoAndStop(160);
}
if (guidePost == "b") {
gotoAndStop(161);
}
// etc.

Not too hard, right? Notice that the operator has changed. This time,
it's the equality operator (two equals signs), rather than the assignment
operator. Don't confuse those.

That's the most basic approach I can think of. If you want to get
fancy, you can use a switch() statement instead. Just for grins ... erase
the series of if() statements and use this intead:

// In frame 159 of the main timeline
switch(guidePost) {
case "a":
gotoAndStop(160);
break;
case "b":
gotoAndStop(161);
break;
// etc.
}

Similar approach. Maybe that one makes more sense to you.

It's always bewildering at first, but if you get yourself grounded, and
if you get comfortable reading the built-in documentation, you'll find that
things begin to fall into place.

http://www.quip.net/blog/first-time-here/


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
whyitsmeAuthor
Participant
Aug 11, 2006 3:14 PM UTC
David,

Thank you very very much, your assistance helped alot. Once I figured out what you were saying was able to imput the strings you mentioned and it worked. I did not do it in the first frame as suggested as those particular buttons when clicked on in the first part of movie they behave differently (no need to play the frames 99 through 159, but jump directly to the later frame.

So thanks again for your assistance

Keith Drevecky
Translate