# Howto swap instances with actionscript?

**URL:** <https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759>\
**Category:** Uncategorized\
**Created:** [November 16, 2003, 2:51pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759 "2003-11-16T14:51:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ranoka](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ranoka/32/265_2.png) [@Ranoka](https://forum.kirupa.com/u/Ranoka)\
**Post date:** [November 16, 2003, 2:51pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/1 "2003-11-16T14:51:12Z")

</div>

Hi,  
How can I swap instances using actionscript? Similar to the way you would when you use the swap symbols button on the propertys tool bar.

I want to swap the graphics of the mouse after an event occurs.

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 5:05pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/2 "2003-11-16T17:05:19Z")

</div>

okay, well the best way I’ve come up with so far is to make a movie clip, and to place the different symbols into it and use actionscript to change between the frames .

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 5:10pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/3 "2003-11-16T17:10:12Z")

</div>

You can do that or just tell a new graphic to snap to the mouse…

[AS]  
onClipEvent(enterFrame) {  
this.\_x = \_root.\_xmouse ;  
this.\_y = \_root.\_ymouse;  
}  
[/AS]

using that type of code you can only have one at a time

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 5:22pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/4 "2003-11-16T17:22:56Z")

</div>

I’ve been using  
[AS]startDrag(“hand”, true);  
Mouse.hide();[/AS]

I guess your code is an alternative way of doing it that is backward compatible with flash 5.

thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 5:26pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/5 "2003-11-16T17:26:57Z")

</div>

Sure…either one works :)…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 16, 2003, 9:03pm UTC](https://forum.kirupa.com/t/howto-swap-instances-with-actionscript/94759/6 "2003-11-16T21:03:14Z")

</div>

Create different frames inside the mouse movieclip symbol, add a stop() action to frame 1 (so it doesn’t start off looping through them)

Then on the events you want just use [AS]mouseMovieClipSymbolInstanceName.gotoAndStop(frameNumWithCorrectPointer)[/AS]

If I understood correctly 😛
