浏览 4124 次
锁定老帖子 主题:模仿下拉列表下拉和收起的动画效果
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-02-10
/** * 实现下拉列表、弹出菜单出现和隐藏时缓动的效果 */ package com.gde.dataModel { import fl.transitions.Tween; import fl.transitions.TweenEvent; import fl.transitions.easing.Regular; import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextFormat; public class PopupMenu extends Sprite{ // private var curListMenuState:Boolean; private var myTween:Tween; private var listMenu:ListMenus; private var maskSprite:Sprite; private var referenceObject:Object; // private var playMode:PlayMode; //隐藏位置 private var hidePosition:Number; //显示位置 private var showPosition:Number; /** * referenceObject参照物对象 */ public function PopupMenu(sprite:Object):void{ referenceObject = sprite; var itemTextFormat:TextFormat = new TextFormat(); itemTextFormat.underline = true; listMenu = new ListMenus(); listMenu.setSelectIcon(true); listMenu.selectItem(3); listMenu.setTextFormat(itemTextFormat); // listMenu.addEventListener(ListMenusEvent.SELECTITEM, playMode.setPlayModeHandler); // listMenu.addEventListener(ListMenusEvent.SELECTITEM, playModeMenuEnd); //在按钮的右下方显示菜单 this.addChild(listMenu); maskSprite = new Sprite(); this.addChild(maskSprite); } public function setdata(itemVoArray:Array):void{ listMenu.addItemArray(itemVoArray); listMenu.isSelectMore = false; listMenu.y = referenceObject.y + referenceObject.height; listMenu.x = referenceObject.x + (referenceObject.width - listMenu.width)/2; maskSprite.graphics.clear(); maskSprite.graphics.beginFill(0xFFFFFF); maskSprite.graphics.drawRect(0, 0, listMenu.width, listMenu.height); maskSprite.graphics.endFill(); maskSprite.x = listMenu.x; maskSprite.y = listMenu.y; maskSprite.height = listMenu.height * 1.2; maskSprite.width = listMenu.width; listMenu.mask = maskSprite; listMenu.y = listMenu.y - listMenu.height; hidePosition = listMenu.y - listMenu.height; showPosition = listMenu.y; } public function showListMenu(e:MouseEvent):void{ referenceObject.removeEventListener(MouseEvent.CLICK, showListMenu); backIn(); } public function destroyPlayModeMenu(e:MouseEvent):void{ stage.removeEventListener(MouseEvent.MOUSE_UP, destroyPlayModeMenu); backOut(); } private function backIn():void{ var startValue:Number = maskSprite.y - listMenu.height; var finishValue:Number = maskSprite.y; var duration:Number = 0.4; myTween = new Tween(listMenu, "y", Regular.easeOut, startValue, finishValue, duration, true); myTween.addEventListener(TweenEvent.MOTION_FINISH, showFinishHandler); } private function backOut():void{ var startValue:Number = maskSprite.y; var finishValue:Number = maskSprite.y - listMenu.height; var duration:Number = 0.2; myTween = new Tween(listMenu, "y", Regular.easeIn, startValue, finishValue, duration, true); myTween.addEventListener(TweenEvent.MOTION_FINISH, hideFinishHandler); } private function showFinishHandler(e:TweenEvent):void{ myTween.removeEventListener(TweenEvent.MOTION_FINISH, showFinishHandler); // curListMenuState = true; stage.addEventListener(MouseEvent.MOUSE_UP, destroyPlayModeMenu); } private function hideFinishHandler(e:TweenEvent):void{ myTween.removeEventListener(TweenEvent.MOTION_FINISH, hideFinishHandler); // curListMenuState = false; referenceObject.addEventListener(MouseEvent.CLICK, showListMenu); } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-02-22
没见效果。。。。。
|
|
返回顶楼 | |
发表时间:2010-02-23
sosyi 写道 没见效果。。。。。
同上!!..... |
|
返回顶楼 | |
发表时间:2010-03-24
最好能够将fl包附件形式上传上来
|
|
返回顶楼 | |