Skip to main content
Inspiring
April 24, 2013
Answered

Tween an array Item

  • April 24, 2013
  • 1 reply
  • 717 views

I built a script that will have movieclips populate the stage. In this case a leaderboard.

each movieclip created is positioned and put into an Array.

The problem is getting an array item and being able to tween it

*i'd like to experiment with different tween combinations to get them off the stage. Here is what I got

I'm able to get the clips on the stage...Can't get them off =]

import mx.transitions.Tween;

import mx.transitions.easing.*;

 

Block = new Array();

var Xposition:Number = 0;

var Yposition:Number = 0;

var stack:Number=Math.ceil(Stage.height/30);

var Numofstacks:Number=Math.ceil(Stage.width/30);

var fadeit:Tween;

var n:Number = 0;

for (r=0; r<(Numofstacks); r++) // 25

{

          Yposition=0;

                    for (c=0; c<(stack); c++) // 3

                    {

                              var particle = this.attachMovie("block","block_"+r+c ,this.getNextHighestDepth());

                              particle._y = Yposition

                              particle._x = Xposition

                              Block = particle._name;

                              //trace(particle._name)

                              Yposition = Yposition + 30;

                              n++

 

                    }

                    Xposition=Xposition+30

 

}

var runit = setInterval(effcts, 3000)

function effcts ():Void

{

          trace("go")

          //for (a=0; c<(Block.length - 1); a++) // 3

                    //{

 

                              fadeit = new Tween(Block[0], "_alpha", Strong.easeOut, 100, 0, 1.5, true);

                    //}

clearInterval(runit);

}

This topic has been closed for replies.
Correct answer Ned Murphy

Don't store the _name property in the array, store the particle itself.

Block = particle;

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 24, 2013

Don't store the _name property in the array, store the particle itself.

Block = particle;

JonnyDLAuthor
Inspiring
April 28, 2013

Thanks Ned....

I've built the script to scale and fade out (from left to right)the MCs, but I'm having trouble with masking (using these MCs). Manually I have text on the stage and a movie clip over it, Place a mask on the MC it only shows the text I want.

I try and do it with AS2 and it dosen't work ( particle.setMask(text) ). the text is dynamic, dose it need to be MC? what am I doing wrong.

Ned Murphy
Legend
April 28, 2013

With dynamic text in an animnated or masked environment you need to embed the font in the textfield.  You might get better results if you manipulate movieclips as well.