In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

xml parse

Get Adobe Flash player
by jackzhang1204 17 Aug 2010
/**
 * Copyright jackzhang1204 ( http://wonderfl.net/user/jackzhang1204 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dUSE
 */

package
{
    import flash.display.Sprite;
    import flash.events.Event;
    public class Main extends Sprite
    {
        private var _movieWidth:int;
        private var _movieHeight:int;
        private var _movieColorArray:Array;

        private var colors:String;
       
        public var configXml:XML=
            <flashConfig>
                <swf movieWidth="300" movieHeight="300" movieColor="0x00ffff,0x0000ff,0xff0000,0xffff00,0xff00ff"/>
            </flashConfig>;
        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 flashConfigXml:XML = new XML(configXml);
            var configSwfList:XMLList=flashConfigXml.swf;

            this._movieWidth = int(configSwfList.@movieWidth);
            //this._movieHeight = int(configSwfList.@movieHeight);
            this._movieHeight = configSwfList.@movieHeight;
            
            //var colors:String = String(configSwfList.@movieColor);
            var colors:String = configSwfList.@movieColor;
           
            this._movieColorArray=colors.split(",");
           
            var rect:Sprite = new Sprite();
            rect.graphics.beginFill (this._movieColorArray[Math.floor(Math.random()*10*this._movieColorArray.length/10)]);
            rect.graphics.drawRect (0,0,this._movieWidth,this._movieHeight);
            addChild (rect);
            
        }
    }
}