Solved

Setting initial draggable mc location to reset at end of quiz

Posted on 2003-11-26
3
247 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

738 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