Solved

Setting initial draggable mc location to reset at end of quiz

Posted on 2003-11-26
3
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

695 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