labels that are numbers

today i was given a movieClip of a candle slowly burning down. it had 15 states represented by numbered frame labels, and i wanted to go to the appropriate label based on the number of days the candle had been burning. the problem is, even if you convert the variable to a string, flash treats it as a number. so:

days=14;
gotoAndStop(String(days));

even though this is a string, flash still interprets this as frame number rather than a frame label. it goes to frame 14, rather than label ’14’. there may be a solution out there, but the only one i know is renaming all of the labels to include an alpha character. laborious…

AS3 to the rescue!

we now have access to available frame labels and the related frame numbers in an array. so assuming we know where which number label we’re after – which is easy in my case where the labels where numbered from 1 to 15, we can easily access the label even if its name is a number:

days=14;
this.gotoAndStop(this.currentLabels[days-1].frame);

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with:
Posted in Flash

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: