zoukankan      html  css  js  c++  java
  • FLEX蒙板处理

    同事在处理绘图时,总有些超出边界,flex可不管你超不超,照样show出来,而在window编程中有API
    selectClipRng来处理,在flex中可以实现,示例如下:

    in maskExample.mxml
     1 <?xml version="1.0"?>
     2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
     3      width="100%" height="100%">
     4     <mx:CheckBox id="cb1" label="enable mask" x="26" y="258"
    selected
    ="false" click="enableMask(cb1.selected);"/>
     5     <mx:TextArea id="t1" x="26" y="58" width="352" height="192" wordWrap="true">
     6         <mx:text><![CDATA[
           省略
    12 ]]></mx:text>
    13     </mx:TextArea>
    14     <mx:creationComplete>
    15         <![CDATA[
    16             //enableMask(cb1.selected);
    17         ]]>
    18     </mx:creationComplete>
    19     <mx:Script>
    20         <![CDATA[
    21 
    22             private function enableMask(mode:Boolean):void
    23             {
    24                 var mask:Sprite = t1.getChildByName("_masker") as Sprite;
    25                 if(mode){
    26                     if(!mask){
    27                         mask = new Sprite();
    28                         mask.name ="_masker";
    29                         t1.addChild(mask);
    30                         t1.mask = mask;
    31                         
    32                         var w:int = t1.width;
    33                         var h:int = t1.height;
    34                         var g:Graphics = mask.graphics;
    35                         g.beginFill(0x000000);
    36                         g.drawRect(20,20,w-10,h-10);
    37                         g.endFill();
    38                     }
    39                 }else{
    40                     if(mask){
    41                         t1.mask = null;
    42                         t1.removeChild(mask);
    43                     }
    44                 }
    45             }
    46         ]]>
    47     </mx:Script>
    48     <mx:Label x="26" y="21" text="蒙板示例" color="#D72626" width="112" fontSize="19"/>
    49     
    50 
    51 </mx:Application>
    52 
    29行:蒙板也必须是目标对象的child.故采用addChild;
    30行:就是将sprite设置为蒙板。


  • 相关阅读:
    There is an overlap in the region chain修复
    There is an overlap in the region chain
    region xx not deployed on any region server
    python 中的re模块,正则表达式
    TCP粘包问题解析与解决
    yield from
    Git push提交时报错Permission denied(publickey)...Please make sure you have the correct access rights and the repository exists.
    mysql 中Varchar 与char的区别
    Mysql 字符集及排序规则
    请实现一个装饰器,限制该函数被调用的频率,如10秒一次
  • 原文地址:https://www.cnblogs.com/jssy/p/889709.html
Copyright © 2011-2022 走看看