Results 1 to 2 of 2

Thread: using a loop to place objects in a row.

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default using a loop to place objects in a row.

    I am trying to place a three items in a row using a loop:

    Code:
    var placement:uint=100;
    var bullet:MovieClip;
    
    for(var i:Number = 0; i < 3; i++)
    	{trace(placement);
    		bullet=new Bullet();
    		bullet.x=placement;
    		bullet.y=placement+=10;
    		addChild(bullet);
    //placement+=10;
    		}
    It seems to be either displaying the three instances on top of eachother or only once -how do I get it to display as a group?

  2. #2
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Wink the answer. but one further question if anyone knows it

    Code:
    var placement:uint=100;
    var bullet:MovieClip;
    
    for(var i:Number = 0; i < 3; i++)
    	{//trace(placement);
    	
    		bullet=new Bullet();
    		//bullet.x=placement;
    		bullet.x = placement + i*(bullet.width+placement);
    		bullet.y+=5;
    		addChild(bullet);
    
    		}
    - would never have just guessed it outright but I have a further question

    I am trying to create a container that changes size as objects get added and removed from it.

Bookmarks

Posting Permissions

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