3/7/2010 9:07:29 AM
Title:
How to use vb script in Flex ?
Can we call or insert the VB script using flex?
If possible, could you plz give me one example
Thanks advance
3/7/2010 9:35:46 AM
you can use externalInterface class to expose functions from flex. see code below for flex . The exposed function is accessible from vbscript or javascript in html page.
<mx:Script>
import flash.external.*;
public function myExposedFunc():String {
return "I am accessible from flex";
}
public function initApp():void {
ExternalInterface.addCallback("myFlexFunction",myExposedFunc);
}
</mx:Script>
I dont know how to write vbscript but flex function can be accessed the same way as we do from javascript . Javascript code is below
<SCRIPT language='JavaScript' charset='utf-8'>
function callFlexApp() {
var myText = MyFlexApplication.myFlexFunction();
alert(myText);
}
</SCRIPT>
Inder
Points: 2480
Posts:0
3/7/2010 11:27:23 AM
Hey FlexFlash,
To call a vbscript function from flex use this vbscript code in html body tag
<script language="vbscript" type="text/vbscript" >
Function vbFunction()
MsgBox "function called from flash"
End Function
</script>
Now you can call "vbFunction()" from flex using "ExternalInterface.call("vbFunction");"
below is sample code for flex mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768" applicationComplete="callExtFun()">
<mx:Script>
<![CDATA[
private function callExtFun():void{
ExternalInterface.call("vbFunction");
}
]]>
</mx:Script>
</mx:Application>