views:

33

answers:

1

Hi All,

I have a small flex application.

What I want to achieve is, I want my user to pass the script as a parameter. so he has the flexibility to do anything with the buttons->like add event, hide the other buttons.

Something like this(below)

<param name="script" value="import flash.events.Event;\n private function printMessage(event:Event):void {\nmessage.text += event.target.label + " pressed" + "\n";\n}">

Thanks.

A: 

If I understood, what you want is simply create dynamic event and load it to some component, right? If so in did its very easy to implement.

Just create your own custom event (inherit from Event) or use the Event itself:

var event:Event = new Event("[Your event type here"],[bubbles?],[cancelable?]);

and then add listener to your wanted component to the same "event type".

If you need you can also dispatch this event from wanted component programmatically like this:

[you component].dispatchEvent(event);

but then you have to make sure this component extends EventDispatcher class.

Hope I helped.

Royee

FLEXpert
It can also implement iEventDispatcher interface.
Robusto
Guys... I actually want the programmer to create the event and send it as parameter to the flex file, something that would be as good as writing the code within the script tags