2 Replies Latest reply on Sep 29, 2010 5:34 AM by Whitetimer

    How Do I Load Multiple Text Docs ..... ?

    Whitetimer Level 1

      Hi All

       

      I have a custom component that loads a text document.  Now instead of having 10 custom components that load ten individual text documents, how can i use one custom component to load the ten text documents based on the ID of the button that the user clicks ?

       

      This is my custom component

       

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

                  xmlns:s="library://ns.adobe.com/flex/spark"

                  xmlns:mx="library://ns.adobe.com/flex/mx"

                  xmlns:C="Components.*"

                  width="100%" height="100%"

                  name="New Earth Teachers Level One"

                  creationComplete="loadTXT(event)" >

           

           <!-- Properties of the parent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

           

           <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

           <fx:Declarations>

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

           </fx:Declarations>

           

           

           <!-- Metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

           <fx:Metadata>

                [Event(name="", Type="")]

           </fx:Metadata>

           

           <!-- Styles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

           

           

           <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

           <fx:Script>

                <![CDATA[

                     

                     // import statements ----------------------------------------

                     

                     

                     // variable declarations ------------------------------------

                     

                     

                     // getter/setters -------------------------------------------

                     

                     

                     // helper methods -------------------------------------------

                     

                     

                     // event handlers -------------------------------------------               

                     private function loadTXT(event:Event):void

                     {

                          var loader:URLLoader = new URLLoader();

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

                          loader.addEventListener(Event.COMPLETE, onComplete);

                     }

                     

                     private function onComplete(event:Event):void

                     {

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

                          NetOneTXT.text = myData;

                     }

                     

                     public function resetTextArea():void

                     {

                          

                     }

                     

                ]]>

           </fx:Script>

           

           <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

           

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

                <s:layout>

                     <s:VerticalLayout verticalAlign="top" gap="20" horizontalAlign="center" paddingLeft="10" paddingRight="10" paddingBottom="50" paddingTop="50" />

                </s:layout>

                

                <C:Comp_TopStroke />

                <s:TextArea id="NetOneTXT" width="80%" height="100%" borderVisible="false" editable="false" verticalScrollPolicy="auto" />

                <C:Comp_BottomStroke />

                

           </s:BorderContainer>

           

      </s:VGroup>

       

      Many Thanks