Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-29-2008, 05:01 AM   #1
ssej
Registered User
 
Join Date: May 2008
Posts: 1
Default Scrambling Puzzle Pieces

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(:
ssej is offline   Reply With Quote
Old 05-29-2008, 11:18 AM   #2
jungoy
Simplifying Complexity
 
jungoy's Avatar
 
Join Date: May 2008
Posts: 98
Default Jungoy's way to do it...

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);
}
__________________
Pinoy Ako!

Last edited by jungoy; 05-29-2008 at 11:21 AM.
jungoy is offline   Reply With Quote
Old 05-30-2008, 11:55 AM   #3
nite21
Senior Member
 
Join Date: Apr 2008
Location: Mumbai, India
Posts: 441
Default hi

Quote:
Originally Posted by jungoy View Post
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
Attached Files
File Type: zip puzzle.zip (31.5 KB, 196 views)
nite21 is offline   Reply With Quote
Old 05-30-2008, 11:28 PM   #4
jungoy
Simplifying Complexity
 
jungoy's Avatar
 
Join Date: May 2008
Posts: 98
Default

I can't open Flash CS3 file...pls attach Flash version 8 *.FLA file...
__________________
Pinoy Ako!
jungoy is offline   Reply With Quote
Old 05-31-2008, 03:36 AM   #5
Gambyt
Member
 
Gambyt's Avatar
 
Join Date: Apr 2008
Posts: 92
Default

so what do you want to happen when all the items are in the box?
Gambyt is offline   Reply With Quote
Old 05-31-2008, 03:38 AM   #6
Gambyt
Member
 
Gambyt's Avatar
 
Join Date: Apr 2008
Posts: 92
Default

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?
Gambyt is offline   Reply With Quote
Old 05-31-2008, 05:11 PM   #7
nite21
Senior Member
 
Join Date: Apr 2008
Location: Mumbai, India
Posts: 441
Default hi

Quote:
Originally Posted by Gambyt View Post
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 is offline   Reply With Quote
Old 05-31-2008, 05:19 PM   #8
nite21
Senior Member
 
Join Date: Apr 2008
Location: Mumbai, India
Posts: 441
Default

Quote:
Originally Posted by jungoy View Post
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
Attached Files
File Type: zip puzzle(2).zip (9.5 KB, 136 views)
nite21 is offline   Reply With Quote
Old 06-01-2008, 10:23 AM   #9
jungoy
Simplifying Complexity
 
jungoy's Avatar
 
Join Date: May 2008
Posts: 98
Default Jungoy's way to do it...

here it is...
download attached file...
Attached Files
File Type: zip puzzleTest.zip (11.1 KB, 210 views)
__________________
Pinoy Ako!
jungoy is offline   Reply With Quote
Old 06-01-2008, 01:52 PM   #10
nite21
Senior Member
 
Join Date: Apr 2008
Location: Mumbai, India
Posts: 441
Default hi

Quote:
Originally Posted by jungoy View Post
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
nite21 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
function to string? or array to string? pixelgirl ActionScript 2.0 5 09-13-2007 01:30 AM
Help with my actionscripts for jigsaw puzzle game manutd_20 Gaming and Game Development 0 10-05-2005 11:25 PM
Chess Puzzle problems occi ActionScript 1.0 (and below) 2 02-23-2005 07:57 AM
JigSaw Puzzle Problems mash_potatoe Gaming and Game Development 3 11-08-2004 03:46 PM
Drag & Drop puzzle problems. Xenozip Gaming and Game Development 7 09-29-2003 06:49 AM


All times are GMT. The time now is 12:01 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.