A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Placing instance names in an array?

  1. #1
    Senior Member
    Join Date
    Sep 2002
    Location
    Clogland
    Posts
    100
    I have a scene, two frames. There are two movie clips, blocks, with the instance names "block1" and "block2".

    The first frame has the actionscript:

    block1._alpha = block1._alpha - 5;
    block2._alpha = block2._alpha - 10;


    To keep things moving second frame has the actionscript:

    gotoAndPlay(1);

    This is what I am trying to achieve, block1 fades slower than block2, great.

    Enter the array.....

    I change the actionscript in frame one to:

    amount = array("5","10");
    block1._alpha = block1._alpha - amount[0];
    block2._alpha = block2._alpha - amount[1];

    This also works fine and dandy, the problem comes when I try and put the instance names (block1 and block2) into an array:

    block = array("block1","block2");
    block[0]._alpha = block[0]._alpha - 5;
    block[1]._alpha = block[1]._alpha - 10;

    No fade.

    Would it be that I am trying to do the impossible? Any comments or workarounds greatly appreciated



  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    use the absolute path for ex. _root.block1

    gparis

  3. #3
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,786
    Code:
    block = [block1, block2];
    block[0]._alpha = block[0]._alpha - 5; 
    block[1]._alpha = block[1]._alpha - 10;
    
    /*
    
    or
    
    block = ["block1", "block2"];
    this[block[0]]._alpha = this[block[0]]._alpha - 5; 
    this[block[1]]._alpha = this[block[1]]._alpha - 10;
    
    */

  4. #4
    Senior Member
    Join Date
    Sep 2002
    Location
    Clogland
    Posts
    100
    Edit: sorry, was trying two things at the same time........

    Thanks gSOLO_01, you hit the nail on the head with that second piece of code, I'm up and running.

    Many thanks, you guys are unbelievably quick.






    Old post................


    Thanks for the quick replies, but so far no dice.

    _root.block1._alpha = _root.block1._alpha - 5;

    ............works

    blockarray = array("_root.block1","_root.block2");

    blockarray[0]._alpha = blockarray[0]._alpha - 5;

    ............don't
    [Edited by skalie on 09-24-2002 at 11:25 AM]

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