Class fever.commands.JSCommand

Implemented Interfaces

Command

Description

Defines and registers javascript command.

Allow runtime js method creation and call using the ExternalInterface feature.
If ExternalInterface.available is false commands are not executed.

2 ways to use :

All commands are registred in the JSLocator to easily retreives them using their JSMethodName

As we want to control and keep the method name, we don't have to define the function name in javascript code.
Example of JSCommand instanciation.

   var name : JSMethodName = new JSMethodName( "setTitle" );
   var command : JSCommand = new JSCommand( 
   	name, 
   	"( newtitle ){\tdocument.title = newtitle; }" 
   );
   
   //result or param to pass 
   command.call( "newTitle" );
 

The function "name_function" is automatically added during registration process.

Another way is to use the JSLocator

   var name : JSMethodName = new JSMethodName( "setTitle" );
   var b : Boolean = JSLocator.register( 
   	name, 
   	"( newtitle ){\tdocument.title = newtitle; }" 
   );
   
   if( b ) JSLocator.getCommand( name ).call( "newtitle" );
 

See Also

Method Index

new JSCommand()
call(), execute(), getName(), toString()

Constructor Detail

JSCommand

public function JSCommand(methodName:JSMethodName, fCode:String)

Constructor.

Method Detail

execute

public function execute(e:IEvent):Void

Execute js command.

Pixlib Command polymorphism. s

You can override method to retreive e event parameter.

call

public function call()

Calls js command and returns possible result.

You can pass every arguments you want.

getName

public function getName():String

Returns the js function name used for registration.

toString

public function toString():String

Returns string representation.