PDA

View Full Version : movie wont play or stop when needed to



TheAgent
10-30-2010, 10:23 PM
I have a movie clip that will play if Score = 0 it does technically play
but remains frozen at the first frame. After the stop command i set it to play when "Start" is called however as i said it only plays the first frame and stops, almost as if i told it to "gotoAndStop(Start); however i put "gotoAndPlay("Start"); but it remains stopped, and i made sure that there arent any stop(); commands lying around.

actionscript code



_global.gfxExtensions = true ;

import flash.external.ExternalInterface;
//...
// much of the game will be visual then uscript through flash.

var Score:Number = 0;
var Balls:Number = 3;

text1.text = "Score : " + Score;
text2.text = "Balls : " + Balls;

function addScore(intScore:Number)
{
Score = intScore + Score;
text1.text = "Score : " + Score;
}
//technically subtract pinballs
function subBalls(intBalls:Number)
{
Balls = intBalls + Balls;
text1.text = "Balls : " + Balls;

}
//Begining
if (Score == 0)
{
flasher.gotoAndPlay("Start");
} else if (Score > 1){
flasher.gotoAndStop(1);
}
//End of notification


//PINBALL FUNCTIONS
// what to do if you have a certain amount of balls ;D
if (Balls == 0) //end game Uscript call if balls equals zero
{
ExternalInterface.call("OutofPinBalls");
//if pinballs equals 1 then load a warning.
} else if (Balls == 1){
loadMovieNum("lowpinballs.swf",2);
} else if (Balls >= 2){ //else make sure its unloaded
unloadMovie("lowpinballs.swf");

} else {
//do nothing homie!... for now.
}
//VISIBLE Point TROPHIES

if (Score >= 9500)
{// first trophy
loadMovieNum("ninektrophy.swf",3);
} else if (Score >= 15500) {
loadMovieNum("fiffivetrophy.swf",4);
} else if (Score >= 25500) {
loadMovieNum("twofivetrophy.swf",5);
} else if (Score >= 50500) {
loadMovieNum("halfhundredtrophy.swf",6);
} else if (Score >= 101000){
loadMovieNum("onehundredtrophy.swf",7);
} else if (Score >= 500000){
loadMovieNum("fivehundredtrophy.swf",8);
} else if (Score >=1000000){
loadMovieNum("millionairetrophy.swf",9);
} else if (Score >=2000000){
loadMovieNum("needsalifetrophy.swf",10);
}
//End of Score Trophy system






not sure what to do. Thanks

Note: the loadMovieNum's will be replaced.

TheAgent
10-31-2010, 02:49 PM
It does the same in CS4 and CS5 Flash, so im not sure it has to be the code i guess even tho it seems perfectly fine

TheAgent
11-01-2010, 08:33 AM
bump i cant get this to work.

Nysuatro
11-01-2010, 09:29 AM
I am not really sure what you want. But the if statement will only be evaluated once.
If you want it to be read more you will have to use onenterframe or .... But you have to watch out with that. It can make your swf lag/slow.

There is a possibility that what I am saying is totally wrong :D

TheAgent
11-01-2010, 09:32 AM
my problem is that it only plays the first frame when it should play the whole time line of the movie clip and yeah then it doesn't do the "else if" statement so i guess i gotta use on enter frame?

Edit: i seem to got something working by putting a play(); command inside of the flasher movie clip on frame 2, frame one is a stop command so it wont play right on load. My only problem is overriding the stop(); command so it can loop until i stop it when i get over 0 points.

Edit 2: I got it to loop however the else if statement doesn't fire in the editor, it works fine in flash, least i think it does


if (Score == 0)
{
flasher.gotoAndPlay(2);
} else if (Score == 105){
flasher.gotoAndStop(1);
}

Matt Doyle
11-01-2010, 01:05 PM
Well, there are a number of things you could do to get this working.

1. You could wrap all these if statements inside an onEnterFrame() and loop the timeline, but this is expensive and not recommended. The score should really only update the flasher when a score change occurs.
2. Instead, you could put all the score "if" tests inside a function, then call that function from UnrealScript anytime a score event occurs using ActionScriptVoid().
3. You could also call the score flasher function from the addScore function, which I assume is being called by UnrealScript already.

Here's what I'd do:

UnrealScript:


function UpdateScore(Int score) {
ActionScriptVoid("UpdateScore");
}

ActionScript:


function UpdateScore(score:Number):Void {
if (score == 0) {
flasher.gotoAndPlay(2);
}
else if (Score >= 1) {
flasher.gotoAndStop(1);
}
}

TheAgent
11-01-2010, 01:09 PM
Thank you, i got it working by using a setinterval command that reiterates through the command until it updates, but this is much better : D