Home Flex For..in loop

Related Tutorials


 
 

Share on Google+Share on Google+

For..in loop

Advertisement
In this tutorial we will study for..in loop which is similar to for each loop

For..in loop

     

 

In this tutorial we will study for..in loop which is similar to for each loop
of C#, Java and other popular languages, in this example you will see how to display a list on a textbox on click event.

 

 

 

 

 

 



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   creationComplete="initApp()">
<mx:Script>
  <![CDATA[
 
    private var obj: Object=new Object();
 
    private function initApp():void
    {
    obj.a="Hello";
    obj.b="Hi";
    obj.c="Howdy";
    }
    public function dumpObj():void
    {
    for(var txt:String in obj)
    {
      newText.text+=txt+":"+obj[txt]+"\n";
    }
    }
  ]]>
</mx:Script> 
<mx:TextArea id="newText" width="293" height="58" x="52" y="46"/>
<mx:Button id="B" label="Click Me" click="dumpObj()" x="154" y="124"/>
</mx:Application>

   
  

  

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 3, 2006

Related Tutorials

Discuss: For..in loop  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com