Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

there is a very good preliminary sample for understanding that how should variables from a Flash content be accessed in BrewMP Applet.

 

Go through & play a bit with the flash_extensionapp & the flash_extension to understand (they come with the sample Apps for BrewMP).

 

There are two components involved in the communication between Flash Content (eg: flash_extensionapp which has a Flash file swf & a actionscript file *.as) & the BREW MP (flash_extension in which we access the variables of the Flash Content. eg: flash_extension).

 

To understand better you may put Debug Points in the code of flash_extension & start the flash_extension in debug mode on the simulator. Now start the Flash Extension App on same Simulator.

Below is some light on how things are working in this sample.

 

In the flash_extensionapp folder you will see that there is a "flash_extensionapp.as" file(its a plain txt file, you may open this file in textpad or any text editor).

 

This File contains the variables that are used in the "flash_extensionapp.swf" (flash executable).

Note: *.as are action script files used for coding in flash.

 

Now here is how the action script/SWF pass the value to a function in BREW MP extension:

In action script: see function:

 

// start a BREW timer

//This function is called in SWF When a user press START button.

function startTimer()

{

running = 1;

sample.startTimer(100, handler, "onTimer");

}

 

In response this function calls a BREW MP Function in the flashextension:

//see the extension code:

static boolean MyExt_StartTimer(MyExt * pMe, IASArgs * piArgs) {

}

 

The 3 variables from the action script are passed to the function MyExt_StartTimer in BREW.

//Note here variables can be passed as SRTINGS, INT & OBJECTS

To retrieve the variables see the below above in this function:

IASArgs_GetAsObject()

IASArgs_GetAsString()

IASArgs_GetAsInteger()

How to call a method in action script to communicate to the SWF(Flash Content):

// In method MyExt_StartTimer() you will see a ISHELL_SetTimer() call to BREW method MyExt_TimerFired().

//In this function MyExt_TimerFired() see the call to:

IASObject_CallMethod() - this calls the method ontimer in actionscript with 0 Arguments.

Similarly, check out the POSTURL Code, in which it shown how to create Arguments from BREWMP & pass

them to a function in actionscript:

MyExt_PostURL().