flash actionscript:
hello, I have a one frame movie with the attached code in the actions layer. I have a notepad file named "info.txt" in the same folder as my .swf is published. what is wrong. I can't get it to work. help... sky var myInfo:LoadVars = new LoadVars(); myInfo.load("info.txt"); myInfo.onLoad=function (success) { trace("in if"); if(success){ whyUs=myInfo.whyUs; } }; infoText_txt.text=whyUs;
You need to place this line of code; infoText_txt.text=whyUs;
thanks, I figured that out.... I think my other problem is don't you need to have an button to call it. say in my first post it should be... theBtn_mc.onRelease() = function{ infoText_txt.text = whyUs; }; instead of just using infoText_txt.text = whyUs; won't work.
Yeah, you can also nest that line of code in a button event handler as you mentioned. Notice the onLoad and onRelease functions are indeed ?event? handlers. Events are what trigger things to happen. Also you are correct that this line directly after the onLoad function will not work. It?s because Flash will read that line before the event (info.txt loads). I guess an analogy that comes to my mind is? Suppose you are ready to open a wrapped gift and someone ask you what is in it. So to analyze that; ?Suppose you (pretend ?you? are Flash) are ready to open a wrapped gift (load info.txt file) and someone (infoText_txt.text) ask you what is in it (the variable, ?whyUs?). You will only know what is inside of the gift after, you have opened (in this example, ?load it?) it.
thanks for the explanation. I think I understand better now. again thanks,
Don't see what you're looking for? Try a search.
|