100% 至 100% Flex 应用程序预加载器定位

发布于 2024-07-17 10:10:43 字数 336 浏览 5 评论 0原文

我在尝试将加载动画应用到我的 Flex 应用程序(整个浏览器窗口占用者)时遇到问题。 我按照 Adob​​e 的 文章中所述对 DownloadProgressBar 类进行子类化< /a> 关于这个。 基类报告的 stageHeightstageWidth 不正确。 它在构造函数中表示 500x375 像素,在其他地方表示 0x0。 为什么?

I've got a problem trying to apply a loading animation to my Flex application - a whole browser window occupant.
I'm subclassing DownloadProgressBar class as described on Adobe's article about this. stageHeight and stageWidth, reported by base class are incorrect. It says 500x375 pixels in constructor and 0x0 elsewhere. Why?

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

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

发布评论

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

评论(5

慵挽 2024-07-24 10:10:43

你解决这个问题了吗? 我的 Flex 应用程序也有同样的问题。
舞台返回 500x375。
我的解决方法并不漂亮。 该函数在 FlexEvent.INIT_PROGRESS 上调用。 因此,当我的应用程序可用时,我会使用它的 props。

private function onFlexInitProgress( event:FlexEvent ):void {
    if (Application.application != null){
        var appWidth:Number = Application.application.width;
        var appHeight:Number = Application.application.height;
        x = (appWidth * 0.5) - (preloaderSWF.width * 0.5);
        y = (appHeight * 0.5);
        preloaderSWF.visible = true;
    }
}

Have you solved this problem? I have the same problem with my flex app.
Stage returns 500x375.
My workaround is not pretty. This function is called on FlexEvent.INIT_PROGRESS. So when my application is available i use its props.

private function onFlexInitProgress( event:FlexEvent ):void {
    if (Application.application != null){
        var appWidth:Number = Application.application.width;
        var appHeight:Number = Application.application.height;
        x = (appWidth * 0.5) - (preloaderSWF.width * 0.5);
        y = (appHeight * 0.5);
        preloaderSWF.visible = true;
    }
}
倦话 2024-07-24 10:10:43

我不确定这是否有帮助,但我认为可以通过使用 Application.width、Application.height 来引用 Flex 应用程序的大小。

http://livedocs.adobe.com/flex/ 3/html/help.html?content=app_container_2.html

以下问题似乎与您的问题相关:

http://www.nabble.com/Stupid-Question---Flex-width-and-height-td21423345.html

< a href="http://www.nabble.com/Flex-stage-size-td20167125.html" rel="nofollow noreferrer">http://www.nabble.com/Flex-stage-size-td20167125.html

http://dreamweaverforum.info/flex/125327-referencing- stage-flex.html

希望他们有所帮助。

I'm not sure if this will help but I think its possible to reference the size of the Flex application by using Application.width, Application.height.

http://livedocs.adobe.com/flex/3/html/help.html?content=app_container_2.html

The issues below seem to be related to your issue:

http://www.nabble.com/Stupid-Question---Flex-width-and-height-td21423345.html

http://www.nabble.com/Flex-stage-size-td20167125.html

http://dreamweaverforum.info/flex/125327-referencing-stage-flex.html

Hope they help.

离线来电— 2024-07-24 10:10:43

0x0 的宽度/高度测量通常表示相关组件在读取时尚未完全布局(包括子组件)。 在构造函数中检查测量结果肯定还为时过早。 在将舞台设置为全屏并且显示的所有内容都已布置好之后,您可能需要检查测量值,可能是在应用程序创建完成事件中,甚至可能更晚。 以下链接应该是一个很好的资源:

http: //blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/

A width/height measurement of 0x0 is often indicative of the component in question not having been fully laid out at the time of the reading (including child components). Checking measurements in the constructor is surely too early. You'll want to check the measurements after you've set the stage to fullscreen and everything you're displaying has been laid out, probably at the applications creationComplete event, perhaps even later. The following link should be a good resource:

http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/

小帐篷 2024-07-24 10:10:43

您想要做的是将事件侦听器添加到舞台中以获取其调整大小事件,并相应地调整预加载器的大小。 否则,如果有人在显示预加载器时调整您的 Flex 应用程序的大小,则该应用程序不会调整大小。

stage.addEventListener(Event.RESIZE, onStageResize);

public function onStageResize(e : Event) : void {
    this.width = stage.stageWidth;
    this.height = stage.stageHeight;
}

或者,您可以使用如下代码将预加载器置于舞台中央:

preloader.x = this.stage.stageWidth/2 - preloader.width/2;

What you want to do is add an event listener to the stage for its resize event and adjust the size of your preloader accordingly. Otherwise if someone resizes your Flex app while the preloader is displayed it will not resize.

stage.addEventListener(Event.RESIZE, onStageResize);

public function onStageResize(e : Event) : void {
    this.width = stage.stageWidth;
    this.height = stage.stageHeight;
}

Or alternatively you can center your preloader on the stage using code like so:

preloader.x = this.stage.stageWidth/2 - preloader.width/2;
云醉月微眠 2024-07-24 10:10:43

我在 flash builder 的 actionscript 项目中使用 100% 到 100% 宽度和高度时遇到了同样的问题。 我观察到 stage.stageWidth 和 stage.stageHeight 为 500x375,直到预加载器加载主类后,它才会更改为全屏尺寸。 因此,预加载器中的项目定位不正确。 我发现我的主类中的这一行正在更新舞台大小:

stage.scaleMode = StageScaleMode.NO_SCALE;

以下是我在预加载器中实现它的方法:

public function Preloader()
    {
        addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage(event:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        stage.scaleMode=StageScaleMode.NO_SCALE;
        stage.align=StageAlign.TOP_LEFT;
        ...
    }

I had this same problem in an actionscript project in flash builder, using 100% to 100% width and height. I observed that stage.stageWidth and stage.stageHeight was 500x375 until after the preloader had loaded the main class, then it would change to the full screen size. Because of this, the positioning of items in the preloader was incorrect. I discovered that it was this line in my main class that was getting the stage size to update:

stage.scaleMode = StageScaleMode.NO_SCALE;

Here is how I implemented it in my preloader:

public function Preloader()
    {
        addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage(event:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        stage.scaleMode=StageScaleMode.NO_SCALE;
        stage.align=StageAlign.TOP_LEFT;
        ...
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文