Copy link to clipboard
Copied
Hi All, been at this for a while now and can't see the wood for the trees. Is there a way to pass a value through an EventListener so that the array referenced within the function changes value?
var i=int;
btn_US.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler,i=3);
function mouseOverHandler(e:MouseEvent, i):void {
txt_CountryName.text = country;
txt_GoverningBody.text = governingbody;
}
I simply can't see to pass the i value...
Any help would be greatly appreciated.
Mike
From your description it sounds like you are attempting to use one function to work with a bunch of buttons to give you a unique result on each rollover. If that's correct then you may get the result that you want by using an array that contains the instance names of each of the rollover buttons. Then you can use the event target to give you the values from the other two arrays.
Something like this:
var buts:Array = new Array(but1,but2,but3);
var cName:Array = new Array("A","B","C");
var cBody:Array
...Copy link to clipboard
Copied
From your description it sounds like you are attempting to use one function to work with a bunch of buttons to give you a unique result on each rollover. If that's correct then you may get the result that you want by using an array that contains the instance names of each of the rollover buttons. Then you can use the event target to give you the values from the other two arrays.
Something like this:
var buts:Array = new Array(but1,but2,but3);
var cName:Array = new Array("A","B","C");
var cBody:Array = new Array("D","E","F");
for(var i in buts) {
buts.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
}
function mouseOverHandler(e:MouseEvent):void {
var thisOne:int = buts.indexOf(e.target);
txt_CountryName.text = country[thisOne];
txt_GoverningBody.text = governingbody[thisOne];
}
Copy link to clipboard
Copied
Thanks robdillon, this actually streamlined the whole process!
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now