# gotoAndPlay(variable);?

**URL:** <https://forum.kirupa.com/t/gotoandplay-variable/260804>\
**Category:** Uncategorized\
**Created:** [May 20, 2008, 2:40am UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804 "2008-05-20T02:40:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy1](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Andy1](https://forum.kirupa.com/u/Andy1)\
**Post date:** [May 20, 2008, 2:40am UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/1 "2008-05-20T02:40:44Z")

</div>

Is there such thing? Because I’ve tried it, and it does not work.  
I have something like:

\_root.memory = \_currentframe();

and somewhere else have

gotoAndPlay(\_root.memory);

---

<div class="post-metadata">

**Author:** ![Macsy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/macsy/32/3238_2.png) [@Macsy](https://forum.kirupa.com/u/Macsy)\
**Post date:** [May 20, 2008, 6:11am UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/2 "2008-05-20T06:11:25Z")

</div>

Where do you have this code?

---

<div class="post-metadata">

**Author:** ![Macsy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/macsy/32/3238_2.png) [@Macsy](https://forum.kirupa.com/u/Macsy)\
**Post date:** [May 20, 2008, 6:20am UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/3 "2008-05-20T06:20:05Z")

</div>

Switch:  
[http://www.kirupa.com/developer/actionscript/switchcase.htm](http://www.kirupa.com/developer/actionscript/switchcase.htm)

Key listner:  
Check F1-help for Key.getCode and the example they have will bring up listner.

allso check AttachMovie() in F1-help for attaching MCs to the stage. Be sure to read everything becouse there is a part about linkage.

Without this you cant chance ‘map’ or ‘level’ .

---

<div class="post-metadata">

**Author:** ![Macsy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/macsy/32/3238_2.png) [@Macsy](https://forum.kirupa.com/u/Macsy)\
**Post date:** [May 20, 2008, 8:37am UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/4 "2008-05-20T08:37:32Z")

</div>

post in wrong, amagad!

---

<div class="post-metadata">

**Author:** ![Valaran](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@Valaran](https://forum.kirupa.com/u/Valaran)\
**Post date:** [May 20, 2008, 12:06pm UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/5 "2008-05-20T12:06:39Z")

</div>

[quote=- Andy -;2328451]Is there such thing? Because I’ve tried it, and it does not work.  
I have something like:

\_root.memory = \_currentframe();

and somewhere else have

gotoAndPlay(\_root.memory);[/quote]

Your error lies elsewhere, that should work, just tested it myself. A personal tip though, try to keep all code in the main timeline, if you do you could do something like:

```auto

var memory:Number = _currentframe;
yourmovieclip.gotoAndPlay(memory);

```

Therefore not having to worry about scopes.

---

<div class="post-metadata">

**Author:** ![JBPresents](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@JBPresents](https://forum.kirupa.com/u/JBPresents)\
**Post date:** [May 20, 2008, 4:22pm UTC](https://forum.kirupa.com/t/gotoandplay-variable/260804/6 "2008-05-20T16:22:50Z")

</div>

yes the main timeline is important but i don’t understand why you are calling the current frame? whats the point of sending it to the point it is already at

also if your doing coding on a movie clip you should invest time into classes they are a huge time saver and help keep different parts of your code separate
