Let me start off like most AS3 noobies and say sorry for the following question that might seem trivial.
I have a 3 word phrase that needs to be in my flash movie, and it needs to be localized. I'm using an external AS file for all my code. Figured I would just make a flash var and pass our string value in that way. So I made a dynamic text field, gave it an instance name of "mytextfield" which is in a MC called "detail_mc".
Just for kicks I tested my code on the stage just on a keyframe, this was the code:
if (mytext == undefined) myText = "No Value Entered";
mytextfield.text = myText;
That worked for my test. So I took this over to my AS file and there is just no magic happening. I'm not exactly sure whats the problem but hoping its a simple fix. I've been looking for a few hours but nothing has helped
Any help would be very much appreciated. Thank you in advance for any replies.
Heres some answers to questions that might better explain my problem:
1. Are you getting compiler or runtime errors? If so, what are they?
2. If you're not getting errors, are you creating the TextField instance in code? If yes, has it (or its parent MovieClip) been added to the stage?
I have created the MC on the stage with the TextField nested inside of it. The MC name is detail_mc (no instance name) and the dynamic text field has an instance name of myTextField.
3. What is triggering your updates to the textfield's text property (how do you assign the value you want)? Do you have change listeners on some input textfields or is it in an enterFrame listener for example?
I want to update the text field with a flash var. So when I embed the SWF I can pass my translated string.
Yeah, that's definitely AS2. But, it's typed and fairly sensibly written. The conversion to AS3 shouldn't be too hard. The main parts are that loadMovie needs to actually be a Loader, the onWhatever property functions need to use addEventListener instead, and getURL needs to be navigateToURL.
I see textfield declared (as a String), but I don't see it used anywhere. For that matter, I don't see any flashvar stuff either. As I said above, flashvars are handled differently in AS3. In AS2, they simply overwrote whatever root level variable was already there with that name. In AS3, they go into an Object called parameters which is on the LoaderInfo object associated with the root. To get the value specified by the flashvar myTextValue, you'd do this:
var myTextValue:String = root.loaderInfo.parameters.myTextValue;