Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


cleantargetRemoves the bin/js-debug directory and app/Demo/www directory contents

Removes everything except the src directory


-Dplatform=<platform>optionAdd this option to include a new Cordova-supported platform, such as iOS or browser.
-Dappname=<other>optionIf your main MXML file does not match the outer directory (Demo in the example), set this option to the name of the main MXML file. This will also create a matching Cordova application in the app directory.


Cordova Plugins

Cordova has a number of plugins you can use that do a wide variety of things. This is great when you use JavaScript to build your Cordova apps. All you need to do is go to your Cordova application directory and install the plugin, like this:

Code Block
titleAdd Plugin
cordova plugin add cordoba-plugin-geolocation

But if you plan to use FlexJS and ActionScript, some additional steps need to be done. If you were to write the code to use the plugin, something like this in your ActionScript code:

Code Block
titleUse Plugin (JavaScript)
navigator.geolocation.getCurrentPosition(onSuccess, onError);

you will get an error as the compiler does not know what navigator is. In order to use Cordova plugins, you need to create ActionScript wrappers for them in the FlexJS framework projects. There is one started for the Geolocation plugin in the Mobile framework project in flex-asjs/frameworks/projects/Mobile.

If you look into the org.apache.cordova package, you will see a sub-package for the Geolocation framework (geolocation). Inside of this package is the Geolocation ActionScript class file. The class includes an ActionScript function to call the plugin:

Code Block
titleGeolocation Class
		 * Gets the device current location. If successful, the onSuccess function is
		 * called with position parameter (see Cordova documentation). If failure, the
		 * onError function is called with an error parameter (.code and .message members).
		public function getCurrentPosition(onSuccess:Function, onError:Function):void
				navigator["geolocation"].getCurrentPosition(onSuccess, onError);

Within the getCurrentPosition function is the JavaScript call positioned within a COMPILE::JS block. This code block is available to framework classes and causes the code within it to be inserted, as-is, in the cross-compiled JavaScript output. 

Now your ActionScript application code can make use of it:

Code Block
firstlineUsing Geolocation
import org.apache.cordova.geolocation.Geolocation;
    var geolocation:Geolocation = new Geolocation();
    geolocation.getCurrentPosition(onSuccess, onError);
private function onSuccess(position):void {
    trace("Lat = "+position["coords"]["latitude"]+"; Lng = "+position["coords"]["longitude"]);

If you want to use a Cordova plugin in your FlexJS application, you will need to extend the FlexJS framework. Once you have done that, you can submit your code to the Apache Flex project for inclusion.


If you need to change your FlexJS application code source (MXML or ActionScript files), simply re-run the ANT command with the cordova-build.xml file.