dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [F8] using an array to load images into thumbnails

  1. #1
    Junior Member
    Join Date
    Jun 2004
    Posts
    7

    [F8] using an array to load images into thumbnails

    I am new to arrays.

    I am generating thumbnails based on the length of an Array. The array looks something like this (tree.jpg, ant.jpg, fish.jpg, etc) I need to load those images into the thumbnails I have created. I am using the following code:

    var spacing:Number = 10;
    var rows:Number = _parent._parent._parent.numberOfFiles; //my array length
    var columns:Number = 1;
    var myDepth:Number = 1;

    // double-loop which will do the creating and placing of the MC's
    for (i=0; i<rows; i++) {
    for (j=0; j<columns; j++) {
    //set the x and y values before setting the new imageName
    var x:Number = i*(this[imageName]._width+spacing);
    var y:Number = j*(this[imageName]._height+spacing);
    //set the new imageName for this loop run
    var imageName:String = "image"+i+"_"+j;
    //increase the depth value before attaching
    myDepth++;
    //attach a clip
    this.attachMovie("thumbnail", imageName, myDepth);
    //place the new clip using the x and y

    //values calculated at the start of the loop
    this[imageName]._x = x;
    this[imageName]._y = y;
    }
    }

    how do I load them into the thumbnails?

    thanks in advance!!!

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Could it be this:
    code:

    var spacing:Number = 10;
    var rows:Number = _parent._parent._parent.numberOfFiles;//my array length
    var columns:Number = 1;
    var myDepth:Number = 1;

    var k:Number = 0; // added

    // double-loop which will do the creating and placing of the MC's
    for (i=0; i<rows; i++) {
    for (j=0; j<columns; j++) {
    //set the x and y values before setting the new imageName
    var x:Number = i*(this[imageName]._width+spacing);
    var y:Number = j*(this[imageName]._height+spacing);
    //set the new imageName for this loop run
    var imageName:String = "image"+i+"_"+j;
    //increase the depth value before attaching
    myDepth++;
    //attach a clip
    this.attachMovie("thumbnail",imageName,myDepth);
    //place the new clip using the x and y

    //values calculated at the start of the loop
    this[imageName]._x = x;
    this[imageName]._y = y;

    // added
    this[imageName].loadMovie(theArray[k]);
    k++;
    }
    }


    Notice that theArray is the path to the array which has the files' names.

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