Question

For reasons beyond my control, I am currently working on a series of flash files, which have numeric frame labels. This causes a problem, because Flash seems to treat strings the same as integers when using gotoAndPlay/gotoAndStop.

Screenshot:

screenshot

For example, gotoAndPlay('96') won't actually goto the frame with a label of "96," instead it will gotoAndPlay frame #96.

Right now, it seems like the only solution is to manually figure out which frame each of the labels rests on, so instead of using gotoAndPlay('96') I would use gotoAndPlay(718). Obviously, this would be tedious (there are LOTS of frame labels) and it would also require changing the frame numbers if any edits require things to be moved around.

Any ideas? Is there anyway to force flash to gotAndPlay/Stop on a numeric frame label that I've overlooked?

Was it helpful?

Solution

That seems like a Flash Player bug (or at least a design flaw) to me. But you should be able to use the currentLabels property on the MovieClip which will give you an array of FrameLabel objects. Then use that to create your own mapping between the frame label numeric strings and the actual frame numbers.

Here's some sample code of what I'm talking about:

var label : FrameLabel;
var mapping : Object = {};

// Create a mapping between frame label string (regardless of semantics)
// and the frame number that it corresponds to.
for each (label in myMovieClip.currentLabels) {
  mapping[label.name] = label.frame;
}


/**
 * Your own version of gotoAndPlay for labels, which will look into your
 * recently created mapping and play the right frame (by number) for the
 * given frame label.
*/
function gotoAndPlayLabel(label : String) : void
{
  myMovieClip.gotoAndPlay( mapping[label] );
}

You would then use your own gotoAndPlayLabel() function to jump to (and play) a frame by it's label.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top