|
-
Accordion onChange
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 this
Code:
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
Last edited by shx; 03-07-2010 at 03:02 AM.
Reason: clarify
-
I don't understand Steven since you already seem to answer your own question.
e.relatedObject should be the panel you clicked
-
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|