To do this, use the ExternalInterface class in AS3. It allows you to transfer data between the AS3 and the host application / container (be it a web page or a VB form, etc.).
On the AS3 side, you set it like this:
function myAS3Function(someNumber:Number, someObject:Object) { //do something with your number and object trace(someObject.isAwesome); return "hello from AS3"; } //register your function with a label VB can call/invoke if (ExternalInterface.available){ ExternalInterface.addCallback("myAS3Function", myAS3Function); }
On the host side, you send / receive XML to an ActiveX object.
Your XML is as follows:
<invoke name="myAS3Function" returntype="xml"> <arguments> <number>5</number> <object> <property id="foo"><string>bar</string></property> <property id="isAwesome"><true/></property> </object> </arguments> </invoke>
Now create this XML in VB and call the CallFunction method of the Flash VB object, passing it the xml string.
Dim returnValue As String returnValue = MyFlashShockWaveObj.CallFunction(xml) MsgBox(returnValue) 'hello from flash
If you transfer a lot of objects, sometimes itβs easiest to just JSON. Build them and pass only one JSON string to AS3 (and / or vice versa).
source share