-
Notifications
You must be signed in to change notification settings - Fork 3
Appendix C: Launch Configurations
If you've followed the tutorials you'll be used to the fact that the CoreEditor_AIR
project is separate to the CoreEditor
library project. The CoreEditor
library project provides the classes to build an application with, but it doesn't define the application itself.
The CoreEditor_AIR
project we have been working with defines a single application of the framework that ultimately runs in the AIR runtime. But there’s no reason we couldn't define another application that ends up running in the browser, or the standalone player.
This project already exists, and can be found here.
Both of these projects are very simple and generally only have a single class that defines the behaviour of the app as it starts up. This class delegates the work of initializing the CoreEditor
framework to an operation, and usually displays a splash screen while it waits.
The operation that initializes the CoreEditor
framework takes 2 parameters:
- A reference to the stage, which is passed to CoreEditor.init()
- A url to a config file – This defines the local path to an XML file that contains information on how the framework should be configured. Here’s an example of the default
config.xml
file. This file is loaded by default unless another is specified.
<xml>
<applicationID><![CDATA[CoreEditor]]></applicationID>
<fileSystemProvider environment="air" type="local" id="core.local" label="Core" folderName="CoreEditor" />
<fileSystemProvider environment="browser" type="sharedObject" id="core.sharedObject" label="Core" />
<fileSystemProvider environment="browser" type="url" id="core.url" label="Core_URL" baseURL="files" visible="false" />
<extension url="extensions/Default_Ext.swf" />
<extension url="extensions/HelloWorldExtension.swf" />
<!-- File templates -->
<template>
<label><![CDATA[String List]]></label>
<description><![CDATA[Creates a blank String list file.]]></description>
<url><![CDATA[extensions/fileTemplates/stringList.strlist]]></url>
<icon>core.editor.icons.CoreEditorIcons::BlankTemplateIcon</icon>
</template>
</xml>
The filesystemProvider
tag allows you to define what filesystems providers are available at startup. You can define more that one of these. The type
attribute can be either local
, sharedObject
or url
.
Next we have the extension nodes. Here we list the urls of the Extension SWFs we want the framework to load at startup. It is this, more than any other part of the config file that determines how an application works, as ultimately it is extensions that contribute the behaviour.
The CoreEditor_AIR
application and the CoreEditor_Browser
application allow you to specify a different config file to be loaded at run-time. So you don’t need to have multiple versions of this applications, each hard-coded with a different config file to load. This allows you to use a single application to debug multiple configurations of the IDE.
The mechanism for doing this differs between the AIR and browser version of the CoreEditor
app.
Finally we have file templates, which should be familiar from the File Types tutorial.
The AIR app uses ‘invocation arguments’ to determine if a path to a different config file has been passed. These are analogous to command line arguments passed to programs via the command prompt, i.e.
C:/> copy myFile.txt
It assumes the first argument is the path to the config file, and ignores all others. It stores this, and later passes it to the operation responsible for initialising the CoreEditor
framework.
You can specify your own command line arguments via FlashBuilder’s ‘Launch Configurations’ mechanism.
- Open the properties panel for the AIR project.
- Select Run/Debug Settings from the left menu.
- Click New, select AIR_Application then OK.
- Towards the bottom of the panel is a field labelled ‘Command line arguments’. This is where you enter the path to your own config file.
The browser app uses flash vars as its ‘command line’ arguments, so relies on different html files to specify the vars while embedding the SWF. The default html file looks like this
<script type="text/javascript">
var flashvars = {};
flashvars.configURL = "config.xml";
flashvars.as_swf_name = "flashcontent";
var params = {};
params.scale = "noscale";
params.allowFullScreen = true;
params.allowScriptAccess ="always";
params.wmode = "direct";
var attributes = {};
attributes.id = "flashcontent";
swfobject.embedSWF("CoreEditor_Browser.swf", "flashcontent", "100%", "100%", "10.0.0", false, flashvars, params, attributes);
</script>
Note the flashvars.configURL
line.
CoreEditor_Browser
also uses launch configurations to specify a different HTML to launch from.