从舞台上移除精灵
大家好,我的 Flash 页面出现问题。所以我创建了 5 个页面,每个页面都包含几个影片剪辑(文本、图形、表单等)。然而,有一个特定页面包含通过自动生成的内容。精灵。如果我碰巧登陆这个页面,精灵就会出现,但是当我转换到另一个页面时,除了非精灵的东西(消失)之外,它们仍然在那里。我在这个上抓狂了,我设法删除了一些精灵,但有些仍然出现。下面显示了未删除的布局;
var container:Sprite = new Sprite();
//loop places several "item" in this container sprite and a scroll bar
var item:myItem = new myItem();
var sb:customScrollBar = new customScrollBar();
container.addChild(item);
container.addChild(sb);
所以我们现在在生成容器和项目的页面上,然后我单击一个按钮移动到主页,容器仍然留在那里。
这是我尝试过的:
removeChild(container); //nothing, this was called from another keyframe where the container was not generated from
stage.removeChild(container); //nothing
这是错误。 ArgumentError:错误#2025:提供的 DisplayObject 必须是调用者的子级。
笔记* 我还有几个按钮,它们也不是在容器内生成的,如下所示,它们在我运行removeChild(button1)时工作,所以我不知道为什么容器按钮不工作。
Hey guys, got a problem with my pages in flash. So i created 5 pages, each of which contains several movie clips (text, graphics, forms, etc). There is one specific page however that contains autogenerated content via. sprites. If i happen to land on this page, the sprites will appear, but when i transition to another page, they are still there except for the non-sprite stuff (disappear). Im ripping my hair out on this one, i managed to get a few of the sprites to remove but some are still appearing. Below shows the layout of the one thats not being removed;
var container:Sprite = new Sprite();
//loop places several "item" in this container sprite and a scroll bar
var item:myItem = new myItem();
var sb:customScrollBar = new customScrollBar();
container.addChild(item);
container.addChild(sb);
So we are now on this page where container and items are generated, i then click a button to move to say the home page and the container still stays there.
Here is what i tried:
removeChild(container); //nothing, this was called from another keyframe where the container was not generated from
stage.removeChild(container); //nothing
Here are the errors.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
Note*
I also have several buttons that were also generated NOT inside the container like below and they worked when i ran removeChild(button1) so i dont know why the container one is not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
之前我也遇到过类似的情况,我通过执行以下操作解决了。这取决于我如何创建容器实例并因此被父级识别。
var container:Sprite = new Sprite(); container.name = "container"; //------- later var child:DisplayObject = getChildByName("container"); removeChild(child);
如果您需要删除所有孩子,您也可以这样做
while( this.numChildrem > 0 ) this.removeChildAt(0);
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
则不会收到参数错误 2025,
如果您遵循“无需创建名称”, 这是保证 sprite 或 DisplayObject 被添加到 DisplayList 的原因。那么你不会得到 y ArgumentError 2025 。
You will not get an Argument error 2025 IF you follow
No need to create a name this is guarentee that the sprite or DisplayObject is added to the DisplayList. You will not get an y ArgumentError 2025 then.