如何防止加载程序更改我的应用程序位置和大小?

发布于 2024-10-02 06:35:16 字数 1210 浏览 5 评论 0原文

我使用简单的加载程序加载 SWF,但它更改了主应用程序的 x/y 位置和大小。

我应该使用哪个加载器来加载 swf,以保持应用程序的位置大小?

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, function handleInit(event:Event):void{
    var UIDesigner:UIComponent = new  UIComponent();
    UIDesigner.addChild(event.target.loader.content);
    UIDesigner.id = "id_sample";
    ApplicationObject.Instance.addElementAt(UIDesigner,0)

    event.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE, function applicationCompleteHandler(event:Event):void{
        var app:SystemManager = event.target as SystemManager;
        var Designer:SkinnableContainer = app.application as SkinnableContainer;
        Designer.id = "id_test";
        ApplicationObject.Instance.removeElementAt(0);
        pTabCon.addChild(Designer as SkinnableContainer);
        pTabCon.horizontalScrollPolicy = "off";
        pTabCon.verticalScrollPolicy = "off";
        Parent.id_ComponentsTab.addChild(pTabCon);
        Parent.id_ComponentsTab.selectedChild = pTabCon;
        trace("swf loaded successfully");
        ApplicationObject.Instance.m_ApplicationList.addItem(Designer);
    });                         
});

I load an SWF using a simple loader but it changes the main applications x/y position and size.

Which loader do I use to load an swf that will maintain the position size of my app?

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, function handleInit(event:Event):void{
    var UIDesigner:UIComponent = new  UIComponent();
    UIDesigner.addChild(event.target.loader.content);
    UIDesigner.id = "id_sample";
    ApplicationObject.Instance.addElementAt(UIDesigner,0)

    event.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE, function applicationCompleteHandler(event:Event):void{
        var app:SystemManager = event.target as SystemManager;
        var Designer:SkinnableContainer = app.application as SkinnableContainer;
        Designer.id = "id_test";
        ApplicationObject.Instance.removeElementAt(0);
        pTabCon.addChild(Designer as SkinnableContainer);
        pTabCon.horizontalScrollPolicy = "off";
        pTabCon.verticalScrollPolicy = "off";
        Parent.id_ComponentsTab.addChild(pTabCon);
        Parent.id_ComponentsTab.selectedChild = pTabCon;
        trace("swf loaded successfully");
        ApplicationObject.Instance.m_ApplicationList.addItem(Designer);
    });                         
});

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

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

发布评论

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

评论(3

鸠魁 2024-10-09 06:35:16

问题不在于加载器,而在于如何使用它,特别是如何将内容添加到舞台。

DisplayObjectContainer 将根据其内容改变大小。例如,如果您将宽度为 400 的 MovieClip 加载到另一个宽度为 200 的 MovieClip 中,则包含的 MovieClip 宽度将更改为 400。这是预期行为。

例如,可以通过使用屏蔽或在将内容添加到舞台之前修改加载的内容属性来修改此行为。

至于 x & y 属性,这与您的代码有关。加载内容不应更改 x 和包含对象的 y 属性。

如果您编辑您的问题并添加一些代码示例,我们也许可以为您提供更具体的帮助。

The problem is not the Loader but how you use it and specifically, how you add the content to the stage.

A DisplayObjectContainer will change size according to its content. For instance , if you load a MovieClip with a width of 400 in another MovieClip with a 200 width, the containing MovieClip width will change to 400. This is an expected behavior.

It's possible to modify this behavior by using masking for instance or modifying the loaded content properties before adding content to the stage.

As for the x & y properties, it would have to do with your code. Loading content shouldn't change the x & y properties of the containing Object.

If you edit your question and add some code example we may be able to give you more specific help.

瑕疵 2024-10-09 06:35:16

您加载的 swf 是否调用 root 或 stage?我的应用程序的 swf 动画背景遇到了这样的问题。
以及如何加载它?

upd:您始终可以使用 NO_SCALE

does the swf that you load call root or maybe stage? i've had such issue with an swf animated background for my app.
and how do load it?

upd: you can always use NO_SCALE

心凉怎暖 2024-10-09 06:35:16
    loadSWFFile("resources/awords/myswf.swf");
private function loadSWFFile(fileURL:String):void
{
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleSWFLoadComplete0);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler0);
    loader.load( new URLRequest(fileURL));
}
private function handleSWFLoadComplete0( evt:Event ):void
{
    loaderWidth = evt.currentTarget.loader.width;
    loaderHeight = evt.currentTarget.loader.height;

    // Now set the width and height of target component same as loaderWidth and loaderHeight respectively.
}
private function ioErrorHandler0(e:IOErrorEvent):void
{
    mx.controls.Alert.show("Unable to load", "IOError", 0);
}
    loadSWFFile("resources/awords/myswf.swf");
private function loadSWFFile(fileURL:String):void
{
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleSWFLoadComplete0);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler0);
    loader.load( new URLRequest(fileURL));
}
private function handleSWFLoadComplete0( evt:Event ):void
{
    loaderWidth = evt.currentTarget.loader.width;
    loaderHeight = evt.currentTarget.loader.height;

    // Now set the width and height of target component same as loaderWidth and loaderHeight respectively.
}
private function ioErrorHandler0(e:IOErrorEvent):void
{
    mx.controls.Alert.show("Unable to load", "IOError", 0);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文