打印

[AS3] flash 9 在Vc通信的问题

flash8的时候我用如下办法,但是flash cs3怎么通信呢??
fscommand(command,arguments);工作正常!
SetVariable( , )和GetVariable(,)怎么用?


Flash 里面调用fscommand(command,arguments);
复制内容到剪贴板
代码:
_root.s="";
fscommand("start","");
fscommand("quit","");
Vc++2005代码其中定义
CShockwaveflash myflash;
复制内容到剪贴板
代码:
void CmyDlg::FSCommandShockwaveflash(LPCTSTR command, LPCTSTR args)
{
    // TODO: 在此处添加消息处理程序代码
    if(   0 == _tcscmp(command,_T("start")))   
    {
        MessageBox(_T("您选择了启动!"));
        myflash.SetVariable(_T("_root.s"),_T("123"));
        CString    s3=myflash.GetVariable(_T("_root.s"));
        MessageBox(s3);
    }else if(command==_T("quit") )
    {
        MessageBox(_T("您选择了退出!"));
        //CDialog::OnCancel();
    }
}
用下面的办法测试
myflash.SetVariable(_T("s"),_T("123"));
myflash.GetVariable(_T("s"));//s="123"
这个设置成功但是值到那里去了,我在flash9里面怎么读不出来;我要读去值怎么读不出来;
望高手指点一下!
我从Flash CS3 HELP里找来的...[ 进入FLASH CS3 IDE 然后按F1键打开 HELP ]
那两个例子都写在里面
章节路径分别是:

Programming ActionScript 3.0 > Using the external API > Example: Using the external API with a web page container  

Programming ActionScript 3.0 > Using the external API > Example: Using the external API with an ActiveX container  

例子很好理解...各文件也都有说明.因为章节太长.我就不贴了。 ..不过我还是贴了ExteranlAPI的基础说明....

说明如下.
____________________________________________________[摘抄 FlashCS3 Help 章节]________
Programming ActionScript 3.0   [ Chapter:章节名 as3编程 ]
  
Using the external API > Basics of using the external API [ Path:该章小节名: 使用扩展API > 使用扩展API基础]

Common external API tasks[扩展API基础任务]
The following common external API tasks are explained in this chapter:


  • Getting information about the container application
  • Using ActionScript to call code in a container application, including a web page or desktop application
  • Calling ActionScript code from code in a container application
  • Creating a proxy to simplify calling ActionScript code from a container application


Important concepts and terms[概念及重点]
The following reference list contains important terms used in this chapter:


  • ActiveX container: A container application (not a web browser) that includes an instance of the Flash Player ActiveX control to display SWF content within the application.
  • Container application: The application within which Flash Player is running a SWF file, such as a web browser and HTML page that includes Flash Player content.
  • Projector: A SWF file that has been converted into a standalone executable file including Flash Player as well as the SWF file's content. A projector can be created in Adobe Flash CS3 Professional or using the standalone Flash Player. Projectors are commonly used to distribute SWF files by CD-ROM or in similar situations where download size is not an issue and the SWF author wants to be certain the user will be able to run the SWF file, regardless of whether Flash Player is installed on the user's computer.
  • Proxy: A go-between application or code that calls code in one application (the "external application") on behalf of another application (the "calling application"), and returns values to the calling application. A proxy can be used for various reasons, including:

    • To simplify the process of making external function calls by converting native function calls in the calling application into the format understood by the external application
    • To work around security or other restrictions that prevent the caller from communicating directly with the external application

  • Serialize: To convert objects or data values into a format that can be used to pass the values in messages between two programming systems, such as over the Internet or between two different applications running on a single computer.


Working through in-chapter examples[例子]
While you're working through this chapter, you might want to test the example code listings. Many of the code listings in the chapter are small listings of code for demonstration purposes rather than full working examples or code that checks values. Because using the external API requires (by definition) writing ActionScript code as well as code in a container application, testing the examples involves creating a container (for example, a web page containing the SWF) and using the code listings to interact with the container.

To test an example of ActionScript-to-JavaScript communication:

  • Create a new Flash document and save it to your computer.
  • From the main menu, choose File > Publish Settings.
  • In the Publish Settings dialog box, on the Formats tab, confirm that the Flash and HTML check boxes are selected.
  • Click the Publish button. This generates a SWF file and HTML file in the same folder and with the same name that you used to save the Flash document. Click OK to close the Publish Settings dialog box.
  • Deselect the HTML check box. Now that the HTML page is generated, you are going to modify it to add the appropriate JavaScript code. Deselecting the HTML check box ensures that after you modify the HTML page, Flash will not overwrite your changes with a new HTML page when it's publishing the SWF file.
  • Click OK to close the Publish Settings dialog box.
  • With an HTML or text editor application, open the HTML file that was created by Flash when you published the SWF. In the HTML source code, add a script element and copy into it the JavaScript code from the example code listing.
  • Save the HTML file and return to Flash.
  • Select the keyframe on Frame 1 of the Timeline, and open the Actions panel.
  • Copy the ActionScript code listing into the Script pane.
  • From the main menu, choose File > Publish to update the SWF file with the changes that you've made.
  • Using a web browser, open the HTML page you edited to view the page and test communication between ActionScript and the HTML page.

To test an example of ActionScript-to-ActiveX container communication:

  • Create a new Flash document and save it to your computer. You may want to save it in the folder where your container application will expect to find the SWF file.
  • From the main menu, choose File > Publish Settings.
  • In the Publish Settings dialog box, on the Formats tab, confirm that only the Flash check box is selected.
  • In the File field next to the Flash check box, click the folder icon to select the folder into which your SWF file will be published. By setting the location for your SWF file, you can (for example) keep the Flash document in one folder, but put the published SWF file in another folder such as the folder containing the source code for the container application.
  • Select the keyframe on Frame 1 of the Timeline, and open the Actions panel.
  • Copy the ActionScript code for the example into the Script pane.
  • From the main menu, choose File > Publish to re-publish the SWF file.

Create and run your container application to test communication between ActionScript and the container application.
The two examples at the end of this chapter are full examples of using the external API to communicate with an HTML page and a C# desktop application, respectively. Those examples include the full code, including ActionScript and container error-checking code, which you should use when writing code using the external API. For another full example using the external API, see the class example for the ExternalInterface class in the ActionScript 3.0 Language and Components Reference.
占时还没找到方法!
只有自己再研究罗!
2stzone.cn
读取时间不对
生命在于折腾

请大家帮忙解决下面这个头疼问题
www.blueidea.com/bbs/NewsDetail.asp?lp=1&id=2553176

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
我遇到的问题和楼主差不多,
是VC如何控制flash,
例如flash里没有右键控制,于是我在VC里捕捉到右键消息,然后传给as3,让他响应
但问题是用as2做的一切正常,用as3做的就不行
这个问题一直没解决....

但我可以告诉你个曲线救国的办法,拖两个CShockwaveflash 控件到程序里,
一个调用as2的,一个调用as3的,再通过as2的localconnection与as3通信

TOP

引用:
原帖由 shilong 于 2007-12-7 10:38 发表
但我可以告诉你个曲线救国的办法,拖两个CShockwaveflash 控件到程序里,
一个调用as2的,一个调用as3的,再通过as2的localconnection与as3通信
这个方法的确可行! 不过比较麻烦呵呵
2stzone.cn

TOP

其实我是在用flash做Vc的界面,用Vc来写底层的与硬件连接,用flash8的已经搞定了!
只是试试用flash9怎么用!麻烦的话就算了!
2stzone.cn

TOP

与外部ActiveX容器通信还是用ExternalInterface类吧。
看官方示例。

http://livedocs.adobe.com/flash/ ... ;file=00000346.html

TOP