RE: [flexcoders] I really don't know JS about Flex.. help with multirow tabbar

2008-02-05 Thread Tracy Spratt
Google: Flex multi line Tab

 

You will find a Flex 1.5 component by Darron Schall.  I would attempt to
migrate his component to 2.x before starting from scratch on my own.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of targetplanet
Sent: Monday, February 04, 2008 11:21 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] I really don't know JS about Flex.. help with
multirow tabbar

 

ok so I am building an app that needs two tab bars, and I was under
the assumption that the tab bars would return to the next line if it
was too large for the space...hence the post title...I though for an
instance about extending the TabBar component to try and create a
multiline tabBar, but(see title). So then I though ok I can create a
component that loops through my dataProvider array, assigning it to a
TabBar, checks the TabBar width against a set width, removes items
from the array until the bar is the right width, remove those items
from the original array, and repeat with a new TabBar. So here is my
attempt.
Needless to say, it doesn't work, and I feel like I am no where near a
solution. If anyone can help, or already has an exmple of a multiline
tabbar, that would be great.

Thanks,
Russ

I am trying to inplement this with mxml like:


package com.infusion.view.components
{

import flash.display.Sprite;

import mx.collections.ArrayCollection;
import mx.controls.TabBar;
//import mx.core.UIComponent;
import mx.events.CollectionEvent;
import mx.events.ItemClickEvent;

public class MultiRowTabs extends Sprite
{

public var _dataProvider:ArrayCollection = new ArrayCollection();

private var yPos:Number = 0;

public function MultiRowTabs()
{
trace("mrtInit");
//dataProvider = new ArrayCollection();
//_dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE,
onChange);
}

private function click(e:ItemClickEvent):void{
trace("click");
}

private function onChange(dataProvider:ArrayCollection):void{

trace(dataProvider.toString());
var count:int = 0
var data:ArrayCollection = dataProvider;
while(count < dataProvider.length){
var dArray:Array = data.toArray();

var t:TabBar = new TabBar();
t.dataProvider = data;
t.addEventListener(ItemClickEvent.ITEM_CLICK, click);
if(t.width > width){ 
for(var i:int=data.length; i>0 ; i--){
data.removeItemAt(i);
}
}
t.y = yPos;
addChild(t);
yPos += 30;
count += data.length;
dArray.splice(0,data.length);
data.source = dArray;
}
}

public function set dataProvider(dp:ArrayCollection):void{
//_dataProvider = dp;
trace("dp "+dp.toString());
onChange(dp);
}
}
}

 



[flexcoders] I really don't know JS about Flex.. help with multirow tabbar

2008-02-04 Thread targetplanet
ok so I am building an app that needs two tab bars, and I was under
the assumption that the tab bars would return to the next line if it
was too large for the space...hence the post title...I though for an
instance about extending the TabBar component to try and create a
multiline tabBar, but(see title).  So then I though ok I can create a
component that loops through my dataProvider array, assigning it to a
TabBar, checks the TabBar width against a set width, removes items
from the array until the bar is the right width, remove those items
from the original array, and repeat with a new TabBar.  So here is my
attempt.
Needless to say, it doesn't work, and I feel like I am no where near a
solution.  If anyone can help, or already has an exmple of a multiline
tabbar, that would be great.

Thanks,
Russ

I am trying to inplement this with mxml like:


package com.infusion.view.components
{

import flash.display.Sprite;

import mx.collections.ArrayCollection;
import mx.controls.TabBar;
//import mx.core.UIComponent;
import mx.events.CollectionEvent;
import mx.events.ItemClickEvent;

public class MultiRowTabs extends Sprite
{

public var _dataProvider:ArrayCollection = new 
ArrayCollection();

private var yPos:Number = 0;

public function MultiRowTabs()
{
trace("mrtInit");
//dataProvider = new ArrayCollection();

//_dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE,
onChange);
}

private function click(e:ItemClickEvent):void{
trace("click");
}

private function onChange(dataProvider:ArrayCollection):void{

trace(dataProvider.toString());
var count:int = 0
var data:ArrayCollection = dataProvider;
while(count < dataProvider.length){
var dArray:Array = data.toArray();

var t:TabBar = new TabBar();
t.dataProvider = data;
t.addEventListener(ItemClickEvent.ITEM_CLICK, 
click);
if(t.width > width){
for(var i:int=data.length; i>0 ; i--){
data.removeItemAt(i);
}
}
t.y = yPos;
addChild(t);
yPos += 30;
count += data.length;
dArray.splice(0,data.length);
data.source = dArray;
}
}

public function set dataProvider(dp:ArrayCollection):void{
//_dataProvider = dp;
trace("dp "+dp.toString());
onChange(dp);
}
}
}