Solved

Is it possible to dynamically add children to a TabNavigator from a Repeater in FLEX 3?

Posted on 2009-05-11
9
2,440 Views
Last Modified: 2012-05-06
Is it possible to dynamically add children to a tabnavigator from a repeater in Flex 3?

If Yes, can you provide an example?

Thanks!
0
Comment
Question by:20lbMonkey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 24359892
Not sure what you mean.  But you can write a loop and dynamically add Tabs to a tab navigator to say add 3 tads at once?
0
 

Author Comment

by:20lbMonkey
ID: 24359913
Except do it in using an MXML component and a repeater.

Like this:

<mx:Repeater id="prodRepeater"
      width="100%" height="100%"
      dataProvider="{prodEditArray}">
      <v:ProductEditDetail id="prod"
           width="130" height="100%"
           productEditsItem="{prodRepeater.currentItem}"/>
</mx:Repeater>

Based on the results from the repeater, i want to dynamically add tabs to a tabnavigator based on the number of items returned from this snippet.

Does that make sense?
0
 

Author Comment

by:20lbMonkey
ID: 24360057
You can probably tell by my questions that i am pretty new. Would the TabBar work in this situation?
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 19

Expert Comment

by:Jones911
ID: 24360191
I'm just not understanding why you need to do this.  You can loop over prodEditArray and add tabs I do'nt know why this needs to be in a repeater.
0
 

Author Comment

by:20lbMonkey
ID: 24360218
Actually, it doesnt have to be.

So, you are saying that you would recommend looping through the prodEditArray in ActionScript and dynamically create the child tabs?

If yes, then would you fully add the tab navigator child tabs before adding the controls to each tab or do it at the time of the creation?

Thanks for your help!

0
 
LVL 19

Accepted Solution

by:
Jones911 earned 500 total points
ID: 24360230
This is what I think your doign let me know if I'm off.

Lets say you have a bunch on students in the array.  You click on a student then for that student want to add all the Classes they are enrolled in into seperated tabs.  This si just and example but I think its the "type" of end result your after.

In this case I would loop over the array and add the tabs and in each tab add the items you want for that tab.  I would add the items into a vbox ( or whatever u want ) then add that into the tab and add the tab to the navagator.
0
 

Author Comment

by:20lbMonkey
ID: 24365535
Thanks for the quick overview. It really  helped to send me down the right path of reading and coding.

Here is what I wrote:

for (var i:int = 0; i < prodEditArray.length; i++)
{
      var source:String = new String();                              var _canvas:Canvas = new Canvas();
      var _label:Label = new Label();
      var _image:Image = new Image();                        

      _label.text = prodEditArray[i].labelID
      _image.source = prodEditArray[i].imageDir + prodEditArray[i].imageName;
                     _canvas.addChild(_label);
                     _canvas.addChild(_image);                        
                              
      this.TabEdit.addChild(_canvas);                        
}

It is loading and working pretty slick. My only issue now is that I cannot get the _lable to populate on the TabNavigator. I wants to add it inside of the canvas and the Image overwrites it.

Is there a different control that I should be looking at to pupulate the TabNavigator.label?

Thanks again for your help!      
0
 

Author Comment

by:20lbMonkey
ID: 24365770
Scratch that, after i sent the last message, I figured out what i was doing wrong.

Here is the code that worked.

for (var i:int = 0; i < prodEditArray.length; i++)
{
      var source:String = new String();      
                     var _canvas:Canvas = new Canvas();                  
      var _image:Image = new Image();      
                              
      _image.source = prodEditArray[i].imageDir + prodEditArray[i].imageName;                              
      _canvas.label = prodEditArray[i].labelID;
      _canvas.addChild(_image);                        
                              
      this.TabEdit.addChild(_canvas);                                    
}
0
 

Author Closing Comment

by:20lbMonkey
ID: 31580359
Thanks for you guidance!
0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question