Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-09-2005, 12:45 AM   #1
uni009
Registered User
 
Join Date: Dec 2005
Posts: 2
Default [flash 8]sort movieclips into columns...

PHP Code:
var i:Number 0;
function 
goMe(){ 
if (
>= myArray.length){
    
clearInterval(myInterval);
    
i="0";
    }
eval(
myArray[i].instance).slideTo(0,i*myArray[i].instance._height,1,"easeOutBounce");
i++;

i'm using this code to cycle through an array and move the movie clips to x:0, and y:height of clip, times whatever number it is.... if there are 4 objects in the array, object 1 would be 1 times it's own height.... etc... so they're spaced out.


however, when i resize my stage, i'd like to have them arrange differently... into columns... but i'm not sure how to specify breaking them off into columns. i tried something like this:
PHP Code:
var cCount:Number 2;
var 
rCount:Number 1;
function 
goMe2(){ 
//number of columns to make

//number of rows in each column

//height of each item in row
var itemHeight:Number myArray[1].instance._height;
//width of each column
var colWidth:Number myArray[1].instance._width;
if (
>= myArray.length){
    
clearInterval(myInterval);
    
i="0";
    
rCount=0;
    }
    if(
rCount<="2"){
eval(
myArray[i].instance).slideTo(0,rCount*itemHeight,1,"easeOutBounce");
    
rCount++;
    
i++;
    }else{
eval(
myArray[i].instance).slideTo(cCount*colWidth,cCount*rCount,"easeOutBounce");
    
rCount++;
    
i++;
    }

... but it didn't sort correctly

you can see what i mean here: http://www.ericgibb.com/sd.html
uni009 is offline   Reply With Quote
Old 12-09-2005, 07:43 AM   #2
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

One option is to have a nested for loop to set coordinates, and just use a counter variable to go through the array.

PHP Code:
counter=0;
for(
i=0;i<Math.ceil(myarray.length/2);i++){
    for(
j=0;j<2;j++){
        if(
counter<myarray.length){
            
with(myarray[counter]){
                
_y=i*ygap;
                
_x=j*xgap;
            }
            
counter++;
        }
    }

Of course substituting the _x and _y functions with whatever specifically you wanted for setting coordinates, but the point is to use i for establishing the row, while j to establish the column.
Assertnfailure is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
collect all movieclips on timeline IonRod ActionScript 2.0 0 07-20-2005 06:31 PM
Returning movieclips in a scene Tony Nibbles ActionScript 2.0 2 11-23-2004 11:04 AM
DataGrid and limiting columns jkemrich Components 1 12-30-2003 06:00 PM
randomising movieclips in an array snilbert Simple Stuff (Newbies) 2 07-10-2003 02:59 PM
dynamically creating columns of text octothorp Simple Stuff (Newbies) 0 03-04-2002 04:22 PM


All times are GMT. The time now is 09:09 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.