开发者

Stack of photos AS3 - stuck on somthing simple

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 h开发者_StackOverflow社区elp would be much appreciated.


Try currentTarget instead of target.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜