Expand my Community achievements bar.

FABridge in a AS file

Avatar

Level 1
I'm sure there is a way to do this, but I can't find it. I
have an action script file that I want to be able to expose some of
the methods in it to Javascript. The actionscript functions in my
<mx:Application are bieng accessed just fine, from the FABridge.
So , if I have an action script file that I need to be able to call
from the FABridge how would I do that? In the following code
example I can set the label in the application all day long,
however I can never seem to be able to call myMethod in
FlexBridgeTest class.



The code I am using is some thing like this.

var flexApp = FABridge.flash.root();

flexApp.myMethod();



Any ideas??



example code.





<mx:Application

xmlns:mx="
http://www.adobe.com/2006/mxml"


xmlns="*" layout="absolute"

backgroundGradientColors="[#CCCCCC,#CCCCCC]"

updateComplete="currentState='zoomedState'"

creationComplete="creationCompleteHandler(event);">



<fab:FABridge xmlns:fab="bridge.*" />



<mx:Script>

<![CDATA[



private var flexTest: FlexBridgeTest = new FlexBridgeTest();

]]>

</mx:Script>





<mx:Label id="lblMyLabel" />







</mx:Application>





package test {



import mx.controls.Alert;

import bridge.FABridge;



public class FlexBridgeTest {



private var faBridge: FABridge = new FABridge();



public function myMethod():void {

Alert.show("Called!");

}

}

}



1 Reply

Avatar

Former Community Member
If you're trying to contact your flexTest variable of your
<mx:Application>

from JavaScript, it would have to be public, no?



Or are you trying to create a pure ActionScript only test
case without using

MXML / Flex?