A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Help with Controlling an Array

  1. #1

    [F8] Help with Controlling an Array

    Hi all,
    I have an Array and I want to "turn on" one of the elements and "turn off" the rest of the elements. The element I want to turn on will vary in the array. There are about say 15 elements in the array.

    Any insights for this rookie question?

    All my attempts seem to end when the element is found. Can't seem to wrap my head around this...

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    more info and some code required

  3. #3
    Senior Member
    Join Date
    Aug 2000
    All i can say with what info you gave is: use a for loop.


  4. #4
    Sorry...yeah, some code would help:

    This is what I came up with that doesn't seem to be working. I've renamed some things for easier understanding.


    chapmanBoxes = new Array(box_1 box_2, box_3, box_4);

    function peel(keepNumber, whatBoxes)
    for (i = 0; i < whatBoxes.length; i++)
    if (i == keepNumber)

    myButton1.onRollOver = function()
    chapmanBoxes[1].attachMovie("mainPeel", "mainPeel", 1);

    chapmanBoxes[1].mainPeel._x = 103.5;
    chapmanBoxes[1].mainPeel._y = -19.6;

    peel(1, chapmanBoxes);

    myButton2.onRollOver = function()
    chapmanBoxes[2].attachMovie("mainPeel", "mainPeel", 2);

    chapmanBoxes[2].mainPeel._x = 103.5;
    chapmanBoxes[2].mainPeel._y = -19.6;

    peel(2, chapmanBoxes);


    Basically what I want to have happen is to have the corner of the box you RollOver/RollOut "peel" in and out. I have a function for that that isn't shown but works. The peel is a MC in the library called 'mainPeel' that is attached.

    The function 'peel' is meant to peelIn the intended box and peelOut the rest. But what ends up happening is only the last element in the array wants to work.

    I'm still trying to learn actionscripting so my approach might've been a total hackjob, but any help is greatly appreciated.

    Last edited by mrtibbs; 06-06-2007 at 10:57 AM.

  5. #5

    I figured out what I was doing wrong...and I don't have to do any looping code.

    In my peelIn function (that isn't shown)...I had been doing this.onEnterFrame...instead of using the MCpath.onEnterFrame. It makes all the difference.

    Best feeling in the world when the code you've been struggling with for 2 days finally works.

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