在AS3移动应用程序中,我想要一个从底部向上滑动的按钮或图标菜单。使用SlideViewTransition,我可以获得我想要的一部分。
var transition:SlideViewTransition = new SlideViewTransition();
transition.direction = ViewTransitionDirection.UP;
transition.mode = SlideViewTransitionMode.COVER;
view.navigator.pushView(ShareView, null, null, transition);
这很有效,但它没有做我需要做的两件事。
1)我希望新的转换仅上升到屏幕的1/2,以便屏幕的顶部显示下面的视图。
2)我希望覆盖的新视图部分透明。通过设置传入视图的contentGroup背景alpha的alpha,新视图在进入时是透明的。但是,一旦它覆盖视图下方的视图就变得不透明。
this.contentGroup.setStyle('backgroundAlpha', 0.5);
有没有人有任何关于如何让视图向上滑1/2并且透明的想法?我不知道从哪里开始,查看皮肤?或子类转换?,或者使用flash命名空间中的内容而不是spark视图。
答案 0 :(得分:0)
我认为最简单的方法是使用较低级别的ActionScript并使用通常应用于Sprite的方法自己动画,但在这种情况下使用VGroup以便我可以为它添加spark元素。以下是我写的基类。
public class SlideUpDialog extends VGroup {
private var pctHeight:Number;
private var stopHeight:Number;
private var vertIncrement:Number;
public function SlideUpDialog(pctHeight:Number) {
super();
this.pctHeight = pctHeight;
if (stage) {
addedToStageHandler();
} else {
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
}
}
private function addedToStageHandler(event:Event=null) : void {
removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
graphics.beginFill(0xEEEEEE, 0.8);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight * pctHeight);
graphics.endFill();
var bevel:BevelFilter = new BevelFilter(4, -45);
this.filters = [ bevel ];
x = 0;
y = stage.stageHeight;
stopHeight = y * (1 - pctHeight);
vertIncrement = y / 2 / 24 / 4;
}
public function open() : void {
addEventListener(Event.ENTER_FRAME, openFrameHandler);
}
private function openFrameHandler(event:Event) : void {
if (y > stopHeight) {
y -= vertIncrement;
} else {
removeEventListener(Event.ENTER_FRAME, openFrameHandler);
}
}
public function close() : void {
... the reverse of open
}
}