forked from: forked from: flash on 2012-3-11

by umhr forked from forked from: flash on 2012-3-11 (diff: 44)
...
@author umhr
♥0 | Line 34 | Modified 2012-03-11 15:57:41 | MIT License
play

ActionScript3 source code

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

package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
    
    /**
     * ...
     * @author umhr
     */
    public class Main extends Sprite 
    {
        
        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        
        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point
            
            var url:URLRequest = new URLRequest("http://search.twitter.com/search.atom?q=hoge");
            //var url:URLRequest = new URLRequest("http://mztm.heteml.jp/test.txt");
            //var url:URLRequest = new URLRequest("index.html");
            var loader:URLLoader = new URLLoader(url);
            loader.addEventListener(Event.COMPLETE, loader_complete);
        }
        
        private function loader_complete(event:Event):void 
        {
            
            var myXML:XML = XML(event.target.data);
            
            default xml namespace = new Namespace("http://www.w3.org/2005/Atom");
            
            trace(myXML.entry.length());
            //myXML.entry.length();
            
            var textField:TextField = new TextField();
            textField.text = myXML.entry[0].title;
            textField.width = 800;
            textField.height = 600;
            addChild(textField);
        }
        
    }
    
}