Hi Everyone,
I am presently trying to pass a string value into a custom function, that is itself called from within an event method.
At the moment I have attached an event to a symbol instance (called product1) with the following code:
Code:
product1.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
The above code succesfully calls the following custom function:
Code:
function onClick(evt:MouseEvent):void{
navigateToURL(requestURL, "_self");
}
This is only useful for calling 1, distinct, URL and I want to be able to pass a String value into the function onClick() which can represent one of several URLs depending upon which one of several symbols has been clicked.
As a result I will be attaching event listeners to several symbols instances, e.g.:
Code:
product1.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product2.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product3.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product4.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product5.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product6.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
product7.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
And I want my custom function to navigate to a URL based upon which symbol instance has been clicked.
I have tried the following:
Code:
product1.addEventListener(MouseEvent.MOUSE_DOWN, onClick(product1URL));
function onClick(requestURL:String):void{
navigateToURL(requestURL, "_self");
}
Can somebody please help me with passing both the mouse event, and a String value to my custom function? I have been unable to find examples of what I am attempting to do on the internet.
Any help will be greatly appreciated.
Kind Regards,
David