# scale9Grid and masking problem

**URL:** https://forum.kirupa.com/t/scale9grid-and-masking-problem/205484
**Category:** flash
**Created:** [October 30, 2006, 5:37am UTC](https://forum.kirupa.com/t/scale9grid-and-masking-problem/205484 "2006-10-30T05:37:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![apexroom](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@apexroom](https://forum.kirupa.com/u/apexroom)
#### Post date: [October 30, 2006, 5:37am UTC](https://forum.kirupa.com/t/scale9grid-and-masking-problem/205484/1 "2006-10-30T05:37:54Z")

</div>

first of all … thank you very much for your interest

the following actionscript 2.0 code for simple reveal effect applied on a movieclip …  
movie has curved corners and loaded image …  
I’m tring to scale the border and the image mask within that movie while rolling over regardless of which regions of the 4 corners using [COLOR=royalblue] **scale9Grid** [/COLOR] class …  
well … the border does scale properly, **but**  **the mask**  **does not !**

the only conclusion I’ve got that the mask movie [COLOR=royalblue] **does** [/COLOR] scale properly when [COLOR=royalblue] **disable** [/COLOR] masknig !  
any help please ?

[COLOR=gray]// importing nesessary classes //[/COLOR]  
[COLOR=royalblue]import flash.geom.Rectangle[/COLOR];  
[COLOR=royalblue]import mx[/COLOR].transitions.Tween;  
[COLOR=royalblue]import mx[/COLOR].transitions.Tween.easing.\*;

[COLOR=gray]// API drawing engine //[/COLOR]  
[COLOR=royalblue]function[/COLOR] drawRec(mc:[COLOR=royalblue]MovieClip[/COLOR], side:[COLOR=royalblue]Number[/COLOR], corner:[COLOR=royalblue]Number[/COLOR], stroke:[COLOR=royalblue]Number[/COLOR], fill:[COLOR=royalblue]Number[/COLOR]) {  
[COLOR=royalblue]if[/COLOR] (fill != [COLOR=royalblue]undefined[/COLOR]) {  
mc.[COLOR=royalblue]beginFill/COLOR;  
}  
mc.[COLOR=royalblue]lineStyle[/COLOR](5, stroke);  
mc.[COLOR=royalblue]moveTo[/COLOR](-side+corner, -side);  
mc.[COLOR=royalblue]lineTo[/COLOR](side-corner, -side);  
mc.[COLOR=royalblue]curveTo[/COLOR](side, -side, side, -side+corner);  
mc.[COLOR=royalblue]lineTo[/COLOR](side, side-corner);  
mc.[COLOR=royalblue]curveTo[/COLOR](side, side, side-corner, side);  
mc.[COLOR=royalblue]lineTo[/COLOR](-side+corner, side);  
mc.[COLOR=royalblue]curveTo[/COLOR](-side, side, -side, side-corner);  
mc.[COLOR=royalblue]lineTo[/COLOR](-side, -side+corner);  
mc.[COLOR=royalblue]curveTo[/COLOR](-side, -side, -side+corner, -side);  
[COLOR=royalblue]if[/COLOR] (fill != [COLOR=royalblue]undefined[/COLOR]) {  
mc.[COLOR=royalblue]endFill/COLOR;  
}  
}

[COLOR=gray]// creating test movie holder //[/COLOR]  
[COLOR=royalblue]this[COLOR=black].[/COLOR]createEmptyMovieClip[/COLOR]([COLOR=green]"\_box"[/COLOR], 1);  
\_box.[COLOR=royalblue]\_x[/COLOR] = [COLOR=royalblue]Stage[/COLOR].[COLOR=royalblue]width[/COLOR]/2;  
\_box.[COLOR=royalblue]\_y[/COLOR] = [COLOR=royalblue]Stage[/COLOR].[COLOR=royalblue]height[/COLOR]/2;

[COLOR=gray]// creating border within movie holder //[/COLOR]  
\_box.[COLOR=royalblue]createEmptyMovieClip[/COLOR]([COLOR=green]"\_brd"[/COLOR], 3);  
drawRec(\_box.\_brd, 100, 20, 0xA8A8A8);

[COLOR=gray]// creating mask for image container //[/COLOR]  
\_box.[COLOR=royalblue]createEmptyMovieClip[/COLOR]([COLOR=green]"\_msk"[/COLOR], 2);  
drawRec(\_box.\_msk, 95, 18, 0xA8A8A8, 0xA8A8A8);

[COLOR=gray]// creating image container //[/COLOR]  
\_box.[COLOR=royalblue]createEmptyMovieClip[/COLOR]([COLOR=green]"\_img"[/COLOR], 1);

[COLOR=gray]// loading image //[/COLOR]  
[COLOR=royalblue]var[/COLOR] img\_lodr:[COLOR=royalblue]MovieClipLoader[/COLOR] = [COLOR=royalblue]new[/COLOR] [COLOR=royalblue]MovieClipLoader/COLOR;  
[COLOR=royalblue]var[/COLOR] img\_lsnr:[COLOR=royalblue]Object[/COLOR] = [COLOR=royalblue]new[/COLOR] [COLOR=royalblue]Object/COLOR;  
img\_lsnr.[COLOR=royalblue]onLoadInit[/COLOR] = [COLOR=royalblue]function/COLOR {  
target.[COLOR=royalblue]\_x[/COLOR] = -(target.[COLOR=royalblue]\_width[/COLOR]/2);  
target.[COLOR=royalblue]\_y[/COLOR] = -(target.[COLOR=royalblue]\_heigh[/COLOR]t/2);  
target.[COLOR=royalblue]setMask/COLOR; [COLOR=gray]// commenting this line shows proper mask[/COLOR][COLOR=gray] scaling ![/COLOR]  
};  
img\_lodr.[COLOR=royalblue]addListener/COLOR;  
img\_lodr.[COLOR=royalblue]loadClip[/COLOR]([COLOR=green]“image.jpg”[/COLOR], \_box.\_img);

[COLOR=gray]// enable 9-slice scaling for border and mask only //[/COLOR]  
[COLOR=royalblue]var[/COLOR] grid:[COLOR=royalblue]Rectangle[/COLOR] = [COLOR=royalblue]new[/COLOR] [COLOR=royalblue]Rectangle[/COLOR](0, 0, 30, 30);  
\_box.\_brd.[COLOR=royalblue]scale9Grid[/COLOR] = grid;  
\_box.\_msk.[COLOR=royalblue]scale9Grid[/COLOR] = grid;

[COLOR=gray]// assign scaling events for movie holder //[/COLOR]  
\_box.[COLOR=royalblue]onRollOver[/COLOR] = [COLOR=royalblue]function/COLOR {  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_brd, [COLOR=green]"\_xscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_xscale[/COLOR], 200, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_brd, [COLOR=green]"\_yscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_yscale[/COLOR], 200, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_msk, [COLOR=green]"\_xscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_xscale[/COLOR], 200, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_msk, [COLOR=green]"\_yscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_yscale[/COLOR], 200, .5, [COLOR=royalblue]true[/COLOR]);  
};  
\_box.[COLOR=royalblue]onRollOut[/COLOR] = [COLOR=royalblue]function/COLOR {  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_brd, [COLOR=green]"\_xscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_xscale[/COLOR], 100, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_brd, [COLOR=green]"\_yscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_yscale[/COLOR], 100, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_msk, [COLOR=green]"\_xscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_xscale[/COLOR], 100, .5, [COLOR=royalblue]true[/COLOR]);  
[COLOR=royalblue]new[/COLOR] Tween([COLOR=royalblue]this[/COLOR].\_msk, [COLOR=green]"\_yscale"[/COLOR], Regular.easeOut, [COLOR=royalblue]this[/COLOR].\_brd.[COLOR=royalblue]\_yscale[/COLOR], 100, .5, [COLOR=royalblue]true[/COLOR]);  
};  
[COLOR=gray]// end of code //[/COLOR]
