next up previous contents
Next: Remarks Up: Using FFish script objects Previous: Calling methods written in   Contents

Calling actionscript methods from within ffish script

First, you must define the methods in actionscript and export them. For example, in actionscript 2 (Flash 8)
function myFunc(x, y)
{
    return x + y;
}

function myMethod(x, y)
{
    return x + y + y;
}

ExternalInterface.addCallback("myFunc", null, myFunc);
ExternalInterface.addCallback("myFunc2", null, myMethod);

in actionscript 3 (Flash cs3 or Flex 2)

function myFunc(x, y) {
    return x + y;
}

function myMethod(x, y) {
    return x + y + y;
}

ExternalInterface.addCallback("myFunc", myFunc);
ExternalInterface.addCallback("myFunc2", myMethod);

And then you can register the methods in ffish script and call them

// The "registerASMethods" method turns any as2 or as3
// callback functions into ffish script global functions. That is to say,
// you can call the action script functions directly in ffish script
// after calling this method
Application.registerASMethods("myFunc", "myFunc2");
trace(myFunc("hello ", "world"));
trace(myFunc2("hello ", "world"));



Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.