A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: For Loop and Array onPress Assignments

Hybrid View

  1. #1
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    To answer your immediate question, you can create your own properties on buttons. I create a property called idx and use it to store the logoCount number.

    Then, within the event handler, you can use this.property to refer to the thing you stored.

    code:

    for (logoCount=1; logoCount<=6; logoCount++)
    {
    temp = eval("logo"+logoCount);
    temp.idx = logoCount; // store it here...
    temp.onRollOver = function()
    {
    scaleFactor[this.idx] = true;
    };
    temp.onRollOut = function() {
    scaleFactor[this.idx] = false;
    };
    }



    If it were me, I probably wouldn't store scaleFactor in a separate array, but would also assign scaleafactor to each individual button, just I'm doing with idx. I like to keep stuff associated with buttons or movieclips in the buttons or movieclips.

    code:

    for (logoCount=1; logoCount<=6; logoCount++)
    {
    temp = eval("logo"+logoCount);

    temp.onRollOver = function()
    {
    this.isScaling = true;
    };
    temp.onRollOut = function() {
    this.isScaling = false;
    };
    }

    Last edited by jbum; 10-21-2004 at 05:13 PM.

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