flex的ApplicationControlBar中组件滑出
发布时间:2020-12-15 05:12:00 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" mx:Script ![CDATA[ import mx.events.EffectEvent; import mx.events.MoveEvent; private var is_center:Boolean = false; private var
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.events.EffectEvent; import mx.events.MoveEvent; private var is_center:Boolean = false; private var y_pos:int = 0; private function slide_center():void { if (!is_center) { //记下按钮原位置 y_pos = btnSlide.y; //将按钮从control bar中移出 acbMain.removeChild(btnSlide); //加入到主场景以便滑动 this.addChild(btnSlide); //滑动 btnSlide.move(btnSlide.x,stage.height/2 - acbMain.height/2); is_center = true; } else { btnSlide.move(btnSlide.x,y_pos); } } private function on_effectend(e:EffectEvent):void { //为了能够看见按钮回去的过程,要在移动结束后才将它归还control bar控件 //相反操作即可让按钮回到bar上去 if (is_center && btnSlide.hitTestObject(acbMain)) { this.removeChild(btnSlide); acbMain.addChild(btnSlide); is_center = false; } } ]]> </mx:Script> <mx:ApplicationControlBar x="0" y="0" width="100%" id="acbMain"> <mx:Button label="Click Me" click="slide_center()" id="btnSlide" moveEffect="Move" effectEnd="on_effectend(event)"/> </mx:ApplicationControlBar> </mx:Application> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |