View Full Version : IFs and ANDs
I'd like an IF statement to check for two conditions.
What's the correct syntax?
eg: if (x==1) and (y==2) { ...
(I know that's incorrect; it's for clarification purposes.)
Thanks.
CyanBlue
05-31-2003, 09:06 PM
Howdy and Welcome... ;)
Try this...if ((x == 1) && (y == 2)) { ...
Great, thanks.
Unfortunatly, I'm starting to think that wasn't the problem. This snippet may seem criptic, but perhaps someone can help me...
The code is part of the control script for a movieclip. It seems that the clip doesn't like the way i'm using hitTest.
if ((dir == 1) && (_root.exits.room.brick.hitTest(_x,_y-21,true))){dir=5}
dir is a random number between 1 and 8. It's used to determine which way the object movies. 1 through 4 means that it will move 20 pixels up, down, left, or right. 5 through 8 means it does nothing.
So, in order to check to see if there's open space in the direction it would hypothetically be heading, i use the above line.
In that line, if the object will be moving up (1), and 21 pixels above the center of the object is occupied by a 'brick', then make dir = 5.
(If dir equals 5, then the clip won't move)
(The 21 is there because it's measuring from the center of the movieclip, and the object has a radius of 20 px.)
Anyway... the 'bricks' movieclip is nested in the 'room' movieclip, which is nested in the 'exits', which is in the root.
... i'm not sure i actually communicated anything just now...
Hey, it's a long shot, but maybe someone will see a stupid mistake...
I can't believe it. I'm stupid.
I neglected to mention what the actual bug was. It's this:
The object moves around beautifully, but it just doesn't seem to register any sort of hit. It goes through walls, for example.
... perhaps it'd be best if i started from square one, and just asked if anyone knows any strange quirks with hitTest, and nexted movie clips.
It could have something to do with the way i've placed the clip. I have a movieclip with the object in it, and actions on that object. Then the entire clip is placed.
Am i allowed to do that, conventionally? Have the actions for an object not on the clip itself, but in a parent clip, that's placed where the child clip is needed? (Just so i don't need to paste in the actioscript again).
It would appear i started rambling again.
How would I post 'an example'?
CyanBlue
06-01-2003, 02:52 AM
It could have something to do with the way i've placed the clip. I have a movieclip with the object in it, and actions on that object. Then the entire clip is placed.
Am i allowed to do that, conventionally? Have the actions for an object not on the clip itself, but in a parent clip, that's placed where the child clip is needed? (Just so i don't need to paste in the actioscript again).I don't see why not... ;) I suggest you create a simple sample that just have desired effect and script on a new movie, and work on that to make sure you don't get interfered with some other factor in your movie... and once that's working, then you can reapply that to your main movie file...
To upload the file, you can use 'Attach File' section that can be found right above the 'Submit Reply' button... There is a size restriction and file type restriction you have to be careful about... ;)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.