Hello,

I'm having a problem with my component.
It has the same sort of functionality as a tabbar,
but more visual requirements ( hover fx etc.  ).

My tabs ( = Canvas component ) always returns width=0;
What am I doing wrong ?





This is my code for the main class:

package be.webdevotion.connguide.view
{
import mx.core.UIComponent;
import flash.display.Sprite;
import mx.containers.Canvas;
import be.webdevotion.shapes.Rectangle;

public class TopMenu extends UIComponent
{
private var _items : Array;
private var tabs : Canvas;
private var children : Array;
private var itemsChanged : Boolean = false;

public function TopMenu()
{
super();
}
[Bindable]
public function set items ( a : Array ) : void
{
_items = a;
itemsChanged = true;
invalidateProperties();
invalidateSize();
}
public function get items () : Array
{
return _items;
}
override protected function createChildren () : void
{
super.createChildren();
if( ! tabs )
{
children = new Array();
tabs = new Canvas();
}
addChild( tabs );
}
override protected function commitProperties():void
{
super.commitProperties();
if( itemsChanged )
{
var i : Number = 0;
var n : Number = _items.length;
var tab : Tab;
var remw : Number = 0;
for(i=0;i<n;i++)
{
tab = new Tab();
children.push( tab );
tab.label = _items[i];
tab.x = remw;
remw = tab.width;
tabs.addChild( tab );
}
}
}
override protected function measure():void
{
super.measure();
measuredWidth = measuredMinWidth = this.width;
measuredHeight = measuredMinHeight = this.height;
trace(">"+tabs.width);
}
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth,unscaledHeight);
tabs.x = unscaledWidth - tabs.width;
trace(">"+tabs.width);
}
private function onResize ( event : Event = null ) : void
{
tabs.x = this.width - tabs.width;
}
}
}

Reply via email to