# \[Ask: AS2\] Masking object dynamically

**URL:** <https://forum.kirupa.com/t/ask-as2-masking-object-dynamically/323044>\
**Category:** flash\
**Created:** [June 15, 2011, 6:57am UTC](https://forum.kirupa.com/t/ask-as2-masking-object-dynamically/323044 "2011-06-15T06:57:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sangjagoan](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@sangjagoan](https://forum.kirupa.com/u/sangjagoan)\
**Post date:** [June 15, 2011, 6:57am UTC](https://forum.kirupa.com/t/ask-as2-masking-object-dynamically/323044/1 "2011-06-15T06:57:57Z")

</div>

I have Particle animation like this this

```php
for(r=0;r<300;r++){
    Koord_x1=264;
    Koord_x2=500;
    Koord_y1=131;
    Koord_y2=311;
    ObjWidth=300;
    
    var myPellet:MovieClip;
    myPellet=_root.TheFlows.attachMovie("sPellet","oPellet_"+r,r);
    
    myPellet._x=Koord_x1+random(ObjWidth);
    myPellet._y=Koord_y1+random(ObjWidth);

    //speed
    yspeed = 25;

myPellet.onEnterFrame = function() {
    this._y += random(yspeed)//Math.random()*25;
    if (this._y>= Koord_y2) {
        this._y =Koord_y1;};}
}

```

But i want that Object moving in limited area or masked area.  
I add masked area like this

```php
var myMask:MovieClip;
    MyMask=_root.TheFlows.attachMovie("sStorageSilo","oStorageSilo",_root.TheFlows.getNextHighestDepth(),{_x:264,_y:131});
    myPellet.setMask(MyMask);

```

But it still not working. Any advice ?? or correction in my script code ?. Thanks in advance. MHz
