仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 840|回复: 8
打印 上一主题 下一主题

[学习教程] 带来一篇Flash AS文本字段的通明度alpha变更-Flash actionscript

[复制链接]
萌萌妈妈 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-15 20:51:01 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Flash动画说到底就是“遮罩+补间动画+逐帧动画”与元件(主要是影片剪辑)的混合物,通过这些元素的不同组合,从而可以创建千变万化的效果。
由于TextField不撑持对alpha的变更,因而必要对其举行一些操纵,有两种办法:
第一是利用BitmapData往绘制,然后对Bitmap举行操纵,这个办法代码量略微偏多,这里不做赘述。
第二种是利用ColorMatrixFilter过滤器。
//Code:

  • packagecom.drore.map.view
  • {
  • importflash.display.Sprite;
  • importflash.events.Event;
  • importflash.text.TextField;
  • importflash.filters.ColorMatrixFilter;

  • /**
  • *静态天生鼠标提醒
  • *@authorDadahttp://www.asflex.cn
  • *@version5.0
  • *@copyDrorehttp://www.drore.com
  • */
  • publicclassMouseTipextendsSprite
  • {
  • privatevartxtTips:TextField=newTextField();
  • publicfunctionMouseTip()
  • {
  • addEventListener(Event.ENTER_FRAME,init);
  • }

  • privatefunctioninit(event:Event):void
  • {
  • removeEventListener(Event.ENTER_FRAME,init);
  • txtTips.selectable=false;
  • txtTips.tabEnabled=false;
  • txtTips.mouseEnabled=false;
  • txtTips.cacheAsBitmap=true;
  • txtTips.multiline=false;
  • //设置滤镜
  • txtTips.filters=[newColorMatrixFilter];
  • addChild(txtTips);
  • }
  • //设置提醒笔墨
  • publicfunctionsetText(txt:String):void
  • {
  • txtTips.text=txt;
  • txtTips.width=txtTips.textWidth+10;
  • drawBg();
  • }
  • //绘制背景
  • privatefunctiondrawBg():void
  • {
  • graphics.clear();
  • graphics.beginFill(0xF3E789,.8);
  • graphics.lineStyle(1,0xFFFF00);
  • graphics.drawRoundRect(-5,-5,txtTips.textWidth+15,txtTips.textHeight+15,10,10);
  • graphics.endFill();
  • }
  • }

  • }
利用办法:
//Code:

  • //鼠标提醒框
  • privatevarmtips:MouseTip=newMouseTip();
  • mtips.setText("Thisisatestsentense.");
  • //利用TweenLite对mtips举行alipa缓动
  • TweenLite.to(mtips,.3,{alpha:0});

Flash又被称之为闪客,是由macromedia公司推出的交互式矢量图和Web动画的标准,由Adobe公司收购。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-18 07:06

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表