# AS2 problem with dynamic masks... again!

**URL:** <https://forum.kirupa.com/t/as2-problem-with-dynamic-masks-again/298300>\
**Category:** flash\
**Created:** [October 16, 2009, 6:42am UTC](https://forum.kirupa.com/t/as2-problem-with-dynamic-masks-again/298300 "2009-10-16T06:42:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![charco](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@charco](https://forum.kirupa.com/u/charco)\
**Post date:** [October 16, 2009, 6:42am UTC](https://forum.kirupa.com/t/as2-problem-with-dynamic-masks-again/298300/1 "2009-10-16T06:42:41Z")

</div>

Hello it’s me again still struggling with a project. I decided to try to use setInterval for myanimation, which is just a mouse trail. However, I’m trying to get teh mouse trail to be a dynamic mask. In my previous swf this was achieved by using a holder mc with the animation inside and then using this as the mask. But this time I just canpt seem to hit on the right way to get it to work. The code I am using for the mouse trail is:

```auto
var i:Number = 0;
var myInt:Number;
var t:MovieClip;
_root.createEmptyMovieClip('holder',_root.getNextHighestDepth());
bg.cacheAsBitmap = true;
holder.cacheAsBitmap = true;
function init() {
 t=attachMovie('star', 'star'+i, i, {_x:_xmouse, _y:_ymouse});
 t._x = _xmouse;
 t._y = _ymouse;
 t._xscale = t._yscale=10;
 t.onEnterFrame = function() { 
  bg.setMask(holder);
  this._x += (-5+Math.random()*6);
  this._y += (-5+Math.random()*6);
  this._rotation += (-2+Math.random()*3);
  this._xscale = this._yscale += 2;
  this._alpha -= 5;
 };
 if (i<20) {
  i++;
 } else {
  i = 0;
 }
}
myInt = setInterval(init, 70);

```

You’ll see that I haven’t got the holder doing anything except existing as an empty mc.  
The code above works great for a simple mouse trail with a bit of drift.  
The problem is when I try to ‘put it in’ a holder everything breaks down. I’ve studied the code I used last time but am getting nowhere after 24 hours. So here I am again throwing myself at the mercy of the forums.  
I tried:

```auto
function init() {
 holder.t=attachMovie('star', 'star'+i, i, {_x:_xmouse, _y:_ymouse});
 holder.t._x = _xmouse;
 holder.t._y = _ymouse;
 holder.t._xscale = holder.t._yscale=10;
 holder.t.onEnterFrame = function() { 
  bg.setMask(holder);
  this._x += (-5+Math.random()*6);
  this._y += (-5+Math.random()*6);
  this._rotation += (-2+Math.random()*3);
  this._xscale = this._yscale += 2;
  this._alpha -= 5;
 };
 if (i<20) {
  i++;
 } else {
  i = 0;
 }
}

```

in the function, but now the trail doesn’t resize and the mask still doesn’t work. ☹

Any ideas, oh great ones?
