You can still create the instances dynamically, but you'll need a non- local variable to store the *references* to the instances so you can get at them later on in your WS handler. Maybe an Array would work? You could push the dynamically-created RTE instance onto the Array and then pass an array index integer in addition to a string equivalent to the name of the array variable. You could then access the RTE instance in your handler as:
var theArray: Array = this[_resultID]; var myDynamicRTE: RichTextEditor = RichTextEditor(theArray [_resultIndex]); Hopefully this is all making sense to you. There are probably other (better?) approaches as well; possibly a custom event for you service. --- In [email protected], "Nate Pearson" <[EMAIL PROTECTED]> wrote: > > These RTEs are dynamic. Some times they are removed and sometimes > they are added. There will at least be 9 on different tabs. these > will be added and removed based on user interaction. If I declare my > variable out side of that function it will link the .html text > property to all of my RTEs. > > > > --- In [email protected], "Doug Lowder" <douglowder@> wrote: > > > > Oh, and you'll need to declare the myRTE variable outside of the > > onLoad() function instead of within it. > > > > --- In [email protected], "Doug Lowder" <douglowder@> > > wrote: > > > > > > Setting the id property of an object created in script serves no > > > purpose. It's like knocking on your own front door to see whether > > > you're home or not. Or something. Anyway, you can ditch > > > the 'myRTE.id = "item1" ' line. The rest of the changes would be > > > similar to: > > > > > > private var _resultID:String = "myRTE"; > > > ... > > > this[_resultID].htmltext = _resultText > > > > > > --- In [email protected], "Nate Pearson" <napearson99@> > > > wrote: > > > > > > > > if i do that i get: ReferenceError: Error #1069: Property item1 > > not > > > > found on Systems and there is no default value. > > > > > > > > I made a sample app that demonstrates the problem. THanks so > > much > > > for > > > > your guys' replies. > > > > > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > > > creationComplete="onLoad()" layout="absolute"> > > > > <mx:Script> > > > > <![CDATA[ > > > > import mx.rpc.events.ResultEvent; > > > > import mx.controls.*; > > > > //fake webservice result data > > > > private var _resultID:String = "item1" > > > > private var _resultText:String = "Text I want" > > > > > > > > private function onLoad():void{ > > > > var myRTE:RichTextEditor = new RichTextEditor; > > > > myRTE.percentWidth=100 > > > > myRTE.id = "item1" > > > > myRTE.percentHeight=100 > > > > myRTE.styleName = "rte" > > > > addChild(myRTE); > > > > > > > > //call .NET webservice. We can fake > > > the handler. > > > > wsHandler() > > > > } > > > > private function wsHandler():void{ > > > > //Here i want to get the result text into the > > > RTE i made above. > > > > //Rules: the item1 text is dynamic, so you > > > cant just do > > > > item1.htmltext = _resultText > > > > // In the real app the RTEs are nested > > > pretty deep, so > > > > getChildByName doesnt work unless > > > > //you can reference the parent container. > > > > > > > // > > > > //var myID:String = String(_resultID); > > > > //var rte:RichTextEditor = this[myID]; > > > > //rte.htmlText = "TEST"; > > > > } > > > > ]]> > > > > </mx:Script> > > > > </mx:Application> > > > > > > > > > > > > > > > > > > > > --- In [email protected], "Tracy Spratt" <tspratt@> > > wrote: > > > > > > > > > > Jumping in: > > > > >c > > > > > > > > > > > > > > > > > > > > Tracy > > > > > > > > > > > > > > > > > > > > ________________________________ > > > > > > > > > > From: [email protected] > > > [mailto:[EMAIL PROTECTED] On > > > > > Behalf Of Nate Pearson > > > > > Sent: Wednesday, April 11, 2007 4:37 PM > > > > > To: [email protected] > > > > > Subject: [flexcoders] Re: Changing a string to reference an ID > > of > > > an > > > > > Object > > > > > > > > > > > > > > > > > > > > Yes, but if "item1" gets passed back as a string in my result > > > event I > > > > > don't know how to reference it. > > > > > I.E. > > > > > > > > > > var myID:String = String(event.result[0]) > > > > > > > > > > Now how do I reference the RTE with that ID? > > > > > > > > > > > > > > > --- In [email protected] <mailto:flexcoders% > > > 40yahoogroups.com> > > > > > , "Doug Lowder" <douglowder@> wrote: > > > > > > > > > > > > Hi Nate, > > > > > > > > > > > > The id property of mxml components just tells the compiler > > what > > > to > > > > > name > > > > > > the instance variable when it generates the actionscript > > code. > > > So, > > > > > > your mxml object with id "item1" can be referenced in script > > as > > > simply > > > > > > > > > > > item1: > > > > > > > > > > > > item1.htmlText = "TEST"; > > > > > > > > > > > > Search the archives for more info; there are some really good > > > posts on > > > > > > > > > > > this topic direct from the Adobe folks. > > > > > > > > > > > > > > > > > > --- In [email protected] > > > > > <mailto:flexcoders%40yahoogroups.com> , "Nate Pearson" > > > <napearson99@> > > > > > > wrote: > > > > > > > > > > > > > > I am calling a webservice to get text for an item > > > (RichTextEditor) > > > > > that > > > > > > > I am adding dynamically. > > > > > > > > > > > > > > If i set the ID of the rte to "item1" how do I reference > > that > > > in my > > > > > > > webservice handler? I have the string pass through so that > > the > > > > > > > handler knows that the ID should be item1. > > > > > > > > > > > > > > I've tried: > > > > > > > RichTextEditor("item1").htmlText = "TEST" > > > > > > > > > > > > > > and > > > > > > > > > > > > > > RichTextEditor(this.getChildByName("item1")).htmlText > > = "TEST" > > > > > > > > > > > > > > but neither work. Any help is greatly appreciated. > > > > > > > > > > > > > > > > > > > > > > > > > > > >

