Using C++ on its own is not the only way of developing bada applications, you can create applications using a mixture of C++ APIs and web (Javascript, WAC, HMTL5) and Flash technologies. Skeleton versions of both these application types can be created easily using the application wizard in the bada IDE.
The web application wizard allows developers to create applications using a mixture of HTML, CSS and Javascript. The bada C++ code to create the web control and launch an HTML file is automatically created for you. The web control loads an HTML file called index.html, which in turn uses the Javascript file main.js. Default versions of these files are generated for you and you can then add your own HTML and Javascript to build the web application.
Flash applications are based around a SWF file created using Adobe Flash Lite 3.1 and Actionscript 2.0. Flash objects are represented in bada as controls and you can communicate between your Flash user interface and bada by using the fscommand2 ActionScript statement.
For example, the ActionScript fragment below invokes fscommand2 Set with a custom value,
SendDataEvent:
fscommand2("Set","SendDataEvent", "/");
Data can be sent back to the Flash object by using the SendDataEventToActionScript() API call.
To receive the event from the Flash object we implement the IFlashEventListener interface and respond to the event in the OnFlashDataReceived() method.
Here’s a portion of the code that responds to the SendDataEvent message and sends some data back to the Flash object. FlashForm is a form which derives from IflashEventListener and so gets to handle Flash related events.
pReceivedMethod is a string containing the event received from the Flash control, pFlash is the Flash control itself and dataList is an ArrayList containing the information to send back to the Flash control:
// Implement this callback method from the
// Osp::Ui::IFlashEventListener Interface to respond to the ActionScript
// "Set" fscommand2 that we defined for the PushButton Flash object.
Void
FlashForm::OnFlashDataReceived (const Osp::Ui::Control &source,
const Osp::Base::Collection::IList ¶mList)
{
// code to extract the message and set up the data to send back goes here
// …………………………………….
// If this is the event we were expecting, send a response
if(pReceivedMethod->Equals(L"SendDataEvent",true)) {
pFlash->SendDataEventToActionScript(L"TestExtension",dataList);
}
}
So, bada makes it possible to create your design your entire user interface in Flash- great for porting a Flash based game from another platform, for example.
For a complete code example showing interaction between Flash and bada, keep an eye on ‘Developer Tips’ section of developer.bada.com for a recipe which explains the subject in detail.
You can build a Flash based bada app using Flash Lite 3.1 and ActionScript 2.0. |
This comment has been removed by the author.
ReplyDelete