一堆照片 AS3 - 停留在简单的事情上

发布于 2024-08-10 20:08:08 字数 1624 浏览 1 评论 0原文

我找到了一个关于使用 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 技术交流群。

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

发布评论

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

评论(1

烟燃烟灭 2024-08-17 20:08:08

尝试使用 currentTarget 而不是 target。

Try currentTarget instead of target.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文