[flexcoders] Re: Bind to Dynamic Component or Panel
I am on the path of creating an associative array with reference to the objects (which is this case is a datagrid). However I can't seem to figure out how to update the data provider when a new message is received from my source. Here is how I create the GUI dynamically. CONFIGARRAY gets populated from a DB query. I then loop through creating a panel with a datagrid. At the end I add the panel to the canvas for display. Can someone advise how I could reference the datagrids to bind new data to them when a message is recieved from the server. This step would obviously occur based on an event listener. Basically what I need to do is say something like (if message contains msgType1 then send the message to datagrid1) Here is the gui creation code: for ( var i:int = 0; i CONFIGARRAY.length; i++) { var panel:SuperPanel = new SuperPanel(); var datagrid:DashBoardADG = new DashBoardADG(); datagrid.percentHeight = 100; datagrid.percentWidth = 100; datagrid.id = CONFIGARRAY.getItemAt(i).Panel_Name; datagrid.dataProvider = dataFeed; panel.title = CONFIGARRAY.getItemAt(i).Panel_Name; panel.showControls = true; panel.enableResize = true; panel.width = 400; panel.height = 150; panel.x = X; X = X + 410; panel.y = Y; // if (panelcounter 2) { Y = Y + 160; X = 0; panelcounter = 1; } panelcounter++; panel.addChild(datagrid); PANELARRAY.addItem(); //ADD something for reference to datagrid this.MAIN2.addChild(panel); //MAIN2 is a canvas } --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: I would instead advise that when you create the child, you place a reference to it in some kind of dictionary structure, like an array, an associative array(object), or dictionary. Use that reference to access public members, add event listeners, etc. You will not need to worry about where it is in the dom. Tracy --- In flexcoders@yahoogroups.com, gjessup1 gregjessup@ wrote: Oscar, Thanks for that. That is basically exactly what I needed. The one problem I am running into is that I want my panels to be only 3 wide on the page and I have 12 entries in the DB. So I am creating a page 3 panels wide and 4 panels down. To do this I create a new HBOX every 3rd Panel. so I need a way to figure out which HBOX the panel is in. Then I can do HBOX3.getChildByName(My Panel) The way I am starting to do this is by creating an array collection that keeps the Panel Names and the childIndex for the HBOX and the Panel. What would be nice is if you had a Canvas and and it didn't matter how many levels deep the panel was (i.e the panel had a global bindable name) Then you could do Canvas.getChildByName. I can post code if that doesn't make sense.
[flexcoders] Re: Bind to Dynamic Component or Panel
It sounds like getChildByName is what you need: yourContainer.getChildByName(panel1) Regards, Oscar http://www.holaflex.com http://www.holaflex.com --- In flexcoders@yahoogroups.com, gjessup1 [EMAIL PROTECTED] wrote: I am creating a UI that gets configured from a database. For each DB entry it creates a panel dynamically. Then I have my app receiving messages. Based on the values in the message I decide which panel I want to display the message on. My question is when a panel is dynamically generated. How do I reference it so I can bind to it. i.e panel1.addChild(some object); Is there a getelementbyid reference. Does anyone else have a gui like this they could explain how they are doing it. thanks Greg
[flexcoders] Re: Bind to Dynamic Component or Panel
Oscar, Thanks for that. That is basically exactly what I needed. The one problem I am running into is that I want my panels to be only 3 wide on the page and I have 12 entries in the DB. So I am creating a page 3 panels wide and 4 panels down. To do this I create a new HBOX every 3rd Panel. so I need a way to figure out which HBOX the panel is in. Then I can do HBOX3.getChildByName(My Panel) The way I am starting to do this is by creating an array collection that keeps the Panel Names and the childIndex for the HBOX and the Panel. What would be nice is if you had a Canvas and and it didn't matter how many levels deep the panel was (i.e the panel had a global bindable name) Then you could do Canvas.getChildByName. I can post code if that doesn't make sense.
[flexcoders] Re: Bind to Dynamic Component or Panel
I would instead advise that when you create the child, you place a reference to it in some kind of dictionary structure, like an array, an associative array(object), or dictionary. Use that reference to access public members, add event listeners, etc. You will not need to worry about where it is in the dom. Tracy --- In flexcoders@yahoogroups.com, gjessup1 [EMAIL PROTECTED] wrote: Oscar, Thanks for that. That is basically exactly what I needed. The one problem I am running into is that I want my panels to be only 3 wide on the page and I have 12 entries in the DB. So I am creating a page 3 panels wide and 4 panels down. To do this I create a new HBOX every 3rd Panel. so I need a way to figure out which HBOX the panel is in. Then I can do HBOX3.getChildByName(My Panel) The way I am starting to do this is by creating an array collection that keeps the Panel Names and the childIndex for the HBOX and the Panel. What would be nice is if you had a Canvas and and it didn't matter how many levels deep the panel was (i.e the panel had a global bindable name) Then you could do Canvas.getChildByName. I can post code if that doesn't make sense.