PDA

View Full Version : flash game help


Midget
03-12-2007, 01:20 PM
i'm trying to make a jigsaw puzzle for my crap uni project where the pieces will snap into place when close to their correct position

this is the actionscript i've got on the piece
on (press) {
startDrag("p1");
}

on (release) {
stopDrag();
if (p1._x>25 && p1._x<65 && p1._y>105 && p1._y<145)
p1._x = 45;
p1._y = 125;
}
(p1 is the instance name of the piece if you couldn't tell, and x=45, y=125 is the correct position of it)

now the y snapping works fine, if you put the piece within 20 pixels of it's position it will snap into it's y position perfectly

however, the x snapping is messed up, it snaps into it's x position regardless of where you place it on the board

the compiler doesn't give any errors when i test the actionscript, so i don't understand what's happening

it's here (http://img514.imageshack.us/my.php?image=projectgs4.swf) if you want to have a look (go to games > jigsaw puzzle... only the first piece has any actionscript on it so far btw, so the others won't do anything)

i know it's crap but it's all my course expects of me :/ (it obviously isn't finished either)

any help appreciated :)

Bewildebeast
03-12-2007, 01:57 PM
Your bracketing is off. Should be:


on (release) {
stopDrag();
if (p1._x>25 && p1._x<65 && p1._y>105 && p1._y<145)
{
p1._x = 45;
p1._y = 125;
}
}

It's the y snapping that's not working. You had no opening bracket for the If block, so only the first statement (p1._x = 45;) was part of that block; p1._y = 125 was processed regardless. The last curly bracket closed the on(release) block.

The compiler doesn't give any errors because it's syntactically and logically valid; it's just that the logic is wrong.

Midget
03-12-2007, 08:15 PM
ahhh, i never would've noticed that

cheers :)

edit: argh i'm having another problem

i want to put another video onto it, but it keeps saying
**Warning** The linkage identifier 'FLVPlayback' was already assigned to the symbol 'trailer2/trailer2vid', and cannot be assigned to the symbol 'video/trailer', since linkage identifiers must be unique.
but it won't let me change the linkage identifier for either video

ideas anyone?

Roachy
03-12-2007, 09:39 PM
Sorry to go a little off-topic but your grunt game is lol.
http://img148.imageshack.us/img148/5792/71739585vs3.png

Midget
04-12-2007, 12:14 AM
yeah i know, it needs fixing

it was supposed to be clicks vs hits but i messed it up

needs more results aswell lol