0 Replies Latest reply on Feb 1, 2010 9:52 PM by venkateshk

    Area and Volume

    venkateshk Level 1

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="silver">
          <mx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  private function btnCall():void
                  {
                      if(combo.selectedItem == "A")
                      {
                          var len:Number = parseFloat(tiLength.text);
                          var wid:Number = parseFloat(tiWidth.text);
                          var hei:Number = parseFloat(tiHeight.text);
                          var volume:Number = (len*wid*hei);
                          var tot:Number = (a.height*a.width);
                      }
                  }
              ]]>
          </mx:Script>
          <mx:VBox x="5" y="5" verticalGap="0" id="vb">
              <mx:HBox horizontalGap="0">
                  <mx:Canvas id="a" borderStyle="solid" width="300" height="300" borderThickness="2" borderColor="black"/>
                  <mx:VBox width="15" backgroundColor="yellow" height="300"/>
                  <mx:Canvas id="b" borderStyle="solid" borderThickness="2" width="600" height="300" borderColor="black"/>
                  <mx:VBox width="15" backgroundColor="yellow" height="300"/>
                  <mx:Canvas id="c" borderStyle="solid" borderThickness="2" width="300" height="300" borderColor="black"/>
              </mx:HBox>
              <mx:HBox height="15" width="{vb.width}" backgroundColor="yellow"/>
              <mx:HBox horizontalGap="0">
                  <mx:Canvas id="d" borderStyle="solid" width="300" height="300" borderThickness="2" borderColor="black"/>
                  <mx:VBox width="15" backgroundColor="yellow" height="300"/>
                  <mx:Canvas id="e" borderStyle="solid" borderThickness="2" width="600" height="300" borderColor="black"/>
                  <mx:VBox width="15" backgroundColor="yellow" height="300"/>
                  <mx:Canvas id="f" borderStyle="solid" borderThickness="2" width="300" height="300" borderColor="black"/>
              </mx:HBox>
          </mx:VBox>
         
          <mx:HBox x="300" y="{Application.application.height-50}">
              <mx:ComboBox id="combo" dataProvider="{['A','B','C','D','E','F']}"/>
              <mx:Label text="Length :" fontWeight="bold" fontSize="13"/>
              <mx:TextInput id="tiLength" width="40"/>
              <mx:Label text="Width :" fontWeight="bold" fontSize="13"/>
              <mx:TextInput id="tiWidth" width="40"/>
              <mx:Label text="Height :" fontWeight="bold" fontSize="13"/>
               <mx:TextInput id="tiHeight" width="40"/>
              <mx:Button id="btn" label="Click" click="btnCall()"/>
          </mx:HBox>

      </mx:Application>

       

      This will give different canvases for me

      If I select 'A' from combo and give some values in tiLength,tiWidth,tiHeight then click on Click button

      then I want to calculate the volume from input values and highlight area in canvas 'a' with color based on the the percentage of volume which I calculated from input values In this way I want to fill the total area of the canvas 'a' if i give some other values at next time and if it filup totally then it should show alert that tere is no space

      Please help............. me

      urgent