forked from: 丸め誤差

by mtok forked from 丸め誤差 (diff: 26)
♥0 | Line 48 | Modified 2010-01-06 17:23:17 | MIT License
play

ActionScript3 source code

/**
 * Copyright mtok ( http://wonderfl.net/user/mtok )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9YVR
 */

<?xml version="1.0" encoding="utf-8"?>
<!-- forked from mtok's 丸め誤差 -->
<!-- forked from mtok's flash on 2009-11-27 -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="appCompHandler()">
    <mx:Script>
    <![CDATA[
    import mx.events.FlexEvent;
    private function appCompHandler():void{
       var d:Sprite = new Sprite();
       
       println(String(d));
       println(d.name);
       
       
       var xml:XML = XML("<a>hoge</a>");
       println(xml);
       xml != "" ? println('true') : println("false");
       xml.hasSimpleContent() ? println('simple') : println("complex");
       xml = XML("<a><b >foo</b></a>");
       println(xml);
       xml != "" ? println('true') : println("false");
       
       xml = XML("bar");
       println(xml);
       xml != "" ? println('true') : println("false");

       xml = XML("<b href='aaaa' />");
       println(xml);
       xml != "" ? println('true') : println("false");
       
       xml = new XML("<a>hogehoge</a>");
       println(xml.toString());
       println(String(xml));
    }
    
    private function print(str:String):void{
        taOutput.text = taOutput.text.concat(str);    
    }
    private function println(str:String):void{
        print(str);
        print("\n");    
    }
    
    //removeChildだと名前が被る。
    private function deleteChild(node:XML):XML{
        var p:XML;
        
        if(node != null){
            if( (p = node.parent()) ){
                delete p.children()[node.childIndex()];
            }
        }
        return node;
    }
    ]]>
    </mx:Script>
    <mx:TextArea width="100%" height="100%" id="taOutput" ></mx:TextArea>
</mx:Application>