Link to home
Start Free TrialLog in
Avatar of clickclickbang
clickclickbang

asked on

Pass Var To onPress Event

Experts - I am looping through an array of movie clip names in actionscript 2.0 and need to figure out a way to pass a var to the onPress function. I'm dealing with a scope issue, but am not sure how to fix it.

I have the following code on the first frame of my timeline. The issue is, when the onPress event is fired, counties[i] is undefined. Is there a way I can pass the array variable into the onPress event function without loosing scope?

Thank you for your help!

~ C
counties = testVar1.split(',');
 
for (var i = 0; i < counties.length; i++)
{
	var o = eval(counties[i]);
	o.stop();
	o._alpha = 70;
	
	o.onPress = function()
	{
		getURL("#" + counties[i]);
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of clickclickbang
clickclickbang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial