PDA

View Full Version : Draggable Movie Questions...


Cr@zyCh@rlie
11-24-2003, 09:27 PM
I have a Flash 5 project that has x number of draggable movies and the same number of targets. Only one target per movie is correct. When the user drags all the movies onto the correct targets, they get a movie that congratulates them. If the user drags all items incorrectly, there's a movie that tells them the order is incorrect and asks them to try again.

The problems I'm encountering:

1) If the user drags gets at least one item correct, but doesn't drag all items to their correct box, I need a way to send them to the movie telling them to try again.
2) The try again movie needs to have a button that will reset the test but give them only two more chances to get it right. (So, a global counter incrementing per incorrect series.)
3) Once they've incorrectly placed the items 3 times, they need to be sent to a third movie telling them they need to start the lesson over from the beginning.
4) I need a way to create a button to globally restart the flash program without actually reloading the html page.

Here's what I have working so far.

http://www.creativeflavor.com/DragableChoices.swf

Thank you for the help!

tg
11-25-2003, 11:36 AM
create an init() function that sets all the movieclips to their default (beginning) positions.

in your library create a movie clip with the message to try again and a button on it.
the button should increment your badtry counter, and call _root.init() - this will reset the game to the original layout. the movieclip with the button should then remove itself.


so when the user tries dragging and dropping the mcs, but gets anyone of them wrong, you attach your wronganswer mc, the user can click the button and reset the game, the game is reset, the counter is incremented, and the mc unattaches itself so the user can try again.

Cr@zyCh@rlie
11-25-2003, 11:46 AM
tg,

Thanks for the quick response! :D I'll give this a try.

Ch@rlie

Cr@zyCh@rlie
11-25-2003, 03:28 PM
tg,

Would you mind giving me more assistance with the init () function to set the starting location for each of the draggable mc's? I've tried several times to build this with no success.

I've got the movieclip with the button hiding itself and re-enabling all the buttons, but the starting location isn't set.

Here's what I've got now.

http://www.creativeflavor.com/DragableChoices.swf

Thank you. :)

Ch@rlie

tg
11-25-2003, 04:01 PM
take a look at this... its just a mock up, and kinda of poorly done, i am booked up with work right now, and only stopped by for a seck to let my mind float a bit.

again, this is a mock up... there are much better and more efficient ways to do this... but you'll get the idea of what i'm talking about with this.

Cr@zyCh@rlie
11-25-2003, 04:22 PM
tg,

Thanks! Happy Thanksgiving.

Ch@rlie

tg
11-25-2003, 04:25 PM
no problem... enjoy yours too.

Cr@zyCh@rlie
11-26-2003, 09:11 PM
tg,

I wasn't able to view the initdemo.fla. I'm assuming it is because it was built in MX? I'm running Flash 5.

Thanks.

Ch@rlie

Cr@zyCh@rlie
11-26-2003, 11:26 PM
tg,

I've looked at this further and my program is now completing all functions except for resetting the original location of the draggable mc's. I'm not sure how to set the initial location. I've tried setting something similar to this on each button:

_root.xpos1 = _target._x;
_root.ypos1 = _target._y;

and then trying to reset the mc's location from the restart button like this:

setProperty ("Button1", _x, _root.xpos1);
setProperty ("Button1", _y, _root.ypos1);

But that doesn't work.

Am I missing something? :(

Thanks.

tg
12-01-2003, 12:55 PM
ok, say you've got your mcs out on the stage...

then in your code do this:


/*m1-m3 are the moveable mcs
t1-t3 are the targets... these really dont need to be set here
since you've placed them on the stage....
anyway, when the init() function is run, it will position your mcs
where you want them, and just recall it, when you want to refresh.
*/
init=function(){
//set position for all of the moveable parts
m1._x=m2._x=m3._x=25;
t1._x=t2._x=t3._x=175;
t1._y=m1._y=25;
t2._y=m2._y=175;
t3._y=m3._y=325;
}
//call the function that positions all of the moveable parts. so that they are layed out.
init();

Cr@zyCh@rlie
12-01-2003, 01:30 PM
tg,

Thanks. I'd actually figured out how to do this but forgot to reply. Sorry 'bout that.

For my variables, I was setting them correctly using:

_root.xpos1 = _target._x;
_root.ypos1 = _target._y;

But wasn't calling them correctly. To be more dynamic, I am using this, which works great:

for (i=1; i<4; i++) {
_root["item" add i]._x = _root["item" add i].startX;
_root["item" add i]._y = _root["item" add i].startY;
}

In the on (release) function.

Thanks again for all your assistance!