关于C++扩展ANE,好少资料,就算有也是FB的。。FD这么好用!凭神马。本人从网上找了个亲测可用的。做个教程翻译给大家。。因为废话挺多。我抓重点说。
首先展示下本人的成果。
原帖http://rhuno.com/flashblog/2012/04/30/tutorial-flash-and-c-native-extension/
Last week I decided to look into building a native extension for AIR and was very surprised by the lack of quality resources and tutorials for doing so. I was able to find examples for Android using Java and for iOS using Objective-C, but pretty much nothing for a standard Windows C++ project. I was eventually able to get things up and running by piecing together bits of information from various sources, but I thought I‘d take the time to write a step-by-step tutorial on how to do this so that perhaps others will have an easier time. In this tutorial you will create a native extension that simply adds two numbers together and returns the sum.
I‘ll start with a warning: this tutorial is not for the absolute beginner. You will need the AIR/Flex SDK, Microsoft Visual Studio, familiarity with C++ coding and be comfortable creating packages via the command line. Also, while I‘m comfortable with Flash and ActionScript, I am definitely not an authority on C/C++ so there may be other (better) ways to do some things. Of course, if you happen to be an authority on that stuff, please feel free to suggest improvements! Ok, with the initial disclaimer out of the way, let‘s go ahead and get our hands dirty!
巴拉巴拉,总之就是资料少,你要搞这个必须要熟悉如何用FD。然后作者本人C++比较渣。要是有好的方法请告知。
设置C++项目
To begin, you‘ll need to have Microsoft Visual C++ 2010; and yes, the free Express edition is just fine. Once you‘ve got that installed (and any necessary updates) go ahead and open it up and start a new project. We want to create a Win32 project so select that and give it the name NativeAdd.
开始你要用VC++2010建个Win32项目叫NativeADD。
Select Next and on the following screen, under Application Type, choose DLL (Dynamic-Link Library) and click Finish.
如图选择DLL。
Great! The C++ project has been created! The next step is to make a few changes to the code; open up dllmain.cpp and the top of the file remove the following line:
很好,下面修改代码,打开Dllmain.cpp移除下面的代码。
#include "stdafx.h"
and replace it with this:
然后用下面代码替换
#include <Windows.h>
After that, let‘s go to the DllMain function and remove the entire switch statement so that the only code left in the function is: return TRUE;
The dllmain.cpp file should now look like this:
之后,找到DLLMain函数,移除整个Switch语句。。
The dllmain.cpp file should now look like this:
然后你的DLLmain.cpp就是这样。。(你妹啊。。你直接贴出来结果不行么。。)
#include <Windows.h> BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; }
先翻译这么多。。。后面一大段晚点翻译。。慢慢来~~~心急的可以看原文。。
Using a native extension with Flash Develop is actually a bit of a pain, but it is definitely my preferred IDE, so I‘ll show you how to do this. I got these steps from this video by the AIR Kinect guys, so if you get confused reading this, you can always watch that video instead.
用Flash Develop 的native 扩展蛮痛苦的。但是俺们就是稀饭FD这个IDE。。。所以教教大家怎么做啦。。(挺长的),我从视频上找到的步骤。