I have been studying Action Script in the past few days. I found the possibility of interoperability between QT and flash on the Internet. I tried it and succeeded.
First, QT calls functions in flash:
Qaxwidget.swf file code is as follows:
Qaxwidget flash (this, null );
Flash. setcontrol (qstring: fromutf8 ("{d27cdb6e-ae6d-11cf-96b8-444553540000 }"));
Flash. dynamiccall ("loadmovie (long, string)", 0, "E: // first.swf ");
How to call the method in flash, first use the externalinterface. addcall method in flash to add access points for external interaction:
Externalinterface. addcallback ("drawcircleexternal", drawcircle );
Then how to call this function in QT. In my as3 code, drawcircle needs an int-type parameter, so the call code is as follows:
Qstring STR;
Qtextstream (& Str) <""
<""
<"" <""
<""
<"";
Flash. dynamiccall ("callfunction (string)", STR );
Here, returntype must be XML, and the return value of drawcircle cannot be obtained. I don't know why, but this is not very important.
How to call C ++ in as3 is still implemented through the call method in the externalinterface class in as3.
The code for as3 is as follows:
Externalinterface. Call ("calcu", "bbcc ");
Calcu is the external function name and "bbcc" is the parameter.
When this code is executed in as3, qaxwidget generates a signal in the following format:
Flashcall (qstring)
The content of qstring is as follows:
Bbcc
Therefore, to call C ++ through as3 in QT, you must write a slot and associate it with the above signal. The specific code is as follows:
Connect (& flash, signal (flashcall (qstring), this, slot (calcu (const qstring &)));
Put the code to be called into calcu. Of course, the slot name is not necessarily the same as the function name in as3. you can change it at will.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/liurenjie2008/archive/2010/03/29/5430183.aspx