V2 TabBar - simple example

Here's a simple example of using the V2 TabBar (version 1.0.1) in Flash.


1. Add a TabBar and Loader to the Library.

2. Add this code (frame 1 of Timeline):

var tabListener:Object = new Object();
tabListener.change = function(evt:Object) {
   content_ldr.load(evt.target.value);
};
this.createClassObject(mx.controls.TabBar, "myTabBar", this.getNextHighestDepth());
myTabBar.addEventListener("change", tabListener); myTabBar.setSize(550, 30);
myTabBar.addItem({label:"Home", data:"http://www.flash-mx.com/images/image1.jpg"});
myTabBar.addItem({label:"News", data:"http://www.flash-mx.com/images/image2.jpg"});
this.createClassObject(mx.controls.Loader, "content_ldr", this.getNextHighestDepth(), {_x:0, _y:30, _width:550, _height:370});

3. Ctrl+Enter.

If you bought DRK5 which includes the original version of this component, you can update to the V2 version for free. For more information, visit this link.

Posted by jen on August 25, 2004 at 07:50 PM
Comments

Hi Jen,

It seems that your example is about the only one out there on the subject of using the TabBar component with AS. You wouldn't happen to know how to get a MovieClip loaded into the data part of the Dataprovider Array that you provide it.

var tabBar:TabBar = _root.testTabBar;
var tabObj:Array = {label:"Test Tab 1", data:"testContent_mc"};

tabBar.addItem(tabObj);

In my case "testContent_mc" is set in the library with a linkage identifier of the same name. It doesn't work the way I have it. Any ideas?

Thanks.

-Chris

Posted by: Chris at November 29, 2004 04:40 PM