Search code examples
flashvariablesactionscript-2flash-cs5

attachMovie from loadVariablesNum


I am loading a variable at frame 1with loadVariablesNum("text.txt", 0);. The variable is called dayDate and for this is example the value is 09.

I have a movieClip called d09 in my library that I would like to attach to an empty movieClip (instance name: myLoader) via the variable value.

I can load it the "normal" way like this myLoader.attachMovie("d09", "d09", 1);

But how do I get my variable-value into that statement? I've tried putting in the variable name (like myLoader.attachMovie("dayDate", "d09", 1);) but it just won't do what I need


Solution

  • I haven't used AS2 in a while so I'm not sure what those parameters to attachMovie mean. However I believe you'd want to construct the string "d09" like so: "d" + dayDate

    So your code would look something like:

    myLoader.attachMovie("d" + dayDate, "d09", 1);
    

    (Incidentally, by "the value is 09" I'm guessing you mean datDate is the string "09". If you simply mean the number 9 then you'll have to add in the leading 0.)