I was looking for this code... here it is...
at http://lassieadventurestudio.wordpress.com/2008/09/16/movieclip-frame-labels/
The first and most basic new feature is the MovieClip.currentLabel property. That gives us the frame label of the current timeline frame. While that may seem pretty straight forward, it’s a huge step up from AS2 where the current frame label was not available at run-time (…which always seemed like a pretty big oversight to me).
However, I think the best new feature is the MovieClip.currentLabels property, which gives an array of ALL frame labels on a timeline, along with their corresponding frame numbers. AWESOME. That means that we can quickly and easily set up a scenario that will let us browse all of a MovieClip’s labeled timeline frames at run-time. Here’s an example:
import flash.display.FrameLabel;
// _displayClip = MovieClip with timeline to access.
// _select = Flash UI ComboBox component instance.
_displayClip.stop();
_select.removeAll();
_select.addEventListener(Event.CHANGE, this._onSelectLabel);
// get and populate all of displayClip's frame labels in the select menu
for each (var j:FrameLabel in _displayClip.currentLabels)
{
// add list items with FrameLabel object properties: name, frame.
_select.addItem({label:j.name, data:j.frame});
}
function _onSelectLabel(evt:Event):void
{
// update displayClip when a new frame is selected
_displayClip.gotoAndStop(_select.selectedItem.data);
}
If you set that scenario up in a new Flash document and give the _displayClip a few frame labels to browse through, then you’ll be able to select and display the various frames in your MovieClip using the combobox (…just be sure to put different graphics on each labeled timeline frame so that you can see a change in appearance when you switch between frames!).
So, what can you do with this? I’ve used it in the new Lassie Shepherd editor so that a developer can select frame labels to display within externally loaded SWF media. It works like a charm. This would also be a good means to build a really simple navigation scheme: you’d set up and label different content frames along a timeline, load that movie into a shell, and then you could populate navigation options within the shell based on the frame labels. The beauty here is that if you ever added new content frames to the loaded media, they’d plug right into the shell movie that rendered the navigation.
Thursday, March 12, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment