# attachMovie and button. Help please

**URL:** <https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710>\
**Category:** flash\
**Created:** [September 9, 2004, 11:09am UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710 "2004-09-09T11:09:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mx\_guest2004](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mx\_guest2004](https://forum.kirupa.com/u/mx_guest2004)\
**Post date:** [September 9, 2004, 11:09am UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/1 "2004-09-09T11:09:03Z")

</div>

Hi,  
I have used attachMovie to put a button on the stage. And under the attachMovie code I have an button.onRelease or button.onPress:  
[AS]  
pauseButton.onPress=someFunction(x,y );  
[/AS]  
The problem is that the function runs at the begining of the movie without using that button at all. I have a stop all movieClip function and the movie stops. When I remove the onPress, then movie runs as normal but I don’t have the button neither.  
I need this attachMovie method to have that button on all my scenes.

Any help on this please? 🙂  
mx-guest2004

---

<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:** [September 9, 2004, 12:11pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/2 "2004-09-09T12:11:09Z")

</div>

> [@mx-guest2004](#):
>
> Hi,  
> I have used attachMovie to put a button on the stage. And under the attachMovie code I have an button.onRelease or button.onPress:  
> [AS]  
> pauseButton.onPress=someFunction(x,y );  
> [/AS]  
> The problem is that the function runs at the begining of the movie without using that button at all. I have a stop all movieClip function and the movie stops. When I remove the onPress, then movie runs as normal but I don’t have the button neither.  
> I need this attachMovie method to have that button on all my scenes.
> 
> Any help on this please? 🙂  
> mx-guest2004

pauseButton.onPress = function() {  
someFunction(x, y);  
};

---

<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:** [September 9, 2004, 12:59pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/3 "2004-09-09T12:59:09Z")

</div>

Thanks a lot stringy 🙂 🙂 It works now.  
Your pause function works very fine as well.  
Thanks again for all help.

mx-guest2004

---

<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:** [September 9, 2004, 1:25pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/4 "2004-09-09T13:25:36Z")

</div>

Just one more thing about the pause function.  
I have used AS for my MCs and used as you said the container[obj].onEnterFrame;  
it works fine for pausing the animation, but what about going back to playing again?  
Is it possible to play from where it stopped?

mx-guest2004

---

<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:** [September 9, 2004, 2:09pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/5 "2004-09-09T14:09:22Z")

</div>

> [@mx-guest2004](#):
>
> Just one more thing about the pause function.  
> I have used AS for my MCs and used as you said the container[obj].onEnterFrame;  
> it works fine for pausing the animation, but what about going back to playing again?  
> Is it possible to play from where it stopped?
> 
> mx-guest2004

could you remind me of the code i used and perhaps include the code you are using as well.

---

<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:** [September 9, 2004, 2:36pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/6 "2004-09-09T14:36:12Z")

</div>

Here is your code:  
[AS]  
function DoAll(container, func) {  
containerfunc;  
for (var obj in container) {  
if (typeof (container[obj]) == “movieclip”) {  
container[obj]func;  
for (var mob in container[obj]) {  
if (typeof (container[obj][mob]) == “movieclip”) {  
container[obj][mob]func;  
}  
for (var dab in container[obj][mob]) {  
if (typeof (container[obj][mob][dab]) == “movieclip”) {  
container[obj][mob][dab]func;  
}  
}  
}  
}  
}  
}  
//DoAll(\_root, “stop”);  
[/AS]  
and for the case of AS:  
[AS]  
function DoAll(container, func) {  
containerfunc;  
for (var obj in container) {  
if (typeof (container[obj]) == “movieclip”) {  
delete container[obj].onEnterFrame;  
}  
[/AS]  
I have used the code for AS. It works fine for pause, but I don’t know the method of playing the movie again.

mx-guest2004

---

<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:** [September 9, 2004, 3:34pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/7 "2004-09-09T15:34:50Z")

</div>

> [@mx-guest2004](#):
>
> Here is your code:  
> [AS]  
> function DoAll(container, func) {  
> containerfunc;  
> for (var obj in container) {  
> if (typeof (container[obj]) == “movieclip”) {  
> container[obj]func;  
> for (var mob in container[obj]) {  
> if (typeof (container[obj][mob]) == “movieclip”) {  
> container[obj][mob]func;  
> }  
> for (var dab in container[obj][mob]) {  
> if (typeof (container[obj][mob][dab]) == “movieclip”) {  
> container[obj][mob][dab]func;  
> }  
> }  
> }  
> }  
> }  
> }  
> //DoAll(\_root, “stop”);  
> [/AS]  
> and for the case of AS:  
> [AS]  
> function DoAll(container, func) {  
> containerfunc;  
> for (var obj in container) {  
> if (typeof (container[obj]) == “movieclip”) {  
> delete container[obj].onEnterFrame;  
> }  
> [/AS]  
> I have used the code for AS. It works fine for pause, but I don’t know the method of playing the movie again.
> 
> mx-guest2004

well i`ve been playing about trying to store the names of functions etc in an array but so far failed. If you are using buttons, you could always get it to goAndPlay another frame, which in turn would have an action on to goAndStop this frame.

---

<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:** [September 9, 2004, 4:23pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/8 "2004-09-09T16:23:37Z")

</div>

I modified your code a little bit. No it doesn’t stop EXACTLY at the same frame. It seems that the current AS finishes first(for example scaling up being completed first) and then the movie stops. When play button been pressed (or released) thee movie continues. Here:

[AS]  
function DoAll(container, func) {  
containerfunc;  
for (var obj in container) {  
if (typeof (container[obj]) == “movieclip”) {  
\_global.stopFrame=\_root.\_currentFrame; //the frame movie stopped  
gotoAndStop(\_root.container[obj].\_currentFrame-1);  
//delete container[obj].onEnterFrame; //not this one  
}  
}  
}  
[/AS]  
and then for the play button:  
[AS]  
playButton.onPress=function(){  
gotoAndPlay(\_global.stopFrame+1);  
}  
[/AS]  
So far. We’ll see if we can get better.  
I have another important question too:  
Is there any typeOf operator for shapes?

mx-guest2004

---

<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:** [September 9, 2004, 6:28pm UTC](https://forum.kirupa.com/t/attachmovie-and-button-help-please/63710/9 "2004-09-09T18:28:00Z")

</div>

> [@mx-guest2004](#):
>
> I modified your code a little bit. No it doesn’t stop EXACTLY at the same frame. It seems that the current AS finishes first(for example scaling up being completed first) and then the movie stops. When play button been pressed (or released) thee movie continues. Here:
> 
> [AS]  
> function DoAll(container, func) {  
> containerfunc;  
> for (var obj in container) {  
> if (typeof (container[obj]) == “movieclip”) {  
> \_global.stopFrame=\_root.\_currentFrame; //the frame movie stopped  
> gotoAndStop(\_root.container[obj].\_currentFrame-1);  
> //delete container[obj].onEnterFrame; //not this one  
> }  
> }  
> }  
> [/AS]  
> and then for the play button:  
> [AS]  
> playButton.onPress=function(){  
> gotoAndPlay(\_global.stopFrame+1);  
> }  
> [/AS]  
> So far. We’ll see if we can get better.  
> I have another important question too:  
> Is there any typeOf operator for shapes?
> 
> mx-guest2004

No, there is no typeof operator for shapes.
