PDA

View Full Version : Scrambling Puzzle Pieces


ssej
05-29-2008, 06:01 AM
Hi,
I am a newbie at actionscript, i started learning it 2 days ago for a project. For the project ive made a puzzle. I am having problems creating a Scramble button, a button that the user can press to scramble the puzzle pieces.
Each piece is its own movie clip (with a button inside it) and each movie clip is named as follows: piece1, piece 2, piece 3 etc.
On the Scramble button i was thinking that i could put:
on (release){
_root.piece1._x = Math.floor(Math.random()*100);
_root.piece1._y=Math.floor(Math.random()*100)+40;
_root.piece2._x = Math.floor(Math.random()*100);
_root.piece2._y=Math.floor(Math.random()*100)+40;
(etc.)
}
but of course this doesnt work. Im having problems knowing where to go from here.
Any suggestions would be greatly appreciated(:

jungoy
05-29-2008, 12:18 PM
try if this script will work: let's say your stage width is 300 and height 100.
use only 1 button to randomize all puzzle pieces.

on (release){
_root.piece1._x = random(300);
_root.piece1._y= random(100);
_root.piece2._x = random(300);
_root.piece2._y= random(100);
}

nite21
05-30-2008, 12:55 PM
try if this script will work: let's say your stage width is 300 and height 100.
use only 1 button to randomize all puzzle pieces.

on (release){
_root.piece1._x = random(300);
_root.piece1._y= random(100);
_root.piece2._x = random(300);
_root.piece2._y= random(100);
}

hi jungoy i have made the sample file for puzzle
here there are 4 mcs piece1,piece2,piece3,piece4
and there is a target_mc where the above 4 movieclips have to be placed
correct mc should be placed in the target_mc in correct order 1,2,3,4

also i have to start the timer again when i restart the button

jungoy
05-31-2008, 12:28 AM
I can't open Flash CS3 file...pls attach Flash version 8 *.FLA file...

Gambyt
05-31-2008, 04:36 AM
so what do you want to happen when all the items are in the box?

Gambyt
05-31-2008, 04:38 AM
I rearranged a couple things just to make it easier overall. I have your timer resetting when you hit the scramble button, just need to know what you want to happen when all items are in the box. The scramble works just fine, was there something else you wanted to do with it?

nite21
05-31-2008, 06:11 PM
I rearranged a couple things just to make it easier overall. I have your timer resetting when you hit the scramble button, just need to know what you want to happen when all items are in the box. The scramble works just fine, was there something else you wanted to do with it?

hi gambyt
thanks

there are 4 movieclips piece1 piece2 piece3 and piece4

and there should be a target_mc for keeping this pieces in order

and if suppose piece2 is added in the target 1 col it should not be dropped there

and for the timer it should be in sec and ms

when the scramble btn is clicked the pieces should be in randomly positioned

and when i clik the reset btn it should start from beginning the timer also

and when the mcs are arranged in correct order the game ends message should be displayed

nite21
05-31-2008, 06:19 PM
I can't open Flash CS3 file...pls attach Flash version 8 *.FLA file...

sorry jungoy
here is the flash 8 format


there are 4 movieclips piece1 piece2 piece3 and piece4

and there should be a target_mc for keeping this pieces in order

and if suppose piece2 is added in the target 1 col it should not be dropped there

and for the timer it should be in sec and ms

when the scramble btn is clicked the pieces should be in randomly positioned

and when i clik the reset btn it should start from beginning the timer also

and when the mcs are arranged in correct order the game ends message should be displayed

jungoy
06-01-2008, 11:23 AM
here it is...
download attached file...

nite21
06-01-2008, 02:52 PM
here it is...
download attached file...

jungoy thanks very much

but some changes have to be made

1)if i drag the piece1 to any of this container 2 3 or 4 it automatically places the piece1 to container 1

i wanted that if i drag piece1 to any of wrong places it shouldnt be placed there
and also not automatically be placed to piece1 also
only if i place piece1 to container1 it is right

2)after game over game over message should be displayed along with Try Again
and the user after game over should not be able to drag or drop the box
means the button should be disabled