13 Replies Latest reply on Aug 4, 2009 11:51 PM by hitesh.rawat

    Variables?????

    hitesh.rawat Level 1

      Can we create variables in Flex which can hold values like string or interger?????????????

       

      regards

      H.R.

        • 1. Re: Variables?????
          Richard_Abbott Level 3

          HR,

          yes you can. The basic syntax is

          var my_string_variable: String;

          var my_int_variable: int;

          etc

          These variables obey the usual programming rules for scope and visibility. For variables with class scope you can mark them as private/protected/public so as to define what users outside the class can see: within a method handler you should not use these.

          Richard

          • 2. Re: Variables?????
            hitesh.rawat Level 1

            I'm sorry i think i wrote it wrong.............

            i wanted to ask if we can create variables in the MXML part of the Flex...... i know about the AS3.....

             

            thanks for the reply....

             

            Regards

            H.R.

            • 3. Re: Variables?????
              juniorJaffa

              Maybe I mistake, but according my experience at Flex and coding you can not create variables at MXML part, but why you should do it???....when you create bindable variable at Script part and simply calls this variable at MXML part!
              Just correct my if I replied wrong,but surely not...

              • 4. Re: Variables?????
                Brent Lamborn Level 2

                Of course:

                 

                <mx:Number />

                <mx:String />

                • 5. Re: Variables?????
                  hitesh.rawat Level 1

                  Well binding i think can help........

                   

                  I have a xml file which has source for swiff files which are binded to a List which shows them as options. Then there is play button which plays the swiff files in a SWFLoader.

                   

                  I wanted to bind that source field in xml file to the source property of the SWFLoader. So that the file can be played by clicking PLAY button.

                   

                  Regards

                  H.R.

                  • 6. Re: Variables?????
                    Brent Lamborn Level 2

                    Ok well that is entirely different than your original question. Actually, what you are asking indicates that you don't understand the fundamentals of Flex. I'd suggest you start here:

                     

                    http://learn.adobe.com/wiki/display/Flex/Get+oriented+to+Flex

                     

                    Work through some of the examples. In the days you have been replying in this forum post, you could have easily learned how to do this by now.

                    • 7. Re: Variables?????
                      hitesh.rawat Level 1

                      i read the content and also found some other examples.........then tried again..........

                       

                       

                       

                      <!-- The Options List -->
                          <mx:List id="optionList" dataProvider="{swfList.video}"
                             
                              labelField="@title"
                              selectedIndex="0"
                              selectable="true"
                            
                               width="226"></mx:List>

                       

                       

                      <!--Swiff Loader Frame-->
                              <mx:SWFLoader x="10" y="10" width="569" height="600" id="loader" autoLoad="false" resize="true" scaleContent="true"

                             source="{optionList.selectedItem.@source}">
                                 
                              </mx:SWFLoader>

                       

                      The name of the xml is --- swf.xml

                       

                      Issue is this doesn't load the swf.....i think i have binded the properties well........not sure of that too............

                       

                      Thanks

                      H.R.

                      • 8. Re: Variables?????
                        hitesh.rawat Level 1

                        help with this...................

                        • 9. Re: Variables?????
                          Gregory Lafrance Level 6

                          This page answers your question:

                           

                          http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html

                           

                          If this post answers your question or helps, please mark it as such.

                          • 10. Re: Variables?????
                            hitesh.rawat Level 1

                            well......i have gone through this doc earlier........ but wasn't able to find relative information........being new to this language and trying to create something simultaneouly on the same language is creating this issue cause its not helping me developing concept here.............

                             

                            i'd appriciate if you can tell me ....... how can i bind the source property of a SWFloader with a source field of the selected item in a list where the data provider is external XML file.

                             

                            thanks

                             

                            H.R.

                            • 11. Re: Variables?????
                              hitesh.rawat Level 1

                              <!-- The Options List -->
                                  <mx:List id="optionList" dataProvider="{swfList.video}"
                                     
                                      labelField="@title"
                                      selectedIndex="0"
                                      selectable="true"
                                    
                                       width="226"></mx:List>

                               

                               

                              <!--Swiff Loader Frame-->
                                      <mx:SWFLoader x="10" y="10" width="569" height="600" id="loader" autoLoad="false" resize="true" scaleContent="true"

                                     source="{optionList.selectedItem.@source}">
                                         
                                      </mx:SWFLoader>

                               

                              XML-swfList.xml is the XML file carrying data..............

                               

                              i want to bind the Source property of XML childtag's  with the source property of the SWFplayer for the item selected in the list.


                              Help me with this. What need to be done?

                               

                              Appriciate it.

                              • 12. Re: Variables?????
                                Gregory Lafrance Level 6

                                There are a variety of moving parts in your case (XML loaded, SWFLoader, etc.) so to an answer quickly, you should post simplified yet complete code that shows your data XML file (complete yet simplified), how you are loading the XML file, and everything else that is relevant, such as your SWFLoader, etc.

                                 

                                Without this I know I cannot continue to monitor this post, but with that provided I believe an answer will come soon.

                                • 13. Re: Variables?????
                                  hitesh.rawat Level 1

                                  This is the code which i'm have tried with.......but couldn't get through. i want it to pick the source property of the selected item from the XML.....and then play it as we click the play button

                                   

                                  __________________________________________________________________________________________ _________

                                   

                                   

                                   

                                  <?xml version="1.0" encoding="utf-8"?>
                                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                                     
                                  <mx:Script>
                                      <![CDATA[
                                         
                                          public function settingSource(mourseEvent:MouseEvent):String
                                          {
                                         
                                          return optionList.selectedItem.source ;
                                         
                                          }
                                      ]]>
                                  </mx:Script>

                                   

                                     
                                     
                                      <!-- Connecting XML -->
                                     
                                     
                                      <mx:XML id="swfList" source="swf.xml" xmlns=""/>
                                     
                                     
                                      <!-- The Swiff panel-->
                                     
                                      <mx:Panel x="405" y="52" width="609" height="706" layout="absolute" title="The Swiff Loader" id="loaderPanel" horizontalAlign="left">
                                         
                                          <!--Swiff Loader Frame-->
                                          <mx:SWFLoader x="10" y="10" width="569" height="600" id="loader" autoLoad="false" resize="true" scaleContent="true"

                                             
                                             
                                              >
                                             
                                          </mx:SWFLoader>
                                         
                                          <!-- Play Button -->
                                          <mx:Button x="48" y="618" label="Play" width="87" height="38" id="playButton" labelPlacement="left" enabled="true"
                                             
                                              click="loader.load()"
                                              />
                                     
                                     
                                     
                                      </mx:Panel>
                                     
                                     
                                      <!-- The Options List -->
                                      <mx:List x="36" y="166" height="181" id="optionList" dataProvider="{swfList.video}"
                                         
                                          labelField="@title"
                                         
                                          showDataTips="true"
                                          allowMultipleSelection="false"
                                         
                                          click="optionList.selectedItem.@source = loader.source"
                                         
                                           width="226"></mx:List>
                                     
                                  </mx:Application>