使用 addChild 时阶段会发生变化吗?
我在 Flash CS4 中使用 ActionScript 3 时遇到了一个非常奇怪的错误。我在 for 循环中将影片剪辑添加到舞台中,然后将它们移出视图,以便我可以在需要时将它们拉入并删除。
我已将问题范围缩小到我知道每次使用 addChild() 将一个影片剪辑添加到舞台时,舞台都会向右移动一个像素。我知道这听起来很奇怪,但确实如此……每次添加影片剪辑时,y 轴上的 0 线都会向右移动一个像素。我不知道这是怎么发生的。
这是完成这项工作的代码:
private function setupSlides():void
{
for(x = 0; x < TOTAL_SLIDES; x++)
{
var ClassReference:Class = getDefinitionByName("Slide" + (x+1)) as Class;
var s:MovieClip = new ClassReference() as MovieClip;
s.x = 9999;
s.y = 9999;
addChild(s);
slides[x] = s;
}
}
有什么想法吗?
I'm having a very odd bug with ActionScript 3 in Flash CS4. I am adding movie clips to a stage in a for loop and then moving them out of view so that I can pull them in and remove them when I need them.
I've narrowed down the issue to a point that I know that every time one of the movie clips are added to the stage using addChild(), the stage shifts to the right by one pixel. I know that sounds odd, but it's literally true... the 0 line on the y axis is shifted to the right one pixel every time the movie clip is added. I have no idea how this could be happening.
Here's the code that is doing the work:
private function setupSlides():void
{
for(x = 0; x < TOTAL_SLIDES; x++)
{
var ClassReference:Class = getDefinitionByName("Slide" + (x+1)) as Class;
var s:MovieClip = new ClassReference() as MovieClip;
s.x = 9999;
s.y = 9999;
addChild(s);
slides[x] = s;
}
}
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发布后,我注意到我没有声明循环计数器变量(x)。我声明了它,奇怪的渲染就消失了。我想知道为什么它没有给我一个未声明的变量错误?
这是固定代码:
After posting, I noticed that I had not declared the loop counter variable (x). I declared it, and the strange rendering is gone. I wonder why it just didn't give me an undeclared variable error?
Here's the fixed code: