1 Reply Latest reply on Jan 31, 2011 6:00 AM by _spoboyle

    Setting and getting ActionScript Flag value

    kiran7881 Level 1

      Hi ,

      I have  a Actionscript class

       

      package util
      {
         
      public  class Flag
          {  
           public var viewNamesample:String;
          public function getFlagvalue():String {   
              return viewNamesample;
              }
         
          
          }
      }

       

      In one of my MXML File , i am making use of this above Actionscript class and setting its  value as

       

      <mx:script>
      public var flag:Flag = new Flag() ;

      if()
          flag.viewNamesample = "One";

       

      else
      flag.viewNamesample = "Two";

      </mx:script>

       

      How can i access this flag.viewNamesample value in my another MXML File ??

       

      Please tell me .

        • 1. Re: Setting and getting ActionScript Flag value
          _spoboyle Level 4

          it's hard to know exactly what you are trying to achieve but maybe this will point you in the right direction

           

          <?xml version="1.0" encoding="utf-8"?>
          <!-- http://blog.flexexamples.com/2007/10/26/customizing-the-accordion-header-in-flex-3/ -->
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                          layout="vertical"
                          verticalAlign="top"
                          backgroundColor="white" xmlns:local="*">
             
              <mx:Script>
                  <![CDATA[
                      [Bindable]
                      public var flag:Flag = new Flag();

           

                      protected function button1_clickHandler(event:MouseEvent):void
                      {
                          flag.viewNamesample = "One";
                      }
                     
                      protected function button2_clickHandler(event:MouseEvent):void
                      {
                          flag.viewNamesample = "Two";
                      }

           

                  ]]>
              </mx:Script>
             
              <mx:VBox>
                  <local:MyCanvas id="myCanvas" flag="{flag.viewNamesample}"/>
                  <mx:Button click="button1_clickHandler(event)"/>
                  <mx:Button click="button2_clickHandler(event)"/>
              </mx:VBox>
             
          </mx:Application>

           

          package
          {
              public  class Flag
              { 
                  [Bindable]
                  public var viewNamesample:String;
                 
                  public function getFlagvalue():String {  
                      return viewNamesample;
                  }
                 
                 
              }
          }

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
             
              <mx:Script>
                  <![CDATA[
                      [Bindable]
                      public var flag:String;
                  ]]>
              </mx:Script>
             
              <mx:Label id="myLabel" text="{flag}"/>
             
          </mx:Canvas>