Brew mobile platform + flash Development

Source: Internet
Author: User
Tags time in milliseconds

Brew mobile phone has been launched for some time and has tried something new on the simulator. For example, his flash development is a bright spot. although we have not obtained the mobile phone, we can see that this flash development is still very powerful. next, I will repost a section about environment setup on BREW MP.

 

This section explains the installation procedure for setting up a brew MP flash development environment using Adobe Flash.

For best results, install the following software in this order:

1. Operating System: Microsoft Windows XP or Vista

2. Microsoft. NET Framework 3.5 or greater

3. Adobe Flash CS3 professional or greater
Note: You may purchase the retail version, or download the free trial version:

A. Go to http://www.adobe.com/downloads

B. Select your version of Adobe Flash Professional.

C. either create an account or use an existing account.

D. download and install the trial version of this tool application.

4. Adobe Extension Manager
Note: must be installed to support the brew mp sdk Flash plugin, Adobe Flash Lite, and Adobe mobile client (AMC) development.

5. Brew MP SDK
Note: This may be installed anytime previous to this step.

6. Brew mp sdk Flash plugin

A. Run the brew mp sdk launcher tool:
Start> Programs> Qualcomm> brew mobile platform SDK (Rev number)> Launcher

B. Click setup tab.

C. Click Flash plugin install link.

7. If you have an earlier
Version of the brew SDK btil or brew mp sdk connect installed, then
Uninstall them in Windows Add/Remove programs.

8. Brew MP connect
Note: This is necessary for installing brew MP applications on a brew MP device.

A. Run the brew mp sdk launcher tool:
Start> Programs> Qualcomm> brew mobile platform SDK (Rev number)> Launcher

B. ClickSetupTab.

C. Click ConnectInstallLink.

Note: See brew mp flash application primer for additional details on these pre-requisites.

 

After talking about the previous nonsense, let's take a look at how Flash appeared here.

We know that in brew MP, there are actually advanced interfaces such as iflashplayer. so if you write the program as the main program using native code, you can play a flash in it. but what's more, you can directly use flash as your main program. the following figure shows the flash Framework process:

 

We can find the samplecode directory of the brew mp sdk, which contains a flash_extensionapp application. as described in the preceding figure. here are. DLL ,. SWF ,. ini. it meets the elements required for a flash application to run on the simulator.

If we run this application, we will find that this is a simple page. There is a start and stop button.

If it is running, it will be even better to start up. but it implies deep understanding. this is because the start actually calls the brew API ishll_settimer method, and similar stop also calls the ishell_stoptimer method. but wait. here is a flash program. how can he call the brew API interface?

This is where I want to talk about its power. In brew MP, I introduced a stuff called ActionScript extension. do not get this name wrong. this is not an extension of ActionScript written in flash, but a DLL written in native code (C language. you can write one or several such DLL files. this is a bridge between native code and ActionScript. in principle, you can call any brew MP native API through the interfaces provided by The ActionScript extension. this makes FLASH application more powerful than brew native application. at least theoretically.

Next, let's take a look at how the call is completed. If we open the. As file under the flash_extensionapp folder, we can see such similar code

// Guard against recreating the sample extension and the handler object <br/> If (undefined = sample) <br/>{< br/> sample = new com_qualcomm_asesample (); <br/> handler = new object (); <br/>}< br/> // initialize dynamic text <br/> txttimer = "0 "; <br/> var COUNT = 0; <br/> var running = 0; <br/> // start a brew timer <br/> function starttimer () <br/>{< br/> running = 1; <br/> sample. starttimer (100, handler, "ontimer"); <br/>}< br/> // stop timer <br/> function stoptimer () <br/>{< br/> sample. stoptimer (); <br/> COUNT = 0; <br/> running = 0; <br/>}

First, the sample instance is created here. This is an asesample instance. Where is this instance? This instance is flash_extension. If we open the flash_extension project under samplecode, we will find the description in CIF:

Sysrsc {
Type = 0x1078f14, -- aeeiid_iasextension
Id = "asextension/com_qualcomm_asesample ",
Data = aeeclsid_flashext
}

 

Continue, we see starttimer and stoptimer. These two interfaces call two member functions of the sample, starttimer and stoptimer. How does this call happen? I saw a function in the flash_extension project:

/* Interface Method */<br/> static aeeresult asesample_callmethod (iasextension * Pi, iasobject * piobj, <br/> iasargs * piargs, iasvar * pivar, <br/> const char * pszmethod) <br/>{< br/> asesample * Me = asesamplefromiasextension (PI); <br/> Boolean bresult; <br/> If (0 = stricmp (pszmethod, "starttimer") {<br/> bresult = asesample_starttimer (Me, piargs ); <br/>}< br/> else if (0 = stricmp (pszmethod, "stoptimer") {<br/> bresult = asesample_stoptimer (me ); <br/>}< br/> else if (0 = stricmp (pszmethod, "posturl") {<br/> bresult = asesample_posturl (Me, piargs, 0 ); <br/>}< br/> else if (0 = stricmp (pszmethod, "browseurl") {<br/> bresult = asesample_posturl (Me, piargs, 1 ); <br/>}< br/> else if (0 = stricmp (pszmethod, "receiveurl") {<br/> bresult = asesample_receiveurl (Me, piargs ); <br/>}< br/> else {<br/> iasvar_settoundefined (pivar); <br/> return aee_ebaditem; <br/>}< br/> iasvar_settoboolean (pivar, bresult); <br/> return aee_success; <br/>}< br/>

Now I understand it all at once. in fact, the call relationship is ActionScript => ActionScript Vm => ActionScript extension. according to the iiasextension instance registered here, The ActionScript VM finds the asesample_callmethod method to complete the call. we can see that the function to be called is represented by the pszmethod field. this requires matching parsing in extension. this process is clear. (The details of how to write an extension are not shown here. We recommend that you copy the example of modifying flash_extension in Qualcomm ).

After this call, flash can manipulate native code. How does native code notify flash? Or how to call functions in flash? We noticed that when starttimer is called in the. As file, there are several parameters.Sample. starttimer (100, handler, "ontimer ");

The answer is in these parameters. ontimer is a callback function here. We can see the prototype of this function:

// Timer callback function
Handler. ontimer = function ()
{
If (running ){
Txttimer = string (++ count );
Starttimer ();
}
}

Similarly, when we go back to flash_extension, we have noticed the following implementation:

//////////////////////////////////////// //////////////////////////////////////// <Br/> // extension methods <br/> static void asesample_timerfired (void * PV) <br/>{< br/> asesample * Me = (asesample *) PV; <br/> iasobject_callmethod (Me-> piobjtimer, me-> pszmethodtimer, 0 ); <br/> iqi_releaseif (Me-> piobjtimer ); <br/>}< br/> /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ <Br/> Extension Method-starttimer <br/> usage: <br/> shell. starttimer (timems, handlerobj, methodname) <br/> parameters: <br/> timems <number> time in milliseconds of timer delay. <br/> handlerobj <Object> object that will process the function result. <br/> methodname <string> name of the method on handlerobj that will <br/> process the function result. must conform to the <br/> function prototype: <Ontimerfired> <br/> handler: <br/> <ontimerfired> () This handler is invoked when timer has fired. <br/> handler parameters: <br/> none. <br/> */<br/> static Boolean asesample_starttimer (asesample * Me, iasargs * piargs) <br/>{< br/> iasobject * piobj = 0; <br/> char abuffer [64]; <br/> aeeresult nerr; <br/> int nvalue, cbreq; <br/> freeif (Me-> pszmethodtimer ); <br/> iqi_releaseif (Me-> piobjtimer); <br/> N Err = iasargs_getasinteger (piargs, 0, & nvalue); <br/> If (aee_success! = Nerr) {<br/> goto bail; <br/>}< br/> nerr = iasargs_getasobject (piargs, 1, & piobj); <br/> If (aee_success! = Nerr) {<br/> goto bail; <br/>}< br/> nerr = iasargs_getasstring (piargs, 2, abuffer, sizeof (abuffer), & cbreq ); <br/> If (aee_success! = Nerr) {<br/> goto bail; <br/>}< br/> // save method name <br/> nerr = err_strdup (const char *) abuffer, (char **) & Me-> pszmethodtimer); <br/> If (aee_success! = Nerr) {<br/> goto bail; <br/>}< br/> // save handler object <br/> me-> piobjtimer = piobj; <br/> iasobject_addref (Me-> piobjtimer); <br/> nerr = ishell_settimer (Me-> pishell, (int32) nvalue, asesample_timerfired, me ); <br/> bail: <br/> iqi_releaseif (piobj); <br/> return (aee_success = nerr )? 1: 0; // 1 means settimer succeeded <br/>}

In fact, the callback is completed through iasobject_callmethod. we noticed that iasargs * piargs refers to the parameter list at starttimer. We can see that the third parameter (actually ontimer) is obtained through the iasargs_getasstring interface ). then, after timer arrives, the flash will be notified through iasobject_callmethod (Me-> piobjtimer, me-> pszmethodtimer, 0.

 

To sum up, flash can call the native API of brew MP on the brew MP platform to expand its functions. however, it must be completed by using ActionScript. actionScript interacts with information through two main interfaces. flash uses iasextension_callmethod to call the brew interface, and brew uses iasobject_callmethod to call the flash interface. this is just a simple research. for in-depth development, there are still many more detailed questions. For example, if I use idisplay to draw pages in the brew code, who is controlling the screen at this time? Is it synchronous and asynchronous? I am confused, right? And some applications cannot use the camera module of ActionScript, and icamera of native code is required. At this time, real-time requirements are very high. How can we combine it with the flash UI? So in general, at least the flash brew MP solution looks pretty good, but how many surges are there under it? I'm afraid no one knows yet...

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.