(This tag must be placed inside an <EventHandlers> tag or a <MessageHandlers> tag)
InlineInvoker allows you to call a method without having to instantiate an object (compare with MethodInvoker). You only need to provide a method to call, which can be a method created in the event map (within a Script block), a static method on a class, or method provided by an already created object or singleton.
Any value returned by the function will be available in the lastReturn. See Using lastReturn and Using Smart Objects (lastReturn)
Example:
<InlineInvoker
method="methodToExecute"
arguments="{['argument1', 'argument2']}"/>
Attributes
method
required
The method attribute specifies what function to call. If you had a function called doWork(), you would then write:
<InlineInvoker method="doWork" />
arguments
If the function in your class has arguments, you can pass them via the "arguments" attribute. Suppose your doWork function has the following signature:
public function doWork(name:String, value:Number)
then you can pass those arguments as follows:
<InlineInvoker
method="doWork"
arguments="{['Tom', 36]}"/>
Note that the arguments attribute expects an array. See MethodInvoker (arguments section) for more information.
Calling a static method
With the InlineInvoker tag, you can call static methods. For example, you could call the function random() of the Math library:
<InlineInvoker method="Math.random" />
Remember that any value returned by the function will be available in the lastReturn (Using lastReturn).
Calling a local method
If you have created a method in your event map, you can call it with the InlineInvoker tag:
<mx:Script>
private function myMethod():void {
trace('you called me!');
}
]]>
</mx:Script>
<EventHandlers type="myEventType">
<InlineInvoker method="myMethod" />
</EventHandlers>
Calling a method on a singleton class
Suppose you have a singleton class that contains the method "myMethod" and that you access the singleton instance by the getInstance() method. Then you could call your the method by:
<InlineInvoker method="{MySingleton.getInstance().myMethod}" />
how can i indicate on which object should be invoked?
<code>
<InlineInvoker method="{myObject.myMethod}" />
</code>
To alleviate, instantiate your map after view has loaded (*creationComplete)
private function init(){
var myMap:MainEventMap = new MainEventMap ();
}
We are not able to reproduce that. Please post a more extensive example in the forums. As a general rule, however, you don't add even maps to views...