I’m using the code below and I want the timeline to move to a new frame when all the drags have been completed correctly but I’m not sure where to add the gotoAndPlay script. Suggestions anyone?
stop();
displayTime = 40;
countDown = function(message){
displayTime--;
if (displayTime == 0){
clearInterval(timer);
gotoAndPlay ("TimesUp");
}
}
timer = setInterval(countDown, 1000);
var buttons:Array = [button1, button2, button3, button4, button5, button6, button7];
var sections:Array = ["J'ai- correct!", "Tu as- correct", "Correct", "Ils ont - correct!", "Elles ont - correct!", "Nous avons - correct!", "Vous avez - correct!"];
var speed:Number = .1;
showNames.text = "Let's Go!";
// <-----------------
for (i=0; i<buttons.length; i++) {
buttons*.startX = buttons*._x;
buttons*.startY = buttons*._y;
buttons*.onPress = dragButton;
buttons*.onRelease = buttons*.onReleaseOutside=easeBack;
buttons*.buttonName = sections*;
buttons*.id = (i+1); // <- add this to store the number at the end of the dropZone mc's
// <-----------------
}
function dragButton():Void {
delete this.onEnterFrame;
this.startDrag();
}
function easeBack():Void {
this.stopDrag();
trace(this);
var dropZone:MovieClip = _root["dropZone"+this.id]; // <- add this to know which movie clip
if (!dropZone.hitTest(this)) {
this.onEnterFrame = function() {
this._x += (this.startX-this._x)*speed;
this._y += (this.startY-this._y)*speed;
if (this._x<this.startX+1 && this._x>this.startX-1 && this._y<this.startY+1 && this._y>this.startY-1) {
this._x = this.startX;
this._y = this.startY;
delete this.onEnterFrame;
}
};
} else {
this.onEnterFrame = function() {
this._x += (dropZone._x-this._x)*speed;
this._y += (dropZone._y-this._y)*speed;
if (this._x<dropZone._x+1 && this._x>dropZone._x-1 && this._y<dropZone._y+1 && this._y>dropZone._y-1) {
this._x = dropZone._x;
this._y = dropZone._y;
delete this.onEnterFrame;
showNames.text = this.buttonName;
// <-----------------
}
};
}
}
Thanks a bunch!
Yossi