This content has been marked as final. Show 5 replies
Try removing the ‘_root’ from the mcName variable. So this line of code;
…would be like this;
But if you are looking to retrieving the instance name you can also use this;
…in the onRelease function.
or perhaps more ideal;
> or perhaps more ideal;
> for(var sVar in flashVars)
> //var mcName = sVar.substr(0,3);
> // create the MCs:
> _root["medium"+sVar].mcName = sVar.substr(0,3);
> // assign the function to each created MC:
> _root["medium"+sVar].onRelease = function()
thanks but this does not work.
I think that the problem is that the variables defined in the for loop do not exist in the scope of
when the MC is clicked, and the onRelease function says:
the variable "mcName" is empty.
seb ( ---@webtrans1.com)
http://webtrans1.com | high-end web design
An Ingenious WebSite Builder: http://sitelander.com
In my last post mcName is a property of the new movieclip which it will output its value when the user clicks on that instance. There are 2 things that I notice that may be causing your code not to behavior as desired; one, is that I see no value for ‘i’. And the second is that sVar is returning a Number not a string. So you need to use [ ] to access the element in the flashVars. Also I am assuming flashVars is an Array, if not I am not sure how you are planning to retrieve info with the code you provided.
Below is updated code, and I am able to retrieve the variable mcName when I click on its movieclip. I hope that helps.
My mistake. When using a for-in loop to access an array the var (in this case sVar) is always a String. However it can return a number or a string value depending on what its looping thru. So if flashVars is an Object then you don’t need to use the square bracket unless you need to access the value of that property. Which is where I am confused on what it is you want.