I’ve created a custom MouseEvent in Flex:
package {
import flash.events.MouseEvent;
public class CustomMouseEvent extends MouseEvent {
public var tags:Array = new Array();
public function CustomMouseEvent(type:String, tags:Array) {
super(type, true);
this.tags = tags;
}
}
}
Now I would like to understand how to pass the parameter tags from both Actionscript and MXML:
From actionscript I’m trying something like this, but it doesn’t work:
newTag.addEventListener(MouseEvent.MOUSE_UP, dispatchEvent(new CustomMouseEvent(MouseEvent.MOUSE_UP,[newTag.name])));
From MXML i’m doing this and it doesn’t work as well:
<mx:LinkButton click="dispatchEvent(new CustomMouseEvent(MouseEvent.MOUSE_UP, bookmarksRepeater.currentItem.tags))" />
thanks
Try wrapping the callback code in a function:
I think the issue with the MXML code is that you are using a repeater and trying to get the
currentItemafter the repeating has finished. Try this instead:Hope that helps.
Update
Since you are creating the
newTagobject in a loop, you’ll get better memory usage by just using a named function as the event listener.That way you only create one event listener, rather than
nlisteners that do that exact same thing.