PDA

View Full Version : problems with if statement


quanneur
04-12-2002, 02:00 AM
Hello,
I feel like an idiot posting this but I'm horribly confused right now.
What is wrong with the following code?

var num;
num = 1;
if (num == 1) {
stop();
}

I have placed this code in the 3rd frame of my movie.
If I put the stop() command outside of the if clause then the movie stops playing in the 3rd frame as it should, but from within the if clause, as above, it doesn't work!

You might be wondering why I'd even bother writing such code in the first place.. well, I'm new to actionscript and am just playing around with things to see what works and what doesn't... i tried that and it just doesn't work although i can't figure out why for the life of me.

any help would be greatly appreciated! i've been through countless tutorials and searched the messages here to no avail....

JHallam
04-12-2002, 02:31 AM
It cannot work like that,

Varibles have to be set at the start of the movie

Create a new movie, two layers

layer 1 have these actions on it

Layer1, FRAME 1

var num;
num=1;

Layer1, FRAME 2

if (num == 1) {
gotoAndStop (5);
}

Layer 2 create 10 frames, on frame 5 type hello and on frame 10 type oh no

then you will see this varible stops frame 5.

Remmeber to set your varibles at the start of the movies.

JHallam
04-12-2002, 02:49 AM
Or you could use

var num;
num = 1;
if (num == 1) {
gotoAndStop(5);
}

but why? you might aswell use

basic
gotoAndStop(5);

instead of varible way, earlier post was set example where you can now grow on

quanneur
04-12-2002, 03:27 AM
thanks a lot for your help!

I did exactly like you said, though, and it still doesn't work.. "hello" flashes on the screen quickly and then "oh no" flashes on the screen quickly and it just loops forever... (when i export i set it to loop)

i did exactly like you said to, no more and no less.. do you have to declare a layer an action layer or something?

JHallam
04-12-2002, 03:37 AM
you must be doing it wrong somehow, here is a ZIP file I have for you the example works fine.

Even if its on loop settings We made the movie to STOP at a certain frame :D

Here is a FLA

quanneur
04-14-2002, 03:54 AM
thanks grafix...

so i realized what my problem was.
i was exporting my movie to quicktime to test it out and for some reason the if clauses do not work in quicktime! If I test out the movie in flash player then it works fine.. really weird!

another thing, i've imported a graphic that is 500x 300 pixels into my movie. when i place it on the stage it appears much smaller than it should be at 100% scale... when i double click on the graphic in the library so that i get the properties window, it tells me the graphic is indeed 500x300! when i set the scale to 250% so that it shows up at the size it should, the image quality is terrible! Any ideas on why this would be???

Thanks..

JHallam
04-14-2002, 09:25 AM
Do a search you will find lots of answers for that criteria.

:)