THE XML INTERFACE CLASS

com.michaelhejja.xmleditor.XMLInterface

Variables

public static var base:MovieClip -

An optional variable that can set the base or "root" of your interface. For example, if you had many levels of child movieclips being loaded and removed from the stage, you can always reference the base of your interface by using XMLInterface.base

public static var baseurl:String -

baseurl gets passed to the interface from the main application if it has been set for this page inside of the Page Options window. This can help to complete the URL path to content (images, video, mp3) if the XML file itself does not contain the full path.

public var XMLreferenceNum:Number -

This only stores the location of our current XML file inside of the XML Manager. You should never need to mess with this variable at all when creating a custom interface.

public var XMLData:XML -

This is the actual XML Data that we will be representing and manipulating. If the variable 'testing' is set to 'false,' XML data will be received directly from the XML Editor main application. If testing is set to true, a text XML file will be loaded (defined by testXMLPath), then XMLData will be received from the test file. This allows us to build and test interfaces independent from the main application.

public static var testing:Boolean -

Specifies whether we are in testing or live mode. If testing is set to true, the XML File defined by textXMLPath will be loaded, then the init() function will be fired. If testing is false, we are assuming that the interface will be loaded inside of the editor, and init() will immediately be fired. An interface with testing set to false will not function outside of the main application, so don't be alarmed if you receive runtime errors when compiling the file.
The default value is set to false

public var testXMLPath:String = -

Specifies the location of the XML file that will be loaded when testing is set to true

public var testXMLLoader:URLLoader -

This is the actual loader that loads the test XML file in testing mode. You should never need to mess with this variable at all when creating a custom interface.

public var _XMLManager:XMLManager -

This is a local instance of the XMLManager class, basically used to communicate between the main application and our interface. You you will probably never need to mess with this when creating a custom interface.


Methods

constructor -

The constructor only creates a new instance of the XMLManager class and the added to stage event listener

public function addedListener(e:Event)

Fires once the interface is added to the stage. It first checks whether testing is set to true or false. If true, we will load a local XML File specified by textXMLPath. If false, it will try to load the XML data from the Main application through XMLManager

public function init()

init is where we start building our interface and all of its functionality.
If we are in live mode (testing = false), XMLData will immediately be received from the main application and init() will fire. If testing = true, init will fire only after the text XML file has been loaded. We will override this function on our own interface

example:
public override function init():void {
buildOurInterface();
}

public function onXMLSaved()

onXMLSaved fires after the XML file has successfully been saved. We will override this function in our own interface.

example:
public override function onXMLSaved():void {
showSavedMessage();
}

public function loadComponent(clip:*)

This function will 'dim the lights' and load a movieclip (specified by clip) on top of the editor.

public function unloadComponent(clip:*)

Unloads a loaded component movieclip (specified by clip) and fades the page back to normal.

example of loading and unloading a component on top of the page:

private function openEditor(e:Event):void {

thumbCreator = new ThumbCreator();
loadComponent(thumbCreator);
thumbCreator.addEventListener(ThumbCreator.ON_EXIT, unloadThumbCreator);
}

private function unloadThumbCreator(e:Event){
XMLInterface.base.unloadComponent(thumbCreator);
}

public function saveXML()

Sends our XMLData (which we have manipulated) back to the XMLManager to save the file. When save is complete, onXMLSaved() will fire.

public var _XMLManager:XMLManager -

This is a local instance of the XMLManager class, basically used to communicate between the main application and our interface. You you will probably never need to mess with this when creating a custom interface.