Tweening Dynamically attached MCs

Hi guys.
Need some help with a picture transition I am building using borrowed code from various tutorials. I am trying to make a grid with a dynamically attached clip(ball), use the grid as a mask for a picture(pic) and tween it forward on the press of a button (red):


import mx.transitions.easing.*;
import mx.transitions.Tween;
 
exp = function(mymc){
 new Tween(mymc,"_xscale",Strong.easeIn,mymc._xscale,300,3,true);
 new Tween(mymc,"_yscale",Strong.easeIn,mymc._yscale,300,3,true);
}
 
var PH = _root.createEmptyMovieClip("PH_mc", 0);
var ball:MovieClip;
var depth = 0;
 
for (var i=0; i < 100; i++) {
 for(var j=0;j< 100; j++){
    ball = PH.attachMovie("ball", "ball_"+ i + "_" + j,depth++); 
    ball._x = i*ball._width;
    ball._y = j*ball._height;
    }
}
red.onRelease = function(){
exp(ball);
}
pic.setMask(PH);
 

My problem is that I cannot get the grid to tween forward on pressing red. I have tried various other ways to call function exp with no success, although I have noticed that:


red.onRelease = function(){
exp(PH);
}

successfully tweens the container clip for the grid. Furthermore, I have noticed Flash 8 takes some time before testing the movie. Is my code inefficient?

Many thanks for any help.

Geminian1

Hi guys,
Did not get any reply unfortunately, but eventually trawled everywhere, huffed, puffed and stumbled on a formula courtesy Nuno Mira; I made the ball clip with my picture and attached the following code to it’s first frame:


import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var x0:Number = 0; // x position (upper left corner)
var y0:Number = 0; // y position (upper left corner)
var nr:Number = 12; // number rows
var nc:Number = 12; // number colums
var vd:Number = 50; // vertical distance between the mcs
var hd:Number = 50; // horizontal distance between the mcs
var s:Number = 0; // variable to hold names and depths
 
this.createEmptyMovieClip("pic",0);
 
for (var i = 1; i <= nr; i++) {
 for (var j = 1; j <= nc; j++) {
  s++;
  var mc = pic.attachMovie("square", "square" + s, s);
  mc._x = x0 + hd * (j - 1);
  mc._y = y0 + vd * (i - 1);
  new Tween(mc,"_xscale",Strong.easeInOut,mc._xscale,300,2,true);
  new Tween(mc,"_yscale",Strong.easeInOut,mc._yscale,300,2,true);
 }
}
this.setMask(pic);

I then dynamically attached the ball clip to the root timeline by pressing the red button:


red.onRelease = function(){
 _root.attachMovie("ball","ball",0);
 
}

Hope someone finds this useful.

Geminian1

I think that you prolly wanna use a depth other than 0…