如何防止加载程序更改我的应用程序位置和大小?
我使用简单的加载程序加载 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题不在于加载器,而在于如何使用它,特别是如何将内容添加到舞台。
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.
您加载的 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