24/10/2008import phoxer.ChildsManager.Msk; //con este simple rengon podemos enmascarar un objeto var msk:Msk= new Msk(this,MySprite,0,0,150,100,20); //o tambien se puede implementar asi var msk:Msk= new Msk(this); msk.setNewMask(MySprite,0,0,150,100,20);
/** by .:{PHOXER}:. http://www.phoxer.com v 3.0; */ package phoxer.Sprites{ import flash.display.Shape; import flash.display.Sprite; import phoxer.ChildsManager.DeleteClips; public class Msk extends Sprite{ private var cuad:Shape; public function Msk(cont:Object,mc:Object=null,x:int=0,y:int=0,w:int=0,h:int=0,rad:int=0,vs:Boolean=false):void{ super(); cont.addChild(this); this.mouseEnabled=false; this.mouseChildren=false; if(mc!=null){ setNewMask(mc,x,y,w,h,rad,vs); } } public function setNewMask(mc:Object,x:int,y:int,w:int,h:int,rad:int=0,vs:Boolean=false):void{ DeleteClips.deleteAll(this); this.x=mc.x; this.y=mc.y; cuad = new Shape(); cuad.graphics.beginFill(0x000000); cuad.graphics.drawRoundRect(x, y, w, h,rad); cuad.graphics.endFill(); this.addChild(cuad); if(!vs){ mc.mask=this; } } public function addMsk(x:int,y:int,w:int,h:int,rad:int=0):void{ cuad = new Shape(); cuad.graphics.beginFill(0x000000); cuad.graphics.drawRoundRect(x, y, w, h,rad); cuad.graphics.endFill(); this.addChild(cuad); } } }
/** by .:{PHOXER}:. http://www.phoxer.com v 3.0; */ package phoxer.Sprites{ import flash.display.Shape; import mx.flash.UIMovieClip; import phoxer.ChildsManager.DeleteClips; public class FlexMsk extends UIMovieClip{ private var cuad:Shape; public function FlexMsk(cont:Object,mc:Object=null,x:int=0,y:int=0,w:int=0,h:int=0,rad:int=0,vs:Boolean=false):void{ super(); cont.addChild(this); this.mouseEnabled=false; this.mouseChildren=false; if(mc!=null){ setNewMask(mc,x,y,w,h,rad,vs); } } public function setNewMask(mc:Object,x:int,y:int,w:int,h:int,rad:int=0,vs:Boolean=false):void{ DeleteClips.deleteAll(this); this.x=mc.x; this.y=mc.y; cuad = new Shape(); cuad.graphics.beginFill(0x000000); cuad.graphics.drawRoundRect(x, y, w, h,rad); cuad.graphics.endFill(); this.addChild(cuad); if(!vs){ mc.mask=this; } } public function addMsk(x:int,y:int,w:int,h:int,rad:int=0):void{ cuad = new Shape(); cuad.graphics.beginFill(0x000000); cuad.graphics.drawRoundRect(x, y, w, h,rad); cuad.graphics.endFill(); this.addChild(cuad); } } }
| ActionScript 3 | Flash CS4 | Flash CS3 | Flex 3 |
2 Comentarios.
Mariano
07/11/2008sinceramente muy bueno y sobretodo muy util tu post, me ha sido de mucha ayuda.
muchas gracias por el aporte
Nicolas
03/01/2009Ey q gran recurso... muchisimas, muchisimas gracias!!
----------------------------------------------
Si los tutoriales o los temas tratados en este blog te gustaron y quieres ayudarme a mantenerlos en linea puede hacer una donacion.
La donaciones son destinadas para mantener este blog y a los tutoriales Online.