5 Replies Latest reply on Aug 20, 2010 7:21 AM by injpix

    Silly Question About Loading TXT

    Whitetimer Level 1

      Hi All


      Been away from Flex for a while and just come back to Flex 4, but i am having trouble loading a text file.  This is what i have .....


      <?xml version="1.0" encoding="utf-8"?>

      <s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009"




                               width="100%" initialize="loadTXT(event)">


                <!-- Place non-visual elements (e.g., services, value objects) here -->








                     private function loadTXT(event:Event):void


                          var loader:URLLoader = new URLLoader();

                          loader.load(new URLRequest("Text/sample.txt"));

                          loader.addEventListener(Event.COMPLETE, onComplete);



                     private function onComplete(event:Event):void


                          var myData:String = new String(event.target.data)









                <s:VerticalLayout horizontalAlign="center" verticalAlign="top" />



           <s:HGroup width="100%" height="100%">


                <s:Panel width="300" height="100%" title="Information" dropShadowVisible="false">




                <s:BorderContainer width="100%" height="100%">


                     <s:Label id="textTXT"/>


                     <mx:ViewStack id="infoVS" width="100%" height="100%">










      Any suggestions ... I tried it using a button click and it works, but i cant get it to work when the page loads ...


      Many Thanks