Hi everyone,
Having trouble with my Fla and its drag and drop objects not appearing in their root position when moving back and fourth on the timeline.
I managed to add an "add.Eventlistener" to a restart button to place objects in their original position within the frame but I'd like this to be automatic when going back to a previous frame.
Ideally (!) my prevButton symbol would need to have BOTH "go to previous frame" and "start with objects in their root position". Both codes are below...
fla here:
http://www.violinopedia.com/template_290721.fla
Any hint ?
Thanks !
this.navigationLoop = true; // set to true or false to enable or disable loop when the current position is the first or the last frame
if (!this.hasStarted)
{
this.prevFrame = function(e)
{
if (this.navigationLoop && this.currentFrame == 0)
this.gotoAndStop(this.timeline.duration - 1);
else
this.gotoAndStop(this.currentFrame - 1);
};
this.prevButton.on("click", this.prevFrame, this);
this.stop();
this.hasStarted = true;
this.nextFrame = function(e)
{
if (!this.navigationLoop && this.currentFrame == this.timeline.duration - 1)
return;
this.gotoAndStop(this.currentFrame + 1);
};
this.nextButton.on("click", this.nextFrame, this);
this.stop();
this.hasStarted = true;
}
this.restartButton.addEventListener("click", onClickrestartButton);
var root=this;
var arr=[];
for(var i=0; i<root.numChildren; i++){
arr.push([root.getChildAt(i).id, root.getChildAt(i).x, root.getChildAt(i).y]);
}
window.arrElement=arr;
function onClickrestartButton() {
for(var i=0; i<window.arrElement.length; i++){
var element = window.arrElement[i];
if(root.getChildAt(i).id==element[0]){
root.getChildAt(i).x = element[1];
root.getChildAt(i).y = element[2];
}
}
}