百叶窗特效
来源:互联网 发布:软件测试缺陷 编辑:程序博客网 时间:2024/04/27 06:05
effects\Blinds.as
effects\effectClasses\BlindsInstance.as
Test.mxml
- JScript code
- package effects{ import effects.effectClasses.BlindsInstance; import mx.controls.scrollClasses.ScrollBarDirection; import mx.effects.IEffectInstance; import mx.effects.TweenEffect; public class Blinds extends TweenEffect { private static var AFFECTED_PROPERTIES:Array = ["mask"]; public function Blinds(target:Object=null) { super(target); instanceClass = BlindsInstance; } public var direction:String = ScrollBarDirection.VERTICAL; public var blindsFrom:Number; public var blindsTo:Number; public var gapFrom:Number; public var gapTo:Number; override public function getAffectedProperties():Array { return AFFECTED_PROPERTIES; } override protected function initInstance(instance:IEffectInstance):void { super.initInstance(instance); var blindsInstance:BlindsInstance = BlindsInstance(instance); blindsInstance.direction = direction; blindsInstance.blindsFrom = blindsFrom; blindsInstance.blindsTo = blindsTo; blindsInstance.gapFrom = gapFrom; blindsInstance.gapTo = gapTo; } } }
effects\effectClasses\BlindsInstance.as
- JScript code
- package effects.effectClasses{ import flash.display.DisplayObject; import flash.display.Sprite; import mx.controls.scrollClasses.ScrollBarDirection; import mx.effects.effectClasses.TweenEffectInstance; public class BlindsInstance extends TweenEffectInstance { public function BlindsInstance(target:Object) { super(target); } public var direction:String = ScrollBarDirection.VERTICAL; public var blindsFrom:Number; public var blindsTo:Number; public var gapFrom:Number; public var gapTo:Number; override public function play():void { super.play(); if (isNaN(blindsFrom)) blindsFrom = 30; if (isNaN(blindsTo)) blindsTo = 30; if (isNaN(gapFrom)) gapFrom = 100; if (isNaN(gapTo)) gapTo = 0; blindsFrom = Math.max(Math.min(blindsFrom, 100), 0); blindsTo = Math.max(Math.min(blindsTo, 100), 0); gapFrom = Math.max(Math.min(gapFrom, 100), 0); gapTo = Math.max(Math.min(gapTo, 100), 0); tween = createTween(this, [blindsFrom, gapFrom], [blindsTo, gapTo], duration); } override public function onTweenUpdate(value:Object):void { setBlindsMask(value[0], value[1]); } override public function onTweenEnd(value:Object):void { setBlindsMask(value[0], value[1]); super.onTweenEnd(value); } private function setBlindsMask(blinds:Number, gap:Number):void { var currentTarget:DisplayObject = target as DisplayObject; if (!currentTarget) return; var mask:Sprite = new Sprite(); var targetWidth:Number = currentTarget.width; var targetHeight:Number = currentTarget.height; var length:Number = 0; var gapLength:Number = 0; var currentOffset:Number = 0; var i:int = 0; mask.graphics.clear(); mask.graphics.beginFill(0x000000, 1); if (direction == ScrollBarDirection.VERTICAL) { blinds = (targetHeight / 2) * (blinds / 100); length = (blinds == 0 ? targetHeight : Math.floor(targetHeight / blinds)); gapLength = Math.round((length / 2) * (gap / 100)); for (i = 0; i < blinds; i++) { mask.graphics.drawRect(0, currentOffset, targetWidth, Math.max(length - gapLength, 0)); currentOffset = currentOffset + length; } if (currentOffset < targetHeight) mask.graphics.drawRect(0, currentOffset, targetWidth, targetHeight - currentOffset); } else { blinds = (targetWidth / 2) * (blinds / 100); length = (blinds == 0 ? targetWidth : Math.floor(targetWidth / blinds)); gapLength = Math.round((length / 2) * (gap / 100)); for (i = 0; i < blinds; i++) { mask.graphics.drawRect(currentOffset, 0, Math.max(length - gapLength, 0), targetHeight); currentOffset = currentOffset + length; } if (currentOffset < targetWidth) mask.graphics.drawRect(currentOffset, 0, targetWidth - currentOffset, targetHeight); } mask.graphics.endFill(); currentTarget.mask = mask; } } }
Test.mxml
- XML code
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"xmlns:effect="effects.*" width="100%"height="100%"backgroundColor="#2D8B21"><fx:Declarations><effect:Blinds id="hBlinds" direction="horizontal" duration="1000" blindsFrom="10" blindsTo="10" gapFrom="100" gapTo="0" /><effect:Blinds id="vBlinds" direction="vertical" duration="1000" blindsFrom="10" blindsTo="10" gapFrom="100" gapTo="0" /></fx:Declarations><mx:Panel id="panel" width="100%" height="100%" title="Panel" layout="vertical"><mx:Label text="Label" /><mx:Button label="Button" /><mx:TextInput text="TextInput" /><mx:HRule width="100%" /><mx:Button label="Play(horizontal)" color="#FF0000" click="hBlinds.play([panel])" /><mx:Button label="Play(vertical)" color="#FF0000" click="vBlinds.play([panel])" /></mx:Panel></mx:Application>
- 百叶窗特效
- Html-百叶窗特效
- 一个MTK的百叶窗特效
- 用VB实现“百叶窗”的图形特效
- 用VB实现“百叶窗”的图形特效
- 页面打开时加特效(百叶窗什么的....)
- PS图像特效算法——百叶窗
- 百叶窗特效(用move.js库)
- 百叶窗特效(用move.js库)
- 百叶窗特效(用move.js库)
- 采用gdiplus 制作图像特效----图像特效(扫描、马赛克、百叶窗。。。)
- 百叶窗
- Windows界面编程第十篇 位图显示特效 百叶窗效果
- 经典代码收藏之——百叶窗特效的Java实现
- Windows界面编程第三季位图特效显示——交错、百叶窗、随机积木、飞入伸展
- CCTransition(scene切换时会用到 产生特效 渐隐 碎片 翻页 钟摆 涡轮 渐远 左移 百叶窗。。。)
- silverlight百叶窗
- 实现百叶窗效果图
- 11.2.0.1 Grid Infrastructure Installation Failed at Second Nodes While Running root.sh
- C# EXCEL 分组 Range.Rows.Group()
- PHP学习之memcache集群相关
- iOS: NSUserDefaults issues
- 将136.23.12.64/26划分成四个相同的子网,每个子网内有多少可用IP?
- 百叶窗特效
- 什么是lib文件,lib和dll的关系如何
- iphone里读取gb2312(中文)编码文件或者二进制流。
- java生成GUID与UUID
- 几条C#的Excel编程技巧
- org.tigris.subversion.javahl.ClientException: Attempted to lock an already-locked dir异常解决方法
- 卡尔曼滤波
- Office编程在dot Net环境中总结(Excel篇)
- android adb设置