actionscript 3 - AS3 setChildIndex -
i'm making book page flipping effect (i have flipping right page until now), , i'm having problem index, because page flip doesnt stay on top of others.
i tried writing setchildindex(cont, this.numchildren -1) not working!
import fl.transitions.tween; import fl.transitions.easing.*; import fl.transitions.tweenevent; import flash.display.sprite; var cont : displayobject; var imgloader : loader; (var i:int=0; i<=4; i++){ imgloader = new loader(); imgloader.contentloaderinfo.addeventlistener(event.init, onloadjpeg); imgloader.load(new urlrequest(""+i+".png")); } function onloadjpeg (e : event) : void { cont = e.target.loader; cont.x =300; cont.y =65; cont.width = 286/2; cont.height = 406/2; addchild(cont); cont.addeventlistener(mouseevent.mouse_up, flippage); } function flippage(e:mouseevent):void{ setchildindex(cont, this.numchildren -1); var mytween:tween = new tween(e.currenttarget, "rotationy", regular.easeinout,0, 180, 1, true); }
you need set child index of e.currenttarget
, not cont
.
setchildindex(displayobject(e.currenttarget), this.numchildren - 1);
Comments
Post a Comment