Question
how to pass variables inside onRelease = function() ?
Hi all
I am creating MCs through a loop, but I want to assign an onRelease function to each created MC, in
that same loop. And I need to use the variables from the loop into the function...
So I tried this:
for(var sVar in flashVars){
i++;
var mcName = sVar.substr(0,3);
// create the MCs:
duplicateMovieClip(_root.testBut,"medium"+sVar,i);
_root["medium"+sVar].testText.text=sVar;
// assign the function to each created MC:
_root["medium"+sVar].onRelease = function(){
_root[mcName]._x=0;
}
}
The problem is that the variable "mcName" is not passed into the function. How do I solve this?
--
seb ( ---@webtrans1.com)
http://webtrans1.com | high-end web design
An Ingenious WebSite Builder: http://sitelander.com
I am creating MCs through a loop, but I want to assign an onRelease function to each created MC, in
that same loop. And I need to use the variables from the loop into the function...
So I tried this:
for(var sVar in flashVars){
i++;
var mcName = sVar.substr(0,3);
// create the MCs:
duplicateMovieClip(_root.testBut,"medium"+sVar,i);
_root["medium"+sVar].testText.text=sVar;
// assign the function to each created MC:
_root["medium"+sVar].onRelease = function(){
_root[mcName]._x=0;
}
}
The problem is that the variable "mcName" is not passed into the function. How do I solve this?
--
seb ( ---@webtrans1.com)
http://webtrans1.com | high-end web design
An Ingenious WebSite Builder: http://sitelander.com
