|
A fancier duplicator that uses random values for location, scale and alpha:
counter = 0;
duplicate_btn.onRelease = function() {
counter++;
star0_mc.duplicateMovieClip ("star"+counter+"_mc", counter);
_root["star"+counter+"_mc"]._y = Math.floor(Math.random()*100);
_root["star"+counter+"_mc"]._x = Math.floor(Math.random()*100);
_root["star"+counter+"_mc"]._alpha = Math.floor(Math.random()*100);
//Put the random value in a variable so its
//the same for both _yscale and _xscale
scaleVal = Math.floor(Math.random()*100);
_root["star"+counter+"_mc"]. _yscale = scaleVal;
_root["star"+counter+"_mc"]. _xscale = scaleVal;
};
NEW TRICK: Using _root and [ ] brackets to
work with variable names for object names.
This will work:
_root["myClip"+someVariable+"_mc"]. _someproperty
But this won't:
myClip"+someVariable+"_mc". _someproperty
|