一堆照片 AS3 - 停留在简单的事情上
我找到了一个关于使用 AS3 在 Flash 中创建照片堆栈的教程 ( http://designreviver.com/tutorials/create-an-interactive-stack-of-photos/)。
我一直在尝试制作照片堆栈的动态 XML 版本,但遇到了一个问题(显然:)
我有一个名为 Polaroid 的类,我使用循环将其多个实例添加到舞台上,如下所示:
function processXML(e:Event):void {
var myXML:XML=new XML(e.target.data);
my_images=myXML.IMAGE;
my_total=my_images.length();
photoCount=my_total;
for (var i:Number = 1; i <= my_total; i++) {
imageNo=i;
this.addChild(new polaroid ).name="photo"+imageNo;
this.getChildByName("photo"+imageNo).addEventListener(MouseEvent.MOUSE_DOWN, photoSlideOut);
this.getChildByName("photo"+imageNo).rotation = Math.floor(Math.random()*(rotationRange*2))-rotationRange;
}
}
然后使用两个函数可以将照片滑出并更改其索引,以便它位于所有其他宝丽莱实例的后面。
function photoSlideOut(e:Event):void {
e.target.parent.setChildIndex(e.target, e.target.parent.numChildren - 1);
Tweener.addTween(e.target, {x: photoDestX, time: speed, transition: easeType, onComplete:photoSlideIn, onCompleteParams:[e.target]});
Tweener.addTween(e.target, {rotation: Math.floor(Math.random()*(rotationRange*2))-rotationRange, time: speed*2, transition: easeType});
}
function photoSlideIn(p:MovieClip):void {
p.parent.setChildIndex(p, 0);
Tweener.addTween(p, {x: photoOriginX, time: speed, transition: easeType});
}
photoSlideOut 似乎工作正常,photoslidein 中的补间工作正常 - 我似乎无法更改已单击的宝丽来实例的子索引。
有人知道我在这里哪里出了问题吗?
任何帮助将不胜感激。
I found a tutorial on creating a stack of photos in flash using AS3 (http://designreviver.com/tutorials/create-an-interactive-stack-of-photos/).
I have been trying to make a dynamic XML version of the photo stack and I have a problem (obviously :)
I have a class called Polaroid, and im using a loop to add multiple instances of it onto the stage as follows:
function processXML(e:Event):void {
var myXML:XML=new XML(e.target.data);
my_images=myXML.IMAGE;
my_total=my_images.length();
photoCount=my_total;
for (var i:Number = 1; i <= my_total; i++) {
imageNo=i;
this.addChild(new polaroid ).name="photo"+imageNo;
this.getChildByName("photo"+imageNo).addEventListener(MouseEvent.MOUSE_DOWN, photoSlideOut);
this.getChildByName("photo"+imageNo).rotation = Math.floor(Math.random()*(rotationRange*2))-rotationRange;
}
}
I then Use two functions to slide the photo out and change its index so that it goes behind all of the other instances of Polaroid.
function photoSlideOut(e:Event):void {
e.target.parent.setChildIndex(e.target, e.target.parent.numChildren - 1);
Tweener.addTween(e.target, {x: photoDestX, time: speed, transition: easeType, onComplete:photoSlideIn, onCompleteParams:[e.target]});
Tweener.addTween(e.target, {rotation: Math.floor(Math.random()*(rotationRange*2))-rotationRange, time: speed*2, transition: easeType});
}
function photoSlideIn(p:MovieClip):void {
p.parent.setChildIndex(p, 0);
Tweener.addTween(p, {x: photoOriginX, time: speed, transition: easeType});
}
photoSlideOut seems to be working fine and the tween in photoslidein is working - I cant seem to change the Child Index of the instance of Polaroid that has been clicked though.
Anyone have an idea of where i am going wrong here?
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 currentTarget 而不是 target。
Try currentTarget instead of target.