PDA

View Full Version : Lost..... In a Variable wasteland...


wattie187
02-14-2006, 08:59 AM
I have just started using Flash, and I am creating a simple drag and drop game. Or so I thought. Premise of the game is to drag and drop specific elements onto the correct place on the screen. Once they have hit the correct spot they lock into place and increase a variable by one.

I have achieved all of this, the problem lies in getting the script to react when the variable hits 6 and needs to load a movie to congratulate the winner. I have the code below on each item that is being dragged, any solutions would be helpfull.

on (release) {
//Stop Dragging Movieclip Behavior
stopDrag();
//End Behavior
if (this.hitTest(264,470)){
this._x=203.7;
this._y=457.9;
this.enabled=false;
_global.totalPoint=_global.totalPoint+1;
I want to check for totalPoint equalling 6, if it does I want to load the movie clip Congrats

}
else {
this._x=542.6;
this._y=155.3;
}

}

devilmaycry
02-14-2006, 09:19 AM
hi and welcome

on (release) {
//Stop Dragging Movieclip Behavior
stopDrag();
//End Behavior
if (this.hitTest(264,470)){
this._x=203.7;
this._y=457.9;
this.enabled=false;
_root.totalPoint=_root.totalPoint+1;
if(_root.totalPoint==6){
_root.createEmptyMovieClip("con",_root.getNextHighestDepth());
_root.con.loadMovie("cong.swf");
}

}
else {
this._x=542.6;
this._y=155.3;
}

}

Mantigor
02-14-2006, 09:21 AM
hmm i realtively bew to AS but wouldnt it work if just put

if (_global.totalPoint == '6') {gototandplay (congrats mc)};

or something like that???

p.s. i think my syntax isnt correct so dont use that code plz

wattie187
02-14-2006, 09:46 AM
Thanks for the help, but I have tried this code and first time it tried to load the movie but threw an error. After that it does nothing, I put a trace statement into the If clause and it is throwing up the correct value, so it is getting that far.

wattie187
02-14-2006, 09:55 AM
Eureka, it works. Stupid mistake I had the swf file I was loading inside a folder in my root folder.

Cheers :D

wattie187
02-14-2006, 01:13 PM
Right nearly finished lol

Excuse the probably stupid questions, but I am still learning.

I have got the game, so it now plays a sound file and then checks for the variable to see if it has hit 6. Then I have got it to load a movie clip for the congrats screen. Instead of playing a swf file see code below. Unfortunately when I do this it places it in the bottom left. How can I give it x and y co-ordinates, so I can place it where I want it.

Thanks

on (release) {
//Stop Dragging Movieclip Behavior
stopDrag();
//End Behavior
if (this.hitTest(100,470)){
this._x=30;
this._y=458.9;
this.enabled=false;

//play sound clip when correct
_global.congratSound.start(0,1);

//increment variable totalPoint by 1
_global.totalPoint=_global.totalPoint+1;

//Check if totalPoint has reached a value of 6
if(_global.totalPoint == 6) {

//Load congrats movie
this.attachMovie("congrats","newMc",1)
_root.newMC.congrats


//_root.createEmptyMovieClip("con",_root.getNextHighestDepth());
//_root.con.loadMovie("fish.swf");
}

}
else {
this._x=533.5;
this._y=411.4;
}

}

devilmaycry
02-14-2006, 02:40 PM
_root.createEmptyMovieClip("con",_root.getNextHigh estDepth());
_root.con._x=xValue;
_root.con._y=yValue;
//then load ur movie
_root.con.loadMovie("fish.swf");

wattie187
02-14-2006, 02:56 PM
Great, you have been an awsome help and I thank you.
Last stupid question for the day, how the hell do I stop the movie I am loading to stop looping, the publishing setting are set so that it shouldn't loop.

Thanks
Again