|
|||
|
Hello,
I've read over all of the manual, but I need help with something. I'm working in Flex 2.01. I'm trying to get access to variables defined in Flex using the "FlashPlayer.getVariable" and "FlashPlayer.setVariable" methods. The PROBLEM is that I don't know how to correctly format the NAME of the variable that I want to get. I've tried everything obvious I can think of : FlashPlayer.getVariable("root.myVariableName"); FlashPlayer.getVariable("_root.myVariableName"); FlashPlayer.getVariable("myApplicationName.myVaria bleName"); FlashPlayer.getVariable("_myApplicationName.myVari ableName"); etc... Can anyone here help me out? Thanks in Advance. |
|
|||
|
Although you can use the getVariable method to get properties of the Application object (or any components in the Application container), such as _x, _y, _width, _height, it cannot return the value of a variable defined in the Application container. The name of the Application container is the name of your project plus 0. For example, if your project is "myTest", then the name of the Application container is "myTest0", and you can get its properties in ffish script like
Code:
var x = FlashPlayer.getVariable("_level0.myTest0._x");
1. calling as3 function from within ffish script i) in as 3 define and register a function Code:
*********function myFunc(x, y)
*********{
************return x + y;
*********}
*********
*********function myMethod(x, y)
*********{
************return x + y + y;
*********}
************ExternalInterface.addCallback("myFunc", myFunc);
************ExternalInterface.addCallback("myFunc2", myMethod);
Code:
// 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"));
|
|
|||
|
2. calling ffish scripts from within as3 synchorously
i) you can call it directly by using the ExternalInterface object Code:
ExternalInterface.call("ffish_run", "myscript");
Code:
function callFS(name)
{
ExternalInterface.call("ffish_run", name);
}
callFS("myscript");
i) first define the function in ffish script ("initialize" script) Code:
function fsMethod(x, y)
{
***return x + y;
}
Code:
ExternalInterface.call("fsMethod", 123, 56.0);
Code:
function _fsMethod(x, y)
{
return ExternalInterface.call("fsMethod", x, y);
}
ret = _fsMethod("hello ", "world");
Code:
ExternalInterface.call("ffish_eval", "fsMethod(123, 56.1);");
|
|
|||
|
Quote:
|
|
|||
|
i type in as1/as2
Code:
function myFunc(x, y) {return x + y; }
function myMethod(x, y) { return x + y + y; }
ExternalInterface.addCallback("myFunc", myFunc);
ExternalInterface.addCallback("myFunc2", myMethod);
Code:
Application.registerASMethods("myFunc", "myFunc2");
trace(myFunc("hello ", "world"));
trace(myFunc2("hello ", "world"));
It prints 'undefined'. Where the problem can be ?
__________________
#define true false //happy debugging, friends |
|
|||
|
There are two problems in your code.
First, in the as2 code, the parameters for the "addCallback" method are incorrect. Your code works in as3, but in as2 the method has three parameters. Therefore in as2 your code should be Code:
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);
Code:
Application.registerASMethods("myFunc", "myFunc2");
function testResult() {
trace(myFunc("hello ", "world"));
trace(myFunc2("hello ", "world"));
}
Application.onMovieLoaded = function (movie) {
testResult();
}
|
|
|||
|
Hi,
I am struggling to make an application work. I have to send some values to SWFKIT from SWF and do some calculations then retrieve the values back in SWF. SWF is created in AS3. Any sample available for this? Inside SWF PHP Code:
PHP Code:
fsmethod is the method defined in swfkit and newMethod should be called from SWFKIT method after the calculation. What should I put in SWFKIT? |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|