Re: [Flashcoders] String to array
That's because the data hasn't loaded yet. Loading external assets is asynchronous, so it takes time for them to load. How long it takes depends on how large the data is and how slow/fast your connection is. To determine when external assets have loaded and are available an event mechanism is your best option. loadVariables and loadVariablesNum don't have such an event mechanism and therefor you should no longer use them (unless you're publishing to Flash 5). With Flash 6 a new class was introduced to handle loading external assets, LoadVars, which has an event mechanism (onLoad/onData). http://livedocs.adobe.com/flash/8/main/2323.html http://livedocs.adobe.com/flash/8/main/2331.html Try the following (not tested): import mx.utils.Delegate; var _lv:LoadVars = new LoadVars(); function loadvarsLoadHandler(success:Boolean):Void { trace("Application ::: loadvarsLoadHandler"); trace("- success: "+success); trace("- myVars: "+ _lv.myVars.split(",")); } this._lv.onLoad = Delegate.create(this, this.loadvarsLoadHandler); this._lv.load("FlashMenuLoader.asp"); // asp return value (note there's no spaces between words, just the comma): &myVars=Corporate,Fund of Funds,Single Manager Funds,Perfomance,Client Services&dummy= regards, Muzak - Original Message - From: "Claudio M. E. Bastos Iorio" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, April 12, 2007 1:04 PM Subject: [Flashcoders] String to array > Sorry for the question, I found some examples on google but I still cannot > figure out what's worng with my code. I hope you guys can help me. > > My original array was: > var mm_array:Array = ["Corporate", "Fund of Funds", "Single Manager Funds", > "Perfomance", "Client Services"]; > > Now I want to load those values from an .asp file. My asp returns a string > like: > mivariable=Corporate, Fund of Funds, Single Manager Funds, Perfomance, > Client Services > > So, Im trying this: > loadVariablesNum("FlashMenuLoader.asp", 0, "GET"); > > var mm_array = mivariable.split(","); > > > But I'm getting an undefined value. What's wrong? > > Thanks in advance. > ___ [EMAIL PROTECTED] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] String to array
Looks like you are not waiting for the data to be loaded into your SWF before you split. Try using LoadVars and wait for the onLoad event, and then do a split. something like: var _lv:LoadVars = new LoadVars(); _lv.load(FlashMenuLoader.asp); var my_array:Array; _lv.onLoad = function () { mm_array = mivariable.split(","); trace(mm_array); } Haven't tested that, but you'll get the basic idea. Hope that helps. -- Arul Prasad http://arulprasad.blogspot.com -- On 4/12/07, Claudio M. E. Bastos Iorio <[EMAIL PROTECTED]> wrote: Sorry for the question, I found some examples on google but I still cannot figure out what's worng with my code. I hope you guys can help me. My original array was: var mm_array:Array = ["Corporate", "Fund of Funds", "Single Manager Funds", "Perfomance", "Client Services"]; Now I want to load those values from an .asp file. My asp returns a string like: mivariable=Corporate, Fund of Funds, Single Manager Funds, Perfomance, Client Services So, Im trying this: loadVariablesNum("FlashMenuLoader.asp", 0, "GET"); var mm_array = mivariable.split(","); But I'm getting an undefined value. What's wrong? Thanks in advance. ___ Claudio M. E. Bastos Iorio http://www.blumer.com.ar ___ [EMAIL PROTECTED] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] String to array
Sorry for the question, I found some examples on google but I still cannot figure out what's worng with my code. I hope you guys can help me. My original array was: var mm_array:Array = ["Corporate", "Fund of Funds", "Single Manager Funds", "Perfomance", "Client Services"]; Now I want to load those values from an .asp file. My asp returns a string like: mivariable=Corporate, Fund of Funds, Single Manager Funds, Perfomance, Client Services So, Im trying this: loadVariablesNum("FlashMenuLoader.asp", 0, "GET"); var mm_array = mivariable.split(","); But I'm getting an undefined value. What's wrong? Thanks in advance. ___ Claudio M. E. Bastos Iorio http://www.blumer.com.ar ___ [EMAIL PROTECTED] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com