从Visual Basic的形式传递数据/变量Flash对象 [英] Passing data/variable from a Visual Basic form to a Flash Object

查看:170
本文介绍了从Visual Basic的形式传递数据/变量Flash对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty的肯定,这是可以的地方在这里回答了计算器,但我跳出选项与此有关。

I'm pretty sure that this can be answered somewhere here on stackOverflow but I'm out of options with this.

我有一个的VisualBasic形式,上面有一个按钮对象。我想这个按钮有一个onClick过程,以便点击它传递一个变量或其他命令具有的Shockwave Flash影片运行的另一个窗口。 (例如,有对Flash文件,以显示Flash视频时调用运行一些文本的ActionScript中的功能。)

I have a VisualBasic form with an button object on it. I would like that button to have an onClick procedure so that clicking it passes a variable or other command to another window which has a Shockwave Flash "movie" running. (For example, there is a function on the ActionScript of the Flash file to display some text in the Flash Video running when invoked.)

我在想什么,使这个可能吗?我知道这是一些关于的fscommand ,但不知道如何通过从VB的变量吧。

What am I missing to make this possible? I know it's something about the fscommand but not sure how to pass a variable from VB with it.

推荐答案

做到这一点的方法是使用<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html"相对=nofollow>在AS3 ExternalInterface的类。它允许数据AS3和主机应用程序/容器之间传递(是某个网页或VB窗体等)。

The way to do this is using the ExternalInterface class in AS3. It allows data to be passed between AS3 and the host application/container (be that a webpage or a VB Form etc).

在AS3的一面,你将它设置如下:

In the AS3 side, you set it up as follows:

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);
}

从主机端,您发送/接受她XML 以ActiveX对象。

From the host side, you send/recieve XML to the ActiveX object.

您的XML看起来是这样的:

Your XML looks like this:

<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>


现在,建立在VB中的XML,并调用VB flash对象的 CallFunction 方法,传递XML字符串。


Now, construct that XML in VB, and invoke the CallFunction method of the VB flash object, passing it the xml string.

Dim returnValue As String
returnValue = MyFlashShockWaveObj.CallFunction(xml)

MsgBox(returnValue) 'hello from flash

如果您传递了很多对象,有时最简单的只是JSON.stringify他们并通过只是一个JSON字符串转移到AS3(和/或后)。

If you are passing a lot of objects, sometimes it easiest to just JSON.stringify them and pass just one JSON string over to AS3 (and/or back).

这篇关于从Visual Basic的形式传递数据/变量Flash对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆