I am using the onchange function of the Accordion.
Is there any way of knowing which panel was clicked?
(without using isOpen on each panel)
Steven
Printable View
I am using the onchange function of the Accordion.
Is there any way of knowing which panel was clicked?
(without using isOpen on each panel)
Steven
To do what you want, you have to replace the onChange function with an event listener.
If your accordion instance is named acc, add a listener like thisCode:acc.addEventListener('change', myOnChangeHandler);
function myOnChangeHandler(e:MouseEvent):void {
trace (e.relatedObject); // e.relatedObject contains a reference to the panel that was clicked
}
Thanks again. It worked and was very informative.
When I use (e.relatedObject) I get
[object AccordionPanel]
When i use
(e.relatedObject.name) I get
instance51 (or a different number)
I would like to get the actual panel that was clicked..
Your help would be appreciated.
Steven
I don't understand Steven since you already seem to answer your own question.
e.relatedObject should be the panel you clicked :confused:
When i do a trace( e.relatedObject)
I get [object AccordionPanel] on the logviewer.
This is returned no matter what panel was clicked.
What I need to know is what panel the user clicked on and I am not sure how to do it.
Thanks
Steven
The trace is supposed to return that.
What you want can be done in several ways.
1. When you create the panel and assign it to a variable, you can use the variable for comparison like if (e.relatedObject == panel1)
2. You can assign a unique name to your panels after you create them like panel1.name = "MyFirstPanel";
3. You can use a Dictionary object to store information about the panel.