Hey Guys, I have one string variable that change when I push a button. Now usually when I add an eventlisenter to a movieclip I do this:
movieclipname.addEventListener();
But now the variable is holding the name of the Mc to which to listener should be added. I tried this:
variablename.addEventListener();
-Tim
now I have:
var var1:String = "mc1"
var var2:String = "mc2"
this[var1][var2].price.text =.....
But it still gives me the same error.
TypeError: Error #1010: A term is undefined and has no properties.
at Function/ruse_fla:MainTimeline/onBtnCClick/ruse_fla:completeConfigura tion()[ruse_fla.MainTimeline::frame1:114]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
-Tim
I see you want to have "values" changed dynamicaly with only a few lines of code. That's always the goal.
But I was wondering if you thought of using the MovieClip's main caracteristic, which is being a dynamic class. I do not see your whole code, but maybe you could think about storing the actual Textfields or movieclips as the buttons' properties. Inside your MouseEvent function, you could target them, (maybe) more easily.
____________________
Design Cyboïde
In general, "this" is a reference to the current timeline.
trace(this[var1]; [undefined]
Aside from a typo in the code, the [undefined] is indicating you have an issue with the object you are trying to target It doesn't exist. You need to be sure you've named "mc1" by that name and that it is present when that code executes.
Yep, you need to have some kind of targeting lead-in for the bracket notation to work, and "this" is usually a workable option.
When you use trace([var1]) you are merely tracing the elements of an array you just created when you used [var1] alone.
The problem you seem to have is that you do not have an object on the stage when that code executes that has the instance name "mc1" assigned to it.
If you replace
this[var1][var2].price.text;
with
mc1.mc2.price.text;
you'll probably still be getting the error, though it might turn into a 1009 error. If so, that's indicating for certain that there is no object named mc1 around where that code is.
North America
Europe, Middle East and Africa
Asia Pacific