XML loading ISSUE


hi,

 

i unable load xml.

 

package
{
    import flash.display.sprite;
    import flash.events.event;
    import flash.net.urlrequest;
    import flash.net.urlloader;
    import fl.transitions.easing.strong;
    import flash.text.textformat;
    import flash.text.textfield;
    import flash.text.textfieldautosize;
    import fl.transitions.tween;
    import flash.filters.dropshadowfilter;
   
    public class ps extends sprite
    {
        private var graphcontainer:sprite =  new sprite();
        private var tween:tween;
        private var tf:textformat = new textformat();
        private const bar_spacing:int = 150;
        private var nextbarpos:number;
       
       
        public function ps():void
        {
            // text format
           
            tf.color = "000099";
            tf.size = 40;
            tf.font = "century gothic";
           
            creategraphcontainer();
            //createbars();
        }
       
        private function creategraphcontainer():void
        {
            graphcontainer.graphics.linestyle (1,0x9c9c9e);
            graphcontainer.graphics.moveto (0,0);
            graphcontainer.graphics.lineto (0,500);
            graphcontainer.graphics.lineto (1025,500);
            graphcontainer.x = 0;
            graphcontainer.y = 0;
            var txt:textfield;
            var nexty:number = 0;
            var notch:number = 200;
            (var i:int = 0; < 1400; += notch)
            {
                  txt = new textfield();
                 txt.text = string(i);
                 txt.defaulttextformat = tf;
                 txt.y = (1450 - nexty)/3;
                 txt.x = -30;
                 addchild(txt);
                    nexty += notch;
}
            addchild (graphcontainer); // display graphcontainer
        }
       
        // loading xml file
        private function loadxml(file:string):void
        {
            var urlloader:urlloader =  new urlloader();
            urlloader.addeventlistener(event.complete, parsexml);
            urlloader.load(new urlrequest(file));
        }
       
        private function parsexml (e:event):void
        {
            e.target.removeeventlistener (event.complete, parsexml);
           
            var xmldata:xml = new xml (e.target.data);

 

            createbars (xmldata);
        }
               
        private function createbars (currentxml:xml):void
        {
            (var i:number = 0; < currentxml.children().length(); i++)
            {
                var bar:sprite = new sprite ();
               
                bar.graphics.beginfill (currentxml.children()[i].@color);
                bar.graphics.drawrect (0,0,currentxml.@width,currentxml.children()[i].@value);
                bar.graphics.endfill ();
               
                nextbarpos += currentxml.@width + bar_spacing;
                bar.x = nextbarpos;
               // bar.x = 150 + currentxml.@width * + 80 * i;
                bar.y = 150 - bar.height;

 

                var val:textfield = new textfield ();

 

                val.defaulttextformat = tf;
                val.autosize = textfieldautosize.right;
                val.text = currentxml.children()[i].@value;
           
                val.x = 110 + currentxml.@width * + 80 * i;
                val.y = 160 - bar.height;

 

                var tween:tween = new tween (bar,"height",strong.easeout,15,bar.height,1,true);

 

                addchild (bar);
                addchild (val);
            }
        }
        private function displaynames(currentxml:xml):void
        {
            (var i:number = 0; < currentxml.children().length(); i++)
            {
                var names:textfield = new textfield();

 

                names.defaulttextformat = tf;
                names.autosize = textfieldautosize.left;
                names.text = currentxml.children()[i]. @ name;

 

                names.x = 15 + (40 * i);
                names.y = 150;

 

                addchild(names);
            }
        }
        private function displaynamesp(currentxml:xml):void
        {
            (var i:number = 0; < currentxml.children().length(); i++)
            {
                var namesp:textfield = new textfield();

 

                namesp.defaulttextformat = tf;
                namesp.autosize = textfieldautosize.left;
                namesp.text = currentxml.children()[i]. @ namesp;

 

                namesp.x = 370;
                namesp.y = 80 + (10 * i);

 

                addchild(namesp);
            }
        }
    }
   
}

what mean unable load xml? maybe need call loadxml(file:string) method? in code load called...



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to decompile jsxbin to jsx

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

Phoca Guestbook logger registret bruger af - Joomla! Forum - community, help and support