attachMovie and button. Help please

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? :slight_smile:
mx-guest2004

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

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

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.

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.

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.