PDA

View Full Version : How to get the frame label using actionscript?


4_ever
06-14-2003, 02:36 AM
I have several Frame Labels in the timeline and "Next" button.
Frame 1 has a keyframe with label "start".
Frame 21 has a keyframe with label "mike".
Frame 63 has a keyframe with label "problem".

Generally speaking I'm trying to retrieve the label of the current frame the playhead was on when the button was released.

The code bellow retrieves the frame number the play head was on when the button was released. And then depending on frame number it assigns the label to the variable called "next", so that the playhead could go to that frame label and play the movie from that point.

on (release)
{
var next;
var frame= _currentframe;
if (frame<21)
{
next = "mike";
}
if (frame<128 && frame>21)
{
next = "problem";
}
gotoAndPlay(next);
}

But using frame numbers is not a very good idea because if I add or delete some frames, the functionality of the button won't work any more.

What I really want to know if there is some way to get the frame label using actionscript.

Any suggestions are fully appreciated;)

CyanBlue
06-14-2003, 02:43 AM
Howdy and Welcome... ;)

Check these threads...
http://www.actionscript.org/forums/showthread.php3?s=&threadid=22805
http://www.actionscript.org/forums/showthread.php3?s=&threadid=26221

Colin Campbell
06-14-2003, 02:52 AM
welcome... I'm pretty sure to call a frame name its almost like a target... you just call the frame name... but I'm a newbie too, so don't trust me. Am I right people?

Timmee_3Styler
06-14-2003, 04:55 AM
yup I believe your right
but then again....... I live in an igloo..wat do i know :p

4_ever
06-14-2003, 05:43 AM
CyanBlue you are geneous!!!:)
It really works, thank you for the idea.

Though I had to make a little bit of changes. In your example
http://www.actionscript.org/forums/showthread.php3?s=&threadid=22805
in order to get the value of the currentlable you used: _level0.frameLabel = _level0.myClip._currentlabel;

When I typed keyword _level0 and put dot(.) after it I didn't give me an option to choose frameLable from the listbox . And the same with the name of the instance name of the movie clip (in your example it would be _level0.myClip)

Here is what I came up with:
on (release)
{
var next;
var prev;

var frame = this._currentlabel;

if (frame == "start")
{
next = "mike";
}
if (frame=="mike")
{
next = "problem";
}
gotoAndPlay(next);
}

Once again thank you for your geneous idea

CyanBlue
06-14-2003, 05:52 AM
Um... Let me make sure that I get what you are saying...When I typed keyword _level0 and put dot(.) after it I didn't give me an option to choose frameLable from the listbox . And the same with the name of the instance name of the movie clip (in your example it would be _level0.myClip)Are you talking about the sort-of auto complete type listbox that pops up when you type '.' after _level0??? You are not supposed to see 'frameLable' within the list because that 'frameLable' is a custom variable... Is that what you are saying???

And, thank you, but that is no way near the genius idea... That's crude idea... Think what is going to happen if you happened to have 100 frame labels??? It ain't going to be easy... :D

freddycodes
06-14-2003, 06:41 AM
Jason check it out
http://sitepointforums.com/showthread.php?threadid=113583

Already answered it