A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Order of returned Object.prop

  1. #1
    Senior Member LeoBeer's Avatar
    Join Date
    May 2002
    Posts
    315

    Order of returned Object.prop

    I have a class which accepts an object and then outputs the names and values of it's properties

    Code:
    class ReaderClass
    {
    	
    	function ReaderClass ()
    	{
    	}
    	//-----------------------------------------------------------------
    	function getObjectProps (var_objectToExplore:Object)
    	{		
                    var objectToExplore = var_ objectToExplore
    		for(var prop in objectToExplore)
    		{
    			trace ("prop: " + prop)
    		}
    	}
    }
    now I am using the following code to create a new object:

    Code:
    class NewClass{
    
    var someProp0
    	var someProp1
    	var someProp2
    	var someProp3
    
    	function NewClass(){
    
    
    		someProp0 = new String();
    		someProp1 = new String();
    		someProp3 = new String();
    		someProp2 = new String();
    	}
    }
    an instance of NewClass is being sent to be explored by ReaderClass:

    Code:
    myReaderClass.getObjectProps(myNewClass);
    this will return the properties in the following order:

    prop: someProp2
    prop: someProp3
    prop: someProp1
    prop: someProp0

    and my question is:

    Can I be certain that the once running the myReaderClass.getObjectProps() on any class instance the
    Properties will always be returned in the order shown above? (n, n-1, n-2…..)

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Currently they should be, the for ... in loop will always work through the items in order from the newest to the oldest.

    I don't know if this would change in future versions of flash player, but I think it would be very unlikely.

  3. #3
    Senior Member LeoBeer's Avatar
    Join Date
    May 2002
    Posts
    315
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center