Do not see str in the code? Perhaps you mean testFromFile?
_root.dbox.text = ":: " + textFromFile ;
You would want the above line to be inside the onLoad method or in a
function called by the onLoad method.
Also realize with anonomous function assignments the do occur at run time
and not a compile time. Thus you do want to have the onLoad assignment
before the load method. Because the load method is dependent on network
traffic, often the timing allows the order you have, but often in testing
the speed is such load completes before the onLoad line is reached and thus
load did not know about the callback function. Overall you do not want code
where there is an outside chance that the load method would complete before
the assignment line for onLoad. In summary you want to execute function
assignments before they could be used.
--
Lon Hosford
www.lonhosford.com Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com May many happy bits flow your way!
[quoted text, click to view] "thephatp" <webforumsuser@macromedia.com> wrote in message
news:e9ed6g$sdm$1@forums.macromedia.com...
> Hi Lon,
>
> I'm having a similar problem, and I've already declared the variables
> outside
> of the scope. I'm not sure how scoping works in Flash (but I do in
> general, as
> I'm a software developer), but this doesn't seem to be doing what is
> expected.
> Here is a very shortened version of what I'm tring to do:
>
> var myLoadableData = new LoadVars() ;
> myLoadableData.load( myFile ) ;
>
> var textFromFile:String ;
>
> myLoadableData.onLoad = function( success )
> {
> if( success )
> {
> textFromFile = myLoadableData.songVar ;
> }
> }
>
> _root.dbox.text = ":: " + textFromFile ;
>
>
> At this point, str is null / undefined. Any ideas?
>
> [q][i]Originally posted by: [b][b]Newsgroup User[/b][/b][/i]
> Declare variable outside the onLoad method. Ex:
> var xnRoot:XMLNode;
> var xnHelpText:XMLNode;
> then use them inside onLoad. ex:
> xnRoot= new XMLNode(3, this.firstChild);
> xnHelpText = new XMLNode(3, this.firstChild.firstChild);
>
> As well you can use the courseXML variable outside the onLoad
> var xnRoot:XMLNode = new XMLNode(3, courseXML.firstChild);
> In this case you call another function to use it or move to another frame.
>
> [/q]
>
>
>
> var myLoadableData = new LoadVars() ;
> myLoadableData.load( myFile ) ;
>
> var textFromFile:String ;
>
> myLoadableData.onLoad = function( success )
> {
> if( success )
> {
> textFromFile = myLoadableData.songVar ;
> }
> }
>