Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Setting initial draggable mc location to reset at end of quiz

Posted on 2003-11-26
3
Medium Priority
?
256 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 1000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

647 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