Solved

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

Posted on 2009-05-11
9
2,421 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
  • 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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…
Read about the importance of offline branding in the digital age.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 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