6 Replies Latest reply on Nov 19, 2009 9:11 AM by David_F57

    Flex, Targeting Data from XML into Label

    tvn studios

      I have a Flex Application that runs perfectly, everything is just how I want it to be...the problem is that I can't seem to link the data from an xml file into a data cell reflected in the flex application.  Can anyone help me see what I'm doing wrong?

       

      This is the Flex Application

       

      <?xml version="1.0"?>
      
      <!-- mxml/WipeLeftEffect.mxml -->
      
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*"
      
        pageTitle="FredEA" width="100%" height="100%"
      
        layout="absolute" backgroundColor="#18188A"
      
        creationComplete="continueUpdate();" resize="onResize();">
      
        <mx:Style>
      
      
      
        </mx:Style>
      
        <mx:Script>
      
          <![CDATA[
      
            import mx.events.DropdownEvent;
      
            import mx.events.ListEvent;
      
            import mx.events.IndexChangedEvent;
      
            import mx.collections.ArrayCollection;
      
            import flash.events.Event;
      
            import flash.net.URLLoader;
      
            import flash.net.URLRequest;
      
            import flash.net.URLRequestHeader;
      
            import flash.utils.Timer;
      
            import flash.events.TimerEvent;
      
      
      
      
      
            private function onResize():void
      
            {
      
              if(pair_1_m1==null)
      
              {
      
                return;
      
              }
      
      
      
              var rate_w:Number = this.width/this.measuredWidth;
      
              var rate_h:Number = this.height/this.measuredHeight;
      
      
      
              var rate:Number = rate_w;
      
      
      
              pair_1_m1.scaleX = rate;
      
              pair_1_m1.scaleY = rate;
      
              pair_1_m5.scaleX = rate;
      
              pair_1_m5.scaleY = rate;
      
              pair_1_m5.x = pair_1_m1.x+pair_1_m1.width+5;
      
              pair_1_m15.scaleX = rate;
      
              pair_1_m15.scaleY = rate;
      
              pair_1_m15.x = pair_1_m5.x+pair_1_m5.width+5;
      
              pair_1_m30.scaleX = rate;
      
              pair_1_m30.scaleY = rate;
      
              pair_1_m30.x = pair_1_m15.x+pair_1_m15.width+5;
      
              pair_1_h1.scaleX = rate;
      
              pair_1_h1.scaleY = rate;
      
              pair_1_h1.x = pair_1_m30.x+pair_1_m30.width+5;
      
              pair_1_h4.scaleX = rate;
      
              pair_1_h4.scaleY = rate;
      
              pair_1_h4.x = pair_1_h1.x+pair_1_h1.width+5;
      
      
      
              pair_2_combo.y = pair_1_m1.height+80;
      
              pair_2_lastupdate.y = pair_2_combo.y+2;
      
              pair_2_time.y = pair_2_combo.y+2;
      
      
      
              pair_2_m1.scaleX = rate;
      
              pair_2_m1.scaleY = rate;
      
              pair_2_m1.y = pair_2_time.y+28;
      
              pair_2_m5.scaleX = rate;
      
              pair_2_m5.scaleY = rate;
      
              pair_2_m5.x = pair_2_m1.x+pair_2_m1.width+5;
      
              pair_2_m5.y = pair_2_m1.y;
      
              pair_2_m15.scaleX = rate;
      
              pair_2_m15.scaleY = rate;
      
              pair_2_m15.x = pair_2_m5.x+pair_2_m5.width+5;
      
              pair_2_m15.y = pair_2_m1.y;
      
              pair_2_m30.scaleX = rate;
      
              pair_2_m30.scaleY = rate;
      
              pair_2_m30.x = pair_2_m15.x+pair_2_m15.width+5;
      
              pair_2_m30.y = pair_2_m1.y;
      
              pair_2_h1.scaleX = rate;
      
              pair_2_h1.scaleY = rate;
      
              pair_2_h1.x = pair_2_m30.x+pair_2_m30.width+5;
      
              pair_2_h1.y = pair_2_m1.y;
      
              pair_2_h4.scaleX = rate;
      
              pair_2_h4.scaleY = rate;
      
              pair_2_h4.x = pair_2_h1.x+pair_2_h1.width+5;
      
              pair_2_h4.y = pair_2_m1.y;
      
      
      
            }
      
      
      
            public var server_host:String = "http://www.tvnstudios.com";//"http://kolier.li";//"http://fredworthy.com";
      
            public var server_path:String = "/fredea/metatrader/experts/files/Sea_Data/";
      
            public var pairs:ArrayCollection = new ArrayCollection(
      
            [ {label:"EURUSD", data:1 }, 
      
              {label:"GBPUSD", data:2}, 
      
              {label:"GBPJPY", data:3},]);  
      
      
            private var xml_loader:URLLoader = new URLLoader();
      
            private var xml:XML = new XML();
      
            private function pairChange(event:Event):void
      
            {
      
              var xml_file:String = server_host + server_path + "pair_" + (Number(ComboBox(event.target).selectedIndex)+1) + ".xml";
      
              var xml_request:URLRequest = new URLRequest(xml_file);
      
              xml_request.requestHeaders.push(new URLRequestHeader("Cache-Control", "no-store"));
      
              xml_request.requestHeaders.push(new URLRequestHeader("pragma", "no-cache"));
      
              xml_loader.load(xml_request);
      
              xml_loader.addEventListener(Event.COMPLETE, chartUpdate);
      
            }
      
      
      
            private function pairChange1(event:TimerEvent):void
      
            {
      
              pair_1_combo.dispatchEvent(new ListEvent("change"));
      
            }
      
      
      
            private function pairChange2(event:TimerEvent):void
      
            {
      
               pair_2_combo.dispatchEvent(new ListEvent("change"));
      
            }
      
      
      
            private function continueUpdate():void
      
            {
      
              var myTimer1:Timer = new Timer(1000);
      
              myTimer1.addEventListener(TimerEvent.TIMER, pairChange1);
      
      
      
              var myTimer2:Timer = new Timer(1000);
      
              myTimer2.addEventListener(TimerEvent.TIMER, pairChange2);
      
      
      
              myTimer1.start();
      
              myTimer2.start();
      
            }
      
      
      
            private function chartUpdate(event:Event):void
      
            {
      
              xml = new XML(xml_loader.data);
      
              var pair_name:String = xml.attribute("name");
      
              var time_update:int = xml.attribute("time");
      
              var pair_num:Number = xml.attribute("number");
      
      
      
              if((Number(pair_1_combo.selectedIndex)+1)==pair_num)
      
              {
      
                pair_1_time.text = String(time_update);
      
      
      
                pair_1_m1.data_cell_1 = Number(xml.tf.(@period=="1").cell.(@id=="1").toString());
      
                pair_1_m1.data_cell_2 = Number(xml.tf.(@period=="1").cell.(@id=="2").toString());
      
                pair_1_m1.data_cell_3 = xml.tf.(@period=="1").cell.(@id=="3").toString();
      
                pair_1_m1.data_cell_4 = xml.tf.(@period=="1").cell.(@id=="4").toString();
      
                pair_1_m1.data_cell_5 = xml.tf.(@period=="1").cell.(@id=="5").toString(); 
      
                pair_1_m1.data_cell_6 = Number(xml.tf.(@period=="1").cell.(@id=="6").toString());
      
                pair_1_m1.data_cell_7 = xml.tf.(@period=="1").cell.(@id=="7").toString();
      
                pair_1_m1.data_cell_8 = xml.tf.(@period=="1").cell.(@id=="8").toString();
      
                pair_1_m1.data_cell_9 = Number(xml.tf.(@period=="1").cell.(@id=="9").toString());
      
                pair_1_m1.data_cell_10 = Number(xml.tf.(@period=="1").cell.(@id=="10").toString());
      
                pair_1_m1.data_cell_11 = Number(xml.tf.(@period=="1").cell.(@id=="11").toString());
      
                pair_1_m1.complete();
      
      
      
                pair_1_m5.data_cell_1 = Number(xml.tf.(@period=="5").cell.(@id=="1").toString());
      
                pair_1_m5.data_cell_2 = Number(xml.tf.(@period=="5").cell.(@id=="2").toString());
      
                pair_1_m5.data_cell_3 = xml.tf.(@period=="5").cell.(@id=="3").toString();
      
                pair_1_m5.data_cell_4 = xml.tf.(@period=="5").cell.(@id=="4").toString();
      
                pair_1_m5.data_cell_5 = xml.tf.(@period=="5").cell.(@id=="5").toString();
      
                pair_1_m5.data_cell_6 = Number(xml.tf.(@period=="5").cell.(@id=="6").toString());
      
                pair_1_m5.data_cell_7 = xml.tf.(@period=="5").cell.(@id=="7").toString();
      
                pair_1_m5.data_cell_8 = xml.tf.(@period=="5").cell.(@id=="8").toString();
      
                pair_1_m5.data_cell_9 = Number(xml.tf.(@period=="5").cell.(@id=="9").toString());
      
                pair_1_m5.data_cell_10 = Number(xml.tf.(@period=="5").cell.(@id=="10").toString());
      
                pair_1_m5.data_cell_11 = Number(xml.tf.(@period=="5").cell.(@id=="11").toString());
      
                pair_1_m5.complete();
      
      
      
                pair_1_m15.data_cell_1 = Number(xml.tf.(@period=="15").cell.(@id=="1").toString());
      
                pair_1_m15.data_cell_2 = Number(xml.tf.(@period=="15").cell.(@id=="2").toString());
      
                pair_1_m15.data_cell_3 = xml.tf.(@period=="15").cell.(@id=="3").toString();
      
                pair_1_m15.data_cell_4 = xml.tf.(@period=="15").cell.(@id=="4").toString();
      
                pair_1_m15.data_cell_5 = xml.tf.(@period=="15").cell.(@id=="5").toString();
      
                pair_1_m15.data_cell_6 = Number(xml.tf.(@period=="15").cell.(@id=="6").toString());
      
                pair_1_m15.data_cell_7 = xml.tf.(@period=="15").cell.(@id=="7").toString();
      
                pair_1_m15.data_cell_8 = xml.tf.(@period=="15").cell.(@id=="8").toString();
      
                pair_1_m15.data_cell_9 = Number(xml.tf.(@period=="15").cell.(@id=="9").toString());
      
                pair_1_m15.data_cell_10 = Number(xml.tf.(@period=="15").cell.(@id=="10").toString());
      
                pair_1_m15.data_cell_11 = Number(xml.tf.(@period=="15").cell.(@id=="11").toString());
      
                pair_1_m15.complete();
      
      
      
                pair_1_m30.data_cell_1 = Number(xml.tf.(@period=="30").cell.(@id=="1").toString());
      
                pair_1_m30.data_cell_2 = Number(xml.tf.(@period=="30").cell.(@id=="2").toString());
      
                pair_1_m30.data_cell_3 = xml.tf.(@period=="30").cell.(@id=="3").toString();
      
                pair_1_m30.data_cell_4 = xml.tf.(@period=="30").cell.(@id=="4").toString();
      
                pair_1_m30.data_cell_5 = xml.tf.(@period=="30").cell.(@id=="5").toString();
      
                pair_1_m30.data_cell_6 = Number(xml.tf.(@period=="30").cell.(@id=="6").toString());
      
                pair_1_m30.data_cell_7 = xml.tf.(@period=="30").cell.(@id=="7").toString();
      
                pair_1_m30.data_cell_8 = xml.tf.(@period=="30").cell.(@id=="8").toString();
      
                pair_1_m30.data_cell_9 = Number(xml.tf.(@period=="30").cell.(@id=="9").toString());
      
                pair_1_m30.data_cell_10 = Number(xml.tf.(@period=="30").cell.(@id=="10").toString());
      
                pair_1_m30.data_cell_11 = Number(xml.tf.(@period=="30").cell.(@id=="11").toString());
      
                pair_1_m30.complete();
      
      
      
                pair_1_h1.data_cell_1 = Number(xml.tf.(@period=="60").cell.(@id=="1").toString());
      
                pair_1_h1.data_cell_2 = Number(xml.tf.(@period=="60").cell.(@id=="2").toString());
      
                pair_1_h1.data_cell_3 = xml.tf.(@period=="60").cell.(@id=="3").toString();
      
                pair_1_h1.data_cell_4 = xml.tf.(@period=="60").cell.(@id=="4").toString();
      
                pair_1_h1.data_cell_5 = xml.tf.(@period=="60").cell.(@id=="5").toString();
      
                pair_1_h1.data_cell_6 = Number(xml.tf.(@period=="60").cell.(@id=="6").toString());
      
                pair_1_h1.data_cell_7 = xml.tf.(@period=="60").cell.(@id=="7").toString();
      
                pair_1_h1.data_cell_8 = xml.tf.(@period=="60").cell.(@id=="8").toString();
      
                pair_1_h1.data_cell_9 = Number(xml.tf.(@period=="60").cell.(@id=="9").toString());
      
                pair_1_h1.data_cell_10 = Number(xml.tf.(@period=="60").cell.(@id=="10").toString());
      
                pair_1_h1.data_cell_11 = Number(xml.tf.(@period=="60").cell.(@id=="11").toString());
      
                pair_1_h1.complete();
      
      
      
                pair_1_h4.data_cell_1 = Number(xml.tf.(@period=="240").cell.(@id=="1").toString());
      
                pair_1_h4.data_cell_2 = Number(xml.tf.(@period=="240").cell.(@id=="2").toString());
      
                pair_1_h4.data_cell_3 = xml.tf.(@period=="240").cell.(@id=="3").toString();
      
                pair_1_h4.data_cell_4 = xml.tf.(@period=="240").cell.(@id=="4").toString();
      
                pair_1_h4.data_cell_5 = xml.tf.(@period=="240").cell.(@id=="5").toString();
      
                pair_1_h4.data_cell_6 = Number(xml.tf.(@period=="240").cell.(@id=="6").toString());
      
                pair_1_h4.data_cell_7 = xml.tf.(@period=="240").cell.(@id=="7").toString();
      
                pair_1_h4.data_cell_8 = xml.tf.(@period=="240").cell.(@id=="8").toString();
      
                pair_1_h4.data_cell_9 = Number(xml.tf.(@period=="240").cell.(@id=="9").toString());
      
                pair_1_h4.data_cell_10 = Number(xml.tf.(@period=="240").cell.(@id=="10").toString());
      
                pair_1_h4.data_cell_11 = Number(xml.tf.(@period=="240").cell.(@id=="11").toString());
      
                pair_1_h4.complete();
      
              }
      
      
      
              if((Number(pair_2_combo.selectedIndex)+1)==pair_num)
      
              {
      
                pair_2_time.text = String(time_update);
      
      
      
                pair_2_m1.data_cell_1 = Number(xml.tf.(@period=="1").cell.(@id=="1").toString());
      
                pair_2_m1.data_cell_2 = Number(xml.tf.(@period=="1").cell.(@id=="2").toString());
      
                pair_2_m1.data_cell_3 = xml.tf.(@period=="1").cell.(@id=="3").toString();
      
                pair_2_m1.data_cell_4 = xml.tf.(@period=="1").cell.(@id=="4").toString();
      
                pair_2_m1.data_cell_5 = xml.tf.(@period=="1").cell.(@id=="5").toString();
      
                pair_2_m1.data_cell_6 = Number(xml.tf.(@period=="1").cell.(@id=="6").toString());
      
                pair_2_m1.data_cell_7 = xml.tf.(@period=="1").cell.(@id=="7").toString();
      
                pair_2_m1.data_cell_8 = xml.tf.(@period=="1").cell.(@id=="8").toString();
      
                pair_2_m1.data_cell_9 = Number(xml.tf.(@period=="1").cell.(@id=="9").toString());
      
                pair_2_m1.data_cell_10 = Number(xml.tf.(@period=="1").cell.(@id=="10").toString());
      
                pair_2_m1.data_cell_11 = Number(xml.tf.(@period=="1").cell.(@id=="11").toString());
      
                pair_2_m1.complete();
      
      
      
                pair_2_m5.data_cell_1 = Number(xml.tf.(@period=="5").cell.(@id=="1").toString());
      
                pair_2_m5.data_cell_2 = Number(xml.tf.(@period=="5").cell.(@id=="2").toString());
      
                pair_2_m5.data_cell_3 = xml.tf.(@period=="5").cell.(@id=="3").toString();
      
                pair_2_m5.data_cell_4 = xml.tf.(@period=="5").cell.(@id=="4").toString();
      
                pair_2_m5.data_cell_5 = xml.tf.(@period=="5").cell.(@id=="5").toString();
      
                pair_2_m5.data_cell_6 = Number(xml.tf.(@period=="5").cell.(@id=="6").toString());
      
                pair_2_m5.data_cell_7 = xml.tf.(@period=="5").cell.(@id=="7").toString();
      
                pair_2_m5.data_cell_8 = xml.tf.(@period=="5").cell.(@id=="8").toString();
      
                pair_2_m5.data_cell_9 = Number(xml.tf.(@period=="5").cell.(@id=="9").toString());
      
                pair_2_m5.data_cell_10 = Number(xml.tf.(@period=="5").cell.(@id=="10").toString());
      
                pair_2_m5.data_cell_11 = Number(xml.tf.(@period=="5").cell.(@id=="11").toString());
      
                pair_2_m5.complete();
      
      
      
                pair_2_m15.data_cell_1 = Number(xml.tf.(@period=="15").cell.(@id=="1").toString());
      
                pair_2_m15.data_cell_2 = Number(xml.tf.(@period=="15").cell.(@id=="2").toString());
      
                pair_2_m15.data_cell_3 = xml.tf.(@period=="15").cell.(@id=="3").toString();
      
                pair_2_m15.data_cell_4 = xml.tf.(@period=="15").cell.(@id=="4").toString();
      
                pair_2_m15.data_cell_5 = xml.tf.(@period=="15").cell.(@id=="5").toString();
      
                pair_2_m15.data_cell_6 = Number(xml.tf.(@period=="15").cell.(@id=="6").toString());
      
                pair_2_m15.data_cell_7 = xml.tf.(@period=="15").cell.(@id=="7").toString();
      
                pair_2_m15.data_cell_8 = xml.tf.(@period=="15").cell.(@id=="8").toString();
      
                pair_2_m15.data_cell_9 = Number(xml.tf.(@period=="15").cell.(@id=="9").toString());
      
                pair_2_m15.data_cell_10 = Number(xml.tf.(@period=="15").cell.(@id=="10").toString());
      
                pair_2_m15.data_cell_11 = Number(xml.tf.(@period=="15").cell.(@id=="11").toString());
      
                pair_2_m15.complete();
      
      
      
                pair_2_m30.data_cell_1 = Number(xml.tf.(@period=="30").cell.(@id=="1").toString());
      
                pair_2_m30.data_cell_2 = Number(xml.tf.(@period=="30").cell.(@id=="2").toString());
      
                pair_2_m30.data_cell_3 = xml.tf.(@period=="30").cell.(@id=="3").toString();
      
                pair_2_m30.data_cell_4 = xml.tf.(@period=="30").cell.(@id=="4").toString();
      
                pair_2_m30.data_cell_5 = xml.tf.(@period=="30").cell.(@id=="5").toString();
      
                pair_2_m30.data_cell_6 = Number(xml.tf.(@period=="30").cell.(@id=="6").toString());
      
                pair_2_m30.data_cell_7 = xml.tf.(@period=="30").cell.(@id=="7").toString();
      
                pair_2_m30.data_cell_8 = xml.tf.(@period=="30").cell.(@id=="8").toString();
      
                pair_2_m30.data_cell_9 = Number(xml.tf.(@period=="30").cell.(@id=="9").toString());
      
                pair_2_m30.data_cell_10 = Number(xml.tf.(@period=="30").cell.(@id=="10").toString());
      
                pair_2_m30.data_cell_11 = Number(xml.tf.(@period=="30").cell.(@id=="11").toString());
      
                pair_2_m30.complete();
      
      
      
                pair_2_h1.data_cell_1 = Number(xml.tf.(@period=="60").cell.(@id=="1").toString());
      
                pair_2_h1.data_cell_2 = Number(xml.tf.(@period=="60").cell.(@id=="2").toString());
      
                pair_2_h1.data_cell_3 = xml.tf.(@period=="60").cell.(@id=="3").toString();
      
                pair_2_h1.data_cell_4 = xml.tf.(@period=="60").cell.(@id=="4").toString();
      
                pair_2_h1.data_cell_5 = xml.tf.(@period=="60").cell.(@id=="5").toString();
      
                pair_2_h1.data_cell_6 = Number(xml.tf.(@period=="60").cell.(@id=="6").toString());
      
                pair_2_h1.data_cell_7 = xml.tf.(@period=="60").cell.(@id=="7").toString();
      
                pair_2_h1.data_cell_8 = xml.tf.(@period=="60").cell.(@id=="8").toString();
      
                pair_2_h1.data_cell_9 = Number(xml.tf.(@period=="60").cell.(@id=="9").toString());
      
                pair_2_h1.data_cell_10 = Number(xml.tf.(@period=="60").cell.(@id=="10").toString());
      
                pair_2_h1.data_cell_11 = Number(xml.tf.(@period=="60").cell.(@id=="11").toString());
      
                pair_2_h1.complete();
      
      
      
                pair_2_h4.data_cell_1 = Number(xml.tf.(@period=="240").cell.(@id=="1").toString());
      
                pair_2_h4.data_cell_2 = Number(xml.tf.(@period=="240").cell.(@id=="2").toString());
      
                pair_2_h4.data_cell_3 = xml.tf.(@period=="240").cell.(@id=="3").toString();
      
                pair_2_h4.data_cell_4 = xml.tf.(@period=="240").cell.(@id=="4").toString();
      
                pair_2_h4.data_cell_5 = xml.tf.(@period=="240").cell.(@id=="5").toString();
      
                pair_2_h4.data_cell_6 = Number(xml.tf.(@period=="240").cell.(@id=="6").toString());
      
                pair_2_h4.data_cell_7 = xml.tf.(@period=="240").cell.(@id=="7").toString();
      
                pair_2_h4.data_cell_8 = xml.tf.(@period=="240").cell.(@id=="8").toString();
      
                pair_2_h4.data_cell_9 = Number(xml.tf.(@period=="240").cell.(@id=="9").toString());
      
                pair_2_h4.data_cell_10 = Number(xml.tf.(@period=="240").cell.(@id=="10").toString());
      
                pair_2_h4.data_cell_11 = Number(xml.tf.(@period=="240").cell.(@id=="11").toString());
      
                pair_2_h4.complete();
      
              } 
      
            }
      
          ]]>
      
        </mx:Script>
      
      
      
      
      
        <mx:ComboBox id="pair_1_combo" x="10" y="15" rowCount="6" dataProvider="{pairs}">
      
      
          <mx:change>
      
            <![CDATA[
      
              pair_1_combo.addEventListener(ListEvent.CHANGE, pairChange);
      
            ]]>
      
          </mx:change>
      
        </mx:ComboBox>
      
        <mx:Text x="151" y="17" text="LastUpdate:" color="#FFFFFF"/>
      
        <mx:Text id="pair_1_time" x="232" y="17" text="Text" color="#FFFFFF"/>
      
        <local:Chart id="pair_1_m1" x="10" y="45" data_tf="M1"/>
      
        <local:Chart id="pair_1_m5" x="215" y="45" data_tf="M5"/>
      
        <local:Chart id="pair_1_m15" x="420" y="45" data_tf="M15"/>
      
        <local:Chart id="pair_1_m30" x="625" y="45" data_tf="M30"/>
      
        <local:Chart id="pair_1_h1" x="830" y="45" data_tf="H1"/>
      
        <local:Chart id="pair_1_h4" x="1035" y="45" data_tf="H4"/>
      
      
      
      
      
        <mx:ComboBox id="pair_2_combo" x="10" y="340" rowCount="6" dataProvider="{pairs}">
      
            <mx:change>
      
            <![CDATA[
      
              pair_2_combo.addEventListener(ListEvent.CHANGE, pairChange);
      
            ]]>
      
          </mx:change>
      
        </mx:ComboBox>
      
        <mx:Text id="pair_2_lastupdate" x="151" y="342" text="LastUpdate:" color="#FFFFFF"/>
      
        <mx:Text id="pair_2_time" x="232" y="342" text="Text" color="#FFFFFF"/>
      
        <local:Chart id="pair_2_m1" x="10" y="370" data_tf="M1"/>
      
        <local:Chart id="pair_2_m5" x="215" y="370" data_tf="M5"/>
      
        <local:Chart id="pair_2_m15" x="420" y="370" data_tf="M15"/>
      
        <local:Chart id="pair_2_m30" x="625" y="370" data_tf="M30"/>
      
        <local:Chart id="pair_2_h1" x="830" y="370" data_tf="H1"/>
      
        <local:Chart id="pair_2_h4" x="1035" y="370" data_tf="H4"/>
      
      
      
      </mx:Application>
      
      
      
      

       

      this is the component that populates the screen of the Flex Application

      <?xml version="1.0" encoding="utf-8"?>
      
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="202.66666" height="262.6667"
      
        cornerRadius="10" alpha="1"
      
        borderStyle="solid" borderThickness="1" creationComplete="init();" borderSides="0">
        <mx:backgroundImage>@Embed(source='file:////Users/tynelson/Desktop/finalflexbg.png')</mx:backgroundImage>
        <mx:Script>
      
          <![CDATA[
      
            import mx.controls.sliderClasses.SliderThumb;
      
            import mx.validators.ValidationResult;
      
            import mx.core.UIComponent;
      
      
            import flash.geom.Matrix;
      
      
      
            [bindable]
      
            public var data_tf:String = "TF";
      
            public var data_cell_1:Number = 50;
      
            public var data_cell_2:Number = 100;
      
            public var data_cell_3:String = "2,111,000";
      
            public var data_cell_4:String = "2,111,000";
      
            public var data_cell_5:String = "EURUSD";
      
            public var data_cell_6:Number = 100;
      
            public var data_cell_7:String = "2,111,000";
      
            public var data_cell_8:String = "2,111,000";
      
            public var data_cell_9:Number = 50;
      
            public var data_cell_10:Number = 1;
      
            public var data_cell_11:Number = 50;
      
      
      
      
      
            public function init():void
      
            {
      
              drawBackground();
      
              drawGreenBig();
      
              drawGreenSmall();
      
              drawRedBig();
      
              drawRedSmall(); 
      
              drawTriangleRed();
      
              drawTriangleGreen();
      
            }
      
      
      
            public function complete():void
      
            {
      
              // Remove the old Rectangles
      
              green_big.removeChildAt(0);
      
              green_small.removeChildAt(0);
      
              red_big.removeChildAt(0);
      
              red_small.removeChildAt(0);
      
      
      
              drawGreenBig();
      
              drawGreenSmall();
      
              drawRedBig();
      
              drawRedSmall();
      
      
      
              tf.text = data_tf;
      
              slider_volume.value = data_cell_1;
      
              cell_5.text = numberFormatter.format(data_cell_5); //Pair
      
              cell_3.text = numberFormatter.format(data_cell_3);
      
              cell_4.text = numberFormatter.format(data_cell_4);
      
              cell_7.text = numberFormatter.format(data_cell_7);
      
              cell_8.text = numberFormatter.format(data_cell_8);
      
            }
      
      
      
            private function drawBackground():void
      
            {
      
              var back_ground:UIComponent = new UIComponent();
      
              var myMatrix:Matrix = new Matrix();
      
      
      
              var myColors:Array = [0x6464DA, 0x2D2D9D];
      
              var myAlphaS:Array = [100, 100];
      
              var myRalphaS:Array = [0, 225];
      
      
              back_ground.graphics.drawRect(0, 0, this.width-0, this.height-0);
      
              this.addChildAt(back_ground, 0);
      
            }
      
      
      
            private function drawGreenBig():void
      
            {
      
              var rec_green_big:UIComponent = new UIComponent();
      
              var myMatrix:Matrix = new Matrix();
      
              myMatrix.createGradientBox(50, 100, 0, 0, 0);
      
              var myColors:Array = [0x039003, 0x032003];
      
              var myAlphaS:Array = [100, 100];
      
              var myRalphaS:Array = [0, 225];
      
              rec_green_big.graphics.beginGradientFill(GradientType.LINEAR, myColors, myAlphaS, myRalphaS, myMatrix);
      
              rec_green_big.graphics.drawRect(0, green_big.height-2, green_big.width-2, -145*data_cell_6/(data_cell_6+data_cell_2));
      
              green_big.addChildAt(rec_green_big, 0); 
      
            }
      
      
      
            private function drawRedBig():void
      
            {
      
              var rec_red_big:UIComponent = new UIComponent();
      
              var myMatrix:Matrix = new Matrix();
      
              myMatrix.createGradientBox(70, 100, 0, 0, 0);
      
              var myColors:Array = [0xFF3007, 0x100000];
      
              var myAlphaS:Array = [100, 100];
      
              var myRalphaS:Array = [0, 225];
      
              rec_red_big.graphics.beginGradientFill(GradientType.LINEAR, myColors, myAlphaS, myRalphaS, myMatrix);
      
              rec_red_big.graphics.drawRect(0, red_big.height-2, red_big.width-2, -145*data_cell_2/(data_cell_6+data_cell_2));
      
              red_big.addChildAt(rec_red_big, 0); 
      
            }
      
      
      
            private function drawGreenSmall():void
      
            {
      
              var rec_green_small:UIComponent = new UIComponent();
      
              var myMatrix:Matrix = new Matrix();
      
              myMatrix.createGradientBox(50, 100, 0, 0, 0);
      
              var myColors:Array = [0x039003, 0x032003];
      
              var myAlphaS:Array = [100, 100];
      
              var myRalphaS:Array = [0, 225];
      
              rec_green_small.graphics.beginGradientFill(GradientType.LINEAR, myColors, myAlphaS, myRalphaS, myMatrix);
      
              rec_green_small.graphics.drawRect(0, green_small.height-2, green_small.width-2, -145*data_cell_11/100);
      
              green_small.addChild(rec_green_small); 
      
            }
      
      
      
            private function drawRedSmall():void
      
            {
      
              var rec_red_small:UIComponent = new UIComponent();
      
              var myMatrix:Matrix = new Matrix();
      
              myMatrix.createGradientBox(10, 100, 0, 0, 0);
      
              var myColors:Array = [0xFF3007, 0x100000];
      
              var myAlphaS:Array = [100, 100];
      
              var myRalphaS:Array = [0, 225];
      
              rec_red_small.graphics.beginGradientFill(GradientType.LINEAR, myColors, myAlphaS, myRalphaS, myMatrix);
      
              rec_red_small.graphics.drawRect(0, green_small.height-2, red_small.width-2, -145*data_cell_9/100);
      
              red_small.addChild(rec_red_small); 
      
            }
      
      
      
            private function drawTriangleRed():void
      
            {
      
              var triangle_red:UIComponent = new UIComponent();
      
              triangle_red.graphics.beginFill(0xFF3007);
      
              triangle_red.graphics.moveTo(15, 2);
      
              triangle_red.graphics.lineTo(35, 2);
      
              triangle_red.graphics.lineTo(25, 12);
      
              triangle_red.graphics.lineTo(15, 2);
      
              triangle_red.graphics.endFill();
      
              box_triangle_red.addChild(triangle_red);
      
            }
      
      
      
            private function drawTriangleGreen():void
      
            {
      
              var triangle_green:UIComponent = new UIComponent();
      
              triangle_green.graphics.beginFill(0x33cc33);
      
              triangle_green.graphics.moveTo(25, 2);
      
              triangle_green.graphics.lineTo(15, 12);
      
              triangle_green.graphics.lineTo(35, 12);
      
              triangle_green.graphics.lineTo(25, 2);
      
              triangle_green.graphics.endFill();
      
              box_triangle_green.addChild(triangle_green);
      
            }
      
      
      
          ]]>
      
        </mx:Script>
      
        <mx:NumberFormatter id="numberFormatter" precision="0" useThousandsSeparator="true" useNegativeSign="true"/>
      
        <mx:Label  id="tf" x="85" y="10" text="{data_tf}" fontWeight="bold"
      
          fontSize="16" color="#FFFF00" textAlign="left" fontFamily="Verdana"/>
      <mx:Label id="cell_5" text="{data_cell_5}" x="141" y="5.5"/>
        <mx:Label x="10" y="31" text="Volume" color="#FFFFFF" fontWeight="bold" fontSize="10"/>
      
        <mx:TextArea x="100" y="52" width="34.5" height="165" 
      
          text="100%&#xa; 90%&#xa; 80%&#xa; 70%&#xa; 60%&#xa; 50%&#xa; 40%&#xa; 30%&#xa; 20%&#xa; 10%&#xa;  0%" 
      
          fontSize="10" fontFamily="Times New Roman" wordWrap="false" editable="false" borderColor="#5555FF" 
      
          borderStyle="none" backgroundAlpha="0" color="#FFFFFF"  verticalScrollPolicy="off" textAlign="center"/>
      
        <mx:TextArea x="12.5" y="52" width="30" height="165" 
      
          text="100%&#xa; 90%&#xa; 80%&#xa; 70%&#xa; 60%&#xa; 50%&#xa; 40%&#xa; 30%&#xa; 20%&#xa; 10%&#xa;  0%" 
      
          fontSize="10" fontFamily="Times New Roman" wordWrap="false" editable="false" borderColor="#5555FF" 
      
          borderStyle="none" backgroundAlpha="0" color="#FFFFFF"  verticalScrollPolicy="off"/>
      
      
      
        <mx:HBox id="box_bottom" x="41" y="211" width="156" height="40.65" horizontalGap="0" borderColor="#ffff00" borderStyle="none" horizontalScrollPolicy="off" verticalScrollPolicy="off" borderThickness="1.5">
      
          <!-- Left -->
      
          <mx:VBox height="36" width="53" verticalGap="0" horizontalScrollPolicy="off" verticalScrollPolicy="off" borderStyle="solid" borderColor="#ffff00">
      
            <mx:Box id="box_triangle_red" height="17" width="50" borderColor="#ffff00" borderStyle="none" textAlign="center" paddingLeft="1">
      
              <!-- Triangle -->
      
            </mx:Box>
      
            <mx:Box height="17" width="51"  horizontalScrollPolicy="off" verticalScrollPolicy="off"  borderColor="#ffff00" borderStyle="none">
              <mx:HRule width="51" height="1" strokeColor="#ffff00" strokeWidth="2"/>
      
              <mx:Label id="cell_4" text="{data_cell_4}" width="51" height="16" fontSize="8" color="#ffff00" textAlign="center" paddingTop="-5"/>
      
            </mx:Box>
      
          </mx:VBox>
      
          <!-- Middle -->
      
          <mx:VBox height="36" width="51" verticalGap="0" borderStyle="solid" borderColor="#FFFF00" borderThickness=".9">
      
            <mx:Box height="17" width="48.333336" borderStyle="none" borderColor="#ffff00">
              <mx:Label text="Market" color="#FFFF00" width="46" height="15" textAlign="right"/>
      
            </mx:Box>
      
            <mx:Box height="17" width="49" borderColor="#ffff00" borderStyle="none">
                 <mx:HRule width="57.333336" height="1" strokeColor="#ffff00" strokeWidth="2"/>
                 <mx:Label text="Future" paddingTop="-7" width="45.333336" height="9" textAlign="right" color="#ffff00"/>
      
            </mx:Box>
      
          </mx:VBox>
      
          <!-- Right -->
      
          <mx:VBox height="36" width="52" verticalGap="0" borderStyle="solid" borderColor="#ffff00" horizontalScrollPolicy="off" verticalScrollPolicy="off" borderThickness=".9">
      
            <mx:Box id="box_triangle_green" height="17" width="50" borderStyle="none" borderColor="#ffff00" textAlign="center" paddingLeft="1">
      
              <!-- Triangle -->
      
            </mx:Box>
      
            <mx:Box height="17" width="50.666664" horizontalScrollPolicy="off" verticalScrollPolicy="off" borderColor="#ffff00" borderStyle="none">
              <mx:HRule width="51" height="1" strokeColor="#ffff00" strokeWidth="2"/>
      
              <mx:Label id="cell_8" text="{data_cell_8}"  width="50" height="16" fontSize="8" color="#Ffff00" textAlign="center" paddingTop="-5"/>
      
            </mx:Box>
      
          </mx:VBox>
      
      
      
        </mx:HBox>
      
      
      
        <mx:HBox horizontalGap="0" x="41" y="58" width="63" height="148" borderStyle="solid" borderColor="#ffff00" borderThickness="1.5">
      
          <mx:Canvas id="red_big" height="145" width="51.333336" borderStyle="solid" borderColor="#ffff00" borderThickness=".5">
      
            <mx:Label id="cell_3" text="{data_cell_3}" y="103" width="50" height="16" fontSize="8" color="#FFFFFF" textAlign="center"/>
      
            <mx:Label text="SELL" fontSize="10" color="#FFFFFF" width="40" height="18" textAlign="center" fontWeight="bold" y="126" x="5"/>
      
          </mx:Canvas>
      
          <mx:Box id="red_small" height="145" width="9" borderStyle="solid" borderColor="#ffff00" borderThickness=".5">
      
          </mx:Box>
      
        </mx:HBox>
      
        <mx:HBox horizontalGap="0" x="134" y="58" width="63" height="148" borderStyle="solid" borderColor="#ffff00" borderThickness="1.5">
      
          <mx:Box id="green_small" height="145" width="9" borderColor="#ffff00" borderStyle="solid" borderThickness=".5">
      
          </mx:Box>
      
          <mx:Canvas id="green_big" height="145" width="51" borderStyle="solid" borderColor="#ffff00" borderThickness=".5">
      
            <mx:Label id="cell_7" text="{data_cell_7}"  y="102" width="50" height="16" fontSize="8" color="#FFFFFF" textAlign="center" x="0"/>
      
            <mx:Label text="BUY" fontSize="10" color="#FFFFFF" width="40" height="18" textAlign="center" fontWeight="bold" y="126" x="5"/>
      
          </mx:Canvas>
      
        </mx:HBox>
      
        <mx:VSlider id="slider_volume" invertThumbDirection="true" value="{1 * 100}" x="4.5" y="52" snapInterval="1" enabled="false"
      
          liveDragging="false" maximum="100" minimum="0" allowTrackClick="true" width="1" height="155">
      
          <mx:creationComplete>
      
            <![CDATA[
      
              var thumb:UIComponent = slider_volume.getThumbAt(0);
      
              thumb.width = 13;
      
              thumb.height = 13;
      
            ]]>
      
          </mx:creationComplete>
      
        </mx:VSlider>
      
      
      
      
      
      
      
      
      
      </mx:Canvas>
      
      
      

       

       

      The data is gathered from three xml files, depending on which is selected.  All the data cells get their information correctly, but the simplest one, the name listed in the xml documents, can't seem to be loaded into data_cell_5 which has an id of cell_5

       

      Can anyone help me with this?

       

      I'm so grateful for any help.

        • 1. Re: Flex, Targeting Data from XML into Label
          David_F57 Level 5

          Hi,

           

          No one can help when they need to wade through 2500 lines of white space trying to work out what exactly it is you have here. The code as supplied can't even be compiled due to errors in strings, declarations and a few other things.

           

          So I would suggest you zip the project up and attach it in order to make it easier for anyone that can help you .

           

          In the meantime you have lines like this

           

          <mx:Label id="cell_3" text="{data_cell_3}" y="103" width="50" height="16" fontSize="8" color="#FFFFFF" textAlign="center"/>

           

          data_cell_3 is not declared as Bindable so it won't bind to the label only the intialisation value will be shown, is this your problem ?

           

           

          David

           

          ps: You should have deleted your post as soon as you saw how it displayed and re posted, a little consideration for those that you want to help you can go a long way

          • 2. Re: Flex, Targeting Data from XML into Label
            mewk Level 3

            LOL -- I was wondering if someone was going to mention this (leave it up to David... ).

             

            The string errors aren't entirely his fault; the adobe boards sometimes eat quotes. But dude, let's talk about all that white space:

             

            1. Go to Windows --> Preferences --> General --> Keys
            2. Search "white"
            3. Create a binding command key on "Remove Trailing Whitespace" -- I use "ctrl+w"
            4. go back to mxml editor and highlight everything then press "ctrl + w"
            5. press "ctrl+f" to open the find/replace window
            6. find: "\r\n\r\n\r\n" (minus the double quotes -- "\r\n" is regular expression for 1 line in the editor, so we're searching for three lines in a row)
            7. replace with:"" (nothing)
            8. click "Replace All"

             

            Kaboom 2000+ lines --> 300 lines! and really, in theory, this should only takes 8 seconds to do...

             

            Now, about the problem you asked about:

             

            You would think that the missing binding metadata tags would be at fault, but the code uses a complete() function to reregister all values upon a change. The real reason you can't see cell_5 is because you have this in your code:

            • cell_5.text = numberFormatter.format(data_cell_5);
              

            but data_cell_5 is a string, not a number. what you want is simply

            • cell_5.text = data_cell_5;
              

             

            There's more to say about your code. You should review bindings and consider using loops if possible. Just because you have twelve separate graphs does not mean you need to program on all twelve of them -- somethings definitely missing here. Also I wasn't a big fan of how you handled the change events -- adding listeners in scripts blocks in the middle of the mxml code (?).

             

            On the other hand, there was some good in your code -- URLRequest was a surprise (didn't think it would pass flash security...) and I liked the graphics coding. All in all, glad I reviewed this one. Thanks,

             

            - e

            • 3. Re: Flex, Targeting Data from XML into Label
              tvn studios Level 1

              Hey guys,

               

              Thank you so much for looking past my sloppiness and inconsideration to resolve this problem.  First, I sincerely apologize, I'm new to the forums and you are 100% correct.  I'll be sure you post in a more clean and friendly fashion from now on.  Your solutions worked and I am so grateful. 

               

              Cheers to you for still assisting me considering my lack of good format.

               

              One more question, if you can help...

               

              When it scales in the browser window, it scales real jumpy like and rather sloppy...

              I know that it might be best to scale a parent container in this instance.

               

              Can you advise me on this and perhaps provide a solution if time allows?

               

              I'm so grateful for your assistance,

               

              -Tyler

              • 4. Re: Flex, Targeting Data from XML into Label
                David_F57 Level 5

                Hey Mewk,

                 

                You're back, I haven't seen you here much over the past several days, I just figured you had take a wrong turn on one of your marathons and the thing lasted longer than it was supposed to. Now I suppose I am going to have to behave myself(i should be able to do that for at lest an hour or 2) .

                 

                David.

                • 5. Re: Flex, Targeting Data from XML into Label
                  mewk Level 3

                  @David, still around! Been reading and trying to figure out what this whole FLEX business is all about.

                   

                  But, please keep throwing punches -- gotta keep this place on it's toes!

                   

                  - e

                  • 6. Re: Flex, Targeting Data from XML into Label
                    David_F57 Level 5

                    Hi Mewk,

                     

                    Pity we can't just have some wonderful subliminal hypnotising thing that just downloads all the flex knowledge into our brains in 3 easy sessions at 99.99, but wait if you order in the next 30 minutes we will include the adobe creation suite knowledge pack for just 49.99 ring now , damn gotta stop having infomercials playing in the background while playing on the computer(stupid late night TV).

                     

                    I might have to go awol for a while as I am expecting the arrival of my new twins (big multi-touch screen, and multi touch google phone) so I can get into this new kewl flashplayer 10.1 stuff.

                     

                    David.