Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-25-2007, 02:23 AM
Member
 
Join Date: Sep 2006
Posts: 38
Default Exchanging Data between FFishScript and FLEX..

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.
Reply With Quote
  #2 (permalink)  
Old 02-26-2007, 01:21 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Exchanging Data between FFishScript and FLEX..

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");
To pass data between flex 2 and ffish script, you can use the ExternalInterface object to call as3 functions in ffish script or call ffish script functions in as3, both synchorously:

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);
ii) calling the methods in ffish script
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"));
Reply With Quote
  #3 (permalink)  
Old 02-26-2007, 01:33 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Exchanging Data between FFishScript and FLEX..

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");
ii) first define a function, then call the function
Code:
function callFS(name)
{
    ExternalInterface.call("ffish_run", name);
}

callFS("myscript");
3. calling ffish script functions from within as3 synchorously
i) first define the function in ffish script ("initialize" script)
Code:
function fsMethod(x, y)
{
***return x + y;
}
ii) calling the ffish script function in as3 by using the ExternalInterface
Code:
ExternalInterface.call("fsMethod", 123, 56.0);
or first define the function in as3:
Code:
function _fsMethod(x, y)
{
    return ExternalInterface.call("fsMethod", x, y);
}
ret = _fsMethod("hello ", "world");
or use the "ffish_eval" command
Code:
ExternalInterface.call("ffish_eval", "fsMethod(123, 56.1);");
Reply With Quote
  #4 (permalink)  
Old 02-26-2007, 07:21 PM
Member
 
Join Date: Sep 2006
Posts: 38
Default Re:Exchanging Data between FFishScript and FLEX..

Thank you SOOOOOO Much.

That's what I needed!

Best Regards,

Steve

Reply With Quote
  #5 (permalink)  
Old 05-25-2007, 02:37 AM
Junior Member
 
Join Date: May 2007
Posts: 1
Default Re:Exchanging Data between FFishScript and FLEX..

Quote:
Originally Posted by stevekellogg
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.
Reply With Quote
  #6 (permalink)  
Old 05-25-2007, 02:59 AM
Member
 
Join Date: Sep 2006
Posts: 38
Default Re:Exchanging Data between FFishScript and FLEX..

You can't.
Reply With Quote
  #7 (permalink)  
Old 06-19-2007, 12:26 PM
Member
 
Join Date: May 2007
Posts: 53
Default Re:Exchanging Data between FFishScript and FLEX..

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);
and type
Code:
Application.registerASMethods("myFunc", "myFunc2");
trace(myFunc("hello ", "world"));
trace(myFunc2("hello ", "world"));
in initialize script.
It prints 'undefined'.
Where the problem can be ?
__________________
#define true false //happy debugging, friends
Reply With Quote
  #8 (permalink)  
Old 06-19-2007, 01:07 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Exchanging Data between FFishScript and FLEX..

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);
Second, in the ffish script code, you cannot call the as functions in the "initialize" script, because at that time (when the "intialize" script is running) the main movie has not been loaded yet, and of course the as functions are undefined. Hence, you can only call them after the as functions have been defined. The following code works well

Code:
Application.registerASMethods("myFunc", "myFunc2");

function testResult() {
trace(myFunc("hello ", "world"));
trace(myFunc2("hello ", "world"));
}

Application.onMovieLoaded = function (movie) {
testResult();
}
Reply With Quote
  #9 (permalink)  
Old 07-26-2010, 10:27 AM
Junior Member
 
Join Date: Mar 2009
Posts: 9
Default

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:
var btn:Btn = new Btn();
btn.100;
btn.100;
addChild(btn);
btn.addEventListener(MouseEvent.CLICKonClick);

function 
onClick(e:MouseEvent) {
    if(
ExternalInterface.available) {
        
ExternalInterface.addCallback("fsMethod"newMethod);
        
ExternalInterface.call("fsMethod"12356.0);
    }
}

function 
newMethod(val:Number) {
    
ExternalInterface.call("showAlert"val);

In SWFKIT
PHP Code:
function fsMethod(xy)
{
Dialogs.msgBox(y);
return 
y;


fsmethod is the method defined in swfkit and newMethod should be called from SWFKIT method after the calculation.


What should I put in SWFKIT?
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:58 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.