Flex 3 播放效果已从Stage 中移除

发布于 2024-08-04 11:52:10 字数 228 浏览 3 评论 0原文

我正在使用removeChildAt()从WindowedApplication中删除一个组件,并且想要播放一个效果(在组件内定义,例如mx:Resize),该效果在删除之前将组件(水平盒)的高度降低到0。

我在组件中使用了removedFromStage事件,但它只是消失了(没有播放效果)。我猜它在效果播放之前就被删除了。有没有办法在removeChild函数完成之前播放效果,最好是在组件中定义?

谢谢。

I'm removing a component from the WindowedApplication, using removeChildAt(), and want to play an effect (defined within the component, say mx:Resize) which reduces the height of the component (an hbox) to 0 before it is removed.

I was using the removedFromStage event within the component, but it just disappears (without playing the effect). I guess it's being removed before the effect is played. Is there a way to play the effect, which is preferably defined in the component, before the removeChild function completes?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初吻给了烟 2024-08-11 11:52:10

removedFromStage 将在组件被删除后被触发(适用于清理/内存管理)。大多数 Flex 组件都有一个 removedEffect 属性。这就是您想要使用的。

removedFromStage is going to be fired after the component has been removed (appropriate for cleanup/memory management). Most Flex components have a removedEffect property. This is what you want to use.

两仪 2024-08-11 11:52:10

我将效果移至父级,这样:

var contentBox:VBox = new VBox();
var cm:HBox = new Hbox();
cm.setStyle('removedEffect', CloseDown);
contentBox.addChildAt(cm, 0);
//in another function
contentBox.removeChild(0);

这有效。当我在组件本身中产生效果时,这不起作用,唉。

I moved the effect to the parent so:

var contentBox:VBox = new VBox();
var cm:HBox = new Hbox();
cm.setStyle('removedEffect', CloseDown);
contentBox.addChildAt(cm, 0);
//in another function
contentBox.removeChild(0);

This works. When I had the effect in the component itself, this didn't work, alas.

月寒剑心 2024-08-11 11:52:10

请查阅 Flex Builder 下的 mx.effects.Resize 类帮助页面,并查看事件列表。

基本上,您需要对代码执行的操作是:

  1. 创建调整大小事件。

  2. 为效果结束添加事件监听器

  3. 播放效果

  4. 当效果结束时关闭窗口。

    p>

代码应如下所示:

public function close():void
{
    var resize:Resize   = new Resize();
    resize.heightTo     = 0;
    resize.duration     = 500;
    resize.addEventListener(EffectEvent.EFFECT_END, onCloseEffectEndHandler);

    resize.play([this]);    

}

private function onCloseEffectEndHandler(event:EffectEvent):void
{
    PopUpManager.removePopUp(this);
}

注意:当您显示窗口时,不要忘记设置高度,否则它将保持为 0,您将什么也看不到!

Please consult the mx.effects.Resize class help page under Flex Builder, and see the events list.

Basically what you need to do with your code is:

  1. create the resize event.

  2. add an event listener for the effect end

  3. play the effect

  4. when the effect ended you close the window.

The code should look like:

public function close():void
{
    var resize:Resize   = new Resize();
    resize.heightTo     = 0;
    resize.duration     = 500;
    resize.addEventListener(EffectEvent.EFFECT_END, onCloseEffectEndHandler);

    resize.play([this]);    

}

private function onCloseEffectEndHandler(event:EffectEvent):void
{
    PopUpManager.removePopUp(this);
}

NOTE: WHEN YOU SHOW THE WINDOW DO NOT FORGET TO SET THE HEIGHT, ELSE IT WILL REMAIN 0 AND YOU WILL SEE NOTHING!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文