Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading database records horizontally

Status
Not open for further replies.

zootweller

Technical User
Oct 7, 2001
46
GB
Hi

I'm creating a noticeboard system, whereby each record on a database is displayed in individual 'Card' image holders, and displayed in a grid system, containing a max number of 4 records per row. When the number of records to view (or cards) exceed 4 items, the board will carry the following records over to the next line, so the page eventually fills up as the database is filled.
Each records 'card' is approx. 170x170,

Anyone got any ideas how this can be acheived?

Cheers
 
Code:
// -----------------------------------------------
// Reset all variables
// -----------------------------------------------
n = 0;
x = 0;
y = 0;
// -----------------------------------------------
// Grid Setup (3 row * 4 column grid size)
// -----------------------------------------------
while (y < 3) {
    n++;
    // -----------------------------------------------
    // CREATE NEW CELL
    // -----------------------------------------------
    duplicateMovieClip(&quot;_root.card&quot;, &quot;card&quot; + n, n);
    // -----------------------------------------------
    // Move duplicated card to correct position
    // -----------------------------------------------
    _root[card + n]._x = 10 + (170 * x);
    _root[card + n]._y = 10 + (170 * y);
    // -----------------------------------------------
    // Check to see if there are more spaces in row
    // -----------------------------------------------
    if (Number(x) == 3) {
        y++;
        x = 0;
    } else {
        x++;
    }
}
Here's something to get you started. This script will use a template movieClip already in your _root (you can place it off the stage - that way it won't be seen) to make copies and place them in a grid format. the variable x controls the columns, y controls the rows, and n controls the depths. If you haven't used duplicateMovieClip() before, look it up in the HELP section in Flash.

As I said, this is just a start ... you can modify the above code to allow for better placement of the grid on the stage (at the moment the card grid will start in the top left corner), and you can add more rows or colums to your formation. If you need any more help, let me know. _____________________________________________________
Knowledge is attained only by seeking out that which is unknown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top