Now that I look at it, it's more an architecture issue than a custom event issue.

Your drop down component should listen to the items inside it for when they are selected, and your drop down component should fire a change event when it changes.

item.addEventListener(SELECT, onItemSelect);

private function onItemSelect(event:Event):void
{
   if (event.target != selectedItem)
   {
       selectedItem = DropDownItem(event.target);
       dispatchEvent(new Event(CHANGE));
   }
}

You don't have to pass values in the events now if you don't want. You can reference event.target and access any of its public variables or functions. So, on the CHANGE event, you would say

DropDown(event.target).selectedItem.name

or something along those lines.

Helmut Granda wrote:
I am having a little bit of issue wrapping my head about this easy task.  I
think my brain is fried.

I have created a dropdown component... now when the user selects an element
from the dropdown i can listen for the MOUSE_UP and call a method, that
method dispatches a custom event.

Now I am assigning the name of each one of the elements of the drop down so
that I can pass that along to the method that dispatches the custom event,
but I also want to add an extra parameter but I dont seem to be able to
figure out how since I am creating all the elements at the same time that
adding the MOUSE_UP listeners...


something like

var holder:Sprite = new Sprite;
holder.name = "theName";
...morecode

holder.addEventListener(MouseEvent.MOUSE_UP, myEvent);


private function myEvent(e:MouseEvent) {
trace(e.target.name);
// How about being able to pass an extra parameter?
//From here I am able to dispatch a custom event like so:
dispatchEvent(new DropDownEvent (SELECTED, e.target.name));
//but I need to pass an extra item like so
dispatchEvent(new DropDownEvent (SELECTED, e.target.name, secondParam));
}

TIA
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to