C++与Flash的交互
2015-04-02 10:06
218 查看
原文链接:http://blog.csdn.net/xoyojank/article/details/3122679
研究Flash嵌入游戏中的可行性.......
渲染问题已解决
事件响应已解决
下面是C++与Flash AS的交互, 以MFC为例:
1. 新建一个MFC Dialog程序
2. 添加一个Flash控件
3. 把Flash控件添加一个变量
4. 在OnInitDialog()中添加载.swf文件
[cpp] view
plaincopy
// CCppFlashDlg 消息处理程序
BOOL CCppFlashDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
this->flashUI.LoadMovie(0, "C://Documents and Settings//Administrator//My Documents//My Flash//HelloWorld.swf");
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
5. 制作一个flash, 放一个Button上去, 导出一下就可以在MFC中看到了
6. flash调用C++.
这个很简单, 在flash的那个Button组件的动作中添加脚本:
[javascript] view
plaincopy
on(click)
{
fscommand("MsgBox", "这是flash调用c++的响应");
}
然后在MFC中添加事件响应:
[cpp] view
plaincopy
void CCppFlashDlg::FSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
{
// TODO: Add your message handler code here
if (0 == strcmp("MsgBox", command))
{
MessageBox(args);
}
}
7. C++调用Flash.
首先在Flash中注册回调函数:
[javascript] view
plaincopy
import mx.controls.Alert;
import flash.external.*;
ExternalInterface.addCallback("MsgBox", this, MsgBox);
function MsgBox(msg:String)
{
Alert.show(msg, "",Alert.OK);
}
然后在C++中添加调用:
[cpp] view
plaincopy
void CCppFlashDlg::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
this->flashUI.CallFunction("/
<invoke name=/"MsgBox/">/
<arguments>/
<string>这是C++调用flash的响应</string>/
</arguments>/
</invoke>");
}
另外, 还可以通过GetVariable()和SetVariable()来设置flash中定义的变量
8. 导出一下flash, 编译一下C++, 就可以看到效果了:
研究Flash嵌入游戏中的可行性.......
渲染问题已解决
事件响应已解决
下面是C++与Flash AS的交互, 以MFC为例:
1. 新建一个MFC Dialog程序
2. 添加一个Flash控件
3. 把Flash控件添加一个变量
4. 在OnInitDialog()中添加载.swf文件
[cpp] view
plaincopy
// CCppFlashDlg 消息处理程序
BOOL CCppFlashDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
this->flashUI.LoadMovie(0, "C://Documents and Settings//Administrator//My Documents//My Flash//HelloWorld.swf");
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
5. 制作一个flash, 放一个Button上去, 导出一下就可以在MFC中看到了
6. flash调用C++.
这个很简单, 在flash的那个Button组件的动作中添加脚本:
[javascript] view
plaincopy
on(click)
{
fscommand("MsgBox", "这是flash调用c++的响应");
}
然后在MFC中添加事件响应:
[cpp] view
plaincopy
void CCppFlashDlg::FSCommandShockwaveflash1(LPCTSTR command, LPCTSTR args)
{
// TODO: Add your message handler code here
if (0 == strcmp("MsgBox", command))
{
MessageBox(args);
}
}
7. C++调用Flash.
首先在Flash中注册回调函数:
[javascript] view
plaincopy
import mx.controls.Alert;
import flash.external.*;
ExternalInterface.addCallback("MsgBox", this, MsgBox);
function MsgBox(msg:String)
{
Alert.show(msg, "",Alert.OK);
}
然后在C++中添加调用:
[cpp] view
plaincopy
void CCppFlashDlg::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
this->flashUI.CallFunction("/
<invoke name=/"MsgBox/">/
<arguments>/
<string>这是C++调用flash的响应</string>/
</arguments>/
</invoke>");
}
另外, 还可以通过GetVariable()和SetVariable()来设置flash中定义的变量
8. 导出一下flash, 编译一下C++, 就可以看到效果了:
相关文章推荐
- [导入]C++与Flash的交互
- 通过Flash和c++的交互来实现自己的桌面游戏
- 通过Flash和c++的交互来实现自己的桌面游戏
- C++与Flash的交互
- C++ 实现flash动画播放——Flash和c++的交互
- C++与Flash的交互
- C++与Flash的交互
- C++与Flash的交互
- (zt)Flash与C++交互
- C++与Flash的交互
- C++ 与 Flash 交互 (策略请求文件问题)
- C++与Flash的交互
- C++与Flash的交互
- C++与Flash的交互
- Flash与C++的交互
- C++与Flash的交互
- C++与Flash交互
- C++与FLASH交互及视频帧保存方案
- 有人机交互能力的排列组合算法(C++版)
- Flash与JavaScript信息交互