Solved

Setting initial draggable mc location to reset at end of quiz

Posted on 2003-11-26
3
210 Views
Last Modified: 2010-04-03
I'd like to be able to set the initial location of each of my draggable movieclips and then reset them to that initial location with the press of a button.

On each button, I was trying:

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

and then trying to reset the mc's location from a button for restarting the program like this:

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

But that doesn't work.

Thank you.
0
Comment
Question by:crazycharlie
3 Comments
 
LVL 9

Expert Comment

by:OBCT
ID: 9829623
Try setting the co-ordinats using this code:

on (release) {          
_root.MC._x = 200;   //_root.instancename._x = your x position
_root.MC._y = 200;   //_root.instancename._y = your y position
}

Just change the instance name and the co-ordinats to suit your needs.

Cheers

-OBCT
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 250 total points
ID: 9830293
here's a much better solution. You don't need to explicitly specify coordinates, let flash work it out for you.

on all the movieclips, that you wish to reset, include the following code:

onClipEvent(load) {
this.startX = this._x;
this.startY = this._y;
}

this will set variables with the starting x and y position for each movieclip.
then on the reset button.

if you've named your movieclips nicely, ie item1, item 2, item3 for example, then you can use a for loop

on (press) {
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;
}
}

otherwise you'll need to call each instance of the movieclip explicitly. (not most efficient, but it works)

on (press) {
mcName._x = mcName.startX;
mcName._y = mcName.startY;
}


0
 

Author Comment

by:crazycharlie
ID: 9832056
blue-genie,

That's exactly what I was looking for.  I think I was setting my variables correctly before, but just not calling them correctly.  It's working now!

You're a life-saver.

Ch@rlie
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now