Chapter 11 Example 6
♥0 |
Line 26 |
Modified 2009-09-15 06:12:03 |
MIT License
archived:2017-03-30 03:24:34
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jufw
*/
package {
import com.actionscriptbible.Example;
public class ch11ex6 extends Example {
private const MXML:XML =
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo">
<s:Button label="Test" id="myButton"/>
<mx:Slider direction="horizontal" id="mySlider"/>
<fx:Script><![CDATA[
protected const AUTHOR:String = "roger";
]]></fx:Script>
</s:Application>
public function ch11ex6() {
var s:Namespace = new Namespace("library://ns.adobe.com/flex/spark");
default xml namespace = s;
var newXML:XML = <Application><Button label="new button"/></Application>;
trace(newXML.toXMLString());
//<Application xmlns="library://ns.adobe.com/flex/spark"...
//any new XML you create uses this as the default namespace
trace(MXML.Button.toXMLString());
//the s namespace is open as the default namespace so no need to scope this
MXML.appendChild(<VGroup/>);
MXML.VGroup.appendChild(<CheckBox label="new control!"/>);
trace(MXML.toXMLString());
//these new nodes get assigned to the s namespace too.
//...<s:VGroup>
// <s:CheckBox label="new control!"/>
// </s:VGroup>
}
}
}