A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Accordion onChange

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    37

    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

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    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
    }

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    37
    Thanks again. It worked and was very informative.

  4. #4
    Member
    Join Date
    Jul 2009
    Posts
    37
    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

  5. #5
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I don't understand Steven since you already seem to answer your own question.
    e.relatedObject should be the panel you clicked

  6. #6
    Member
    Join Date
    Jul 2009
    Posts
    37
    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

  7. #7
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center