Flex -- C++ connection?
How do I connect a Flex Application( Intern开发者_如何学Cet Site ) and C++ togehter ?
a minimalistic example from what i mean (User Story): Frank goes to www.myflexsite.de there are 2 textboxes and 1 Button( Label = add two numbers) . He inserts 2 in the first textbox and 5 in the ohter. Now he clicks on the add button.
The Backend : We have a add.cpp file where an add method is defined :
int add(int a, int b ) ...
After Frank clicked on the "add two numbers" Button the add-method in the C++ file is called and the result will be returned.An Alert Window with the result appears.
This is what i want to accomplish, but i don't know how i build the bridge between these 2 Languages. How can they communicate ?
The easiest would be to write a small console application in C++ and then invoke it via Apache or any other web server using CGI. There are performance problems with this but it's a good start, and then you can move forward. From Flex just make HTTP requests and let your program parse them - for instance, you can send XML back and forth.
I don't think this is necessarily the intent, but depending on what you want to accomplish you may want to take a look at the Alchemy project - http://labs.adobe.com/technologies/alchemy/ you can use it to compile C++ code down into code that runs on the Flash Player.
This won't help you communicate between a client and a server, but if there is code you don't want to have to completely rewrite that might be more helpful exposed directly in Flash, this could be a solution.
=Ryan ryan@adobe.com
I was going to write a 'Restful' example, but a quick Bing search finds this guy has already done it:
Yahoo! Image Search REST API - Flex example
Just write your own server side web api in whatever language floats your boat.
ETA: question 153420 might be helpful also.
精彩评论