A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] limit items on a row

  1. #1
    Senior Member
    Join Date
    Jan 2004
    Location
    NZ
    Posts
    100

    resolved [RESOLVED] limit items on a row

    I am trying to load MC's from an array but I need to make it so that after ever 2 MC's the Yposition changes down say 300px so that I have a new line. I have tried using if(see at the bottom of this script.) bellow but it doen't work. Can someone please help me out I need this urgently my dead line is in like 5hrs!


    this is what I have atm.


    Code:
    Code:
    var selectedMensShirts:Array = loadShirts();
    
    
    var itemX:Number = 500; // initial item x position
    var itemY:Number = 100; // initial item y position
    var item2X:Number = 500; // initial item x position
    var item2Y:Number = 0; // initial item y position
    
    
    for each( var shirtName:String in selectedMensShirts )
    {
        var item:DisplayObject = null;
    
    
        if( shirtName == "mYellow" )
        {
          item = new yellow();
    item.addEventListener(MouseEvent.MOUSE_OVER, yellowOver);
         function yellowOver(e:MouseEvent):void {
    menshirt.gotoAndStop(3);
         }
    
    
       item.addEventListener(MouseEvent.MOUSE_OUT, yellowOut);
         function yellowOut(e:MouseEvent):void {
    menshirt.gotoAndStop(1);
    
    
     }
        }
        else if( shirtName == "mBlue" )
        {
           item = new blue();
        item.addEventListener(MouseEvent.MOUSE_OVER, blueOver);
         function blueOver(e:MouseEvent):void {
    menshirt.gotoAndStop(5);
         }
    
    
       item.addEventListener(MouseEvent.MOUSE_OUT, blueOut);
         function blueOut(e:MouseEvent):void {
    menshirt.gotoAndStop(1);
    
    
     }
        }
        else if( shirtName == "mBlack" )
        {
            item = new black();
        item.addEventListener(MouseEvent.MOUSE_OVER, blackOver);
         function blackOver(e:MouseEvent):void {
    menshirt.gotoAndStop(4);
         }
    
    
       item.addEventListener(MouseEvent.MOUSE_OUT, blackOut);
         function blackOut(e:MouseEvent):void {
    menshirt.gotoAndStop(1);
    
    
     }
        }
         else if( shirtName == "mWhite" )
        {
            item = new white(); 
           item.addEventListener(MouseEvent.MOUSE_OVER, whiteOver);
         function whiteOver(e:MouseEvent):void {
    menshirt.gotoAndStop(2);
         }
    
    
       item.addEventListener(MouseEvent.MOUSE_OUT, whiteOut);
         function whiteOut(e:MouseEvent):void {
    menshirt.gotoAndStop(1);
    
    
     }
        }
            if( item != null )
        {
            addChild( item );
            item.x = itemX;
            item.y = itemY;
    
    
            itemX += item.width + 20; // 20 = space between items
        }
                if( item.x >= 300 )                 //If I could do something like this but working where if ItemX is greater than 300 px it will use Item 2.
         {
            addChild( item2 );
            item2.x = item2X;
            item2.y = item2Y;
    
            item2X += item2.width + 20; // 20 = space between items 
        }
    }
    Last edited by Raging Tempist; 11-07-2009 at 07:25 AM.

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Senior Member
    Join Date
    Jan 2004
    Location
    NZ
    Posts
    100
    thanx man

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