# Basic button to play movie AS question - please help

**URL:** https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097
**Category:** flash
**Created:** [September 2, 2004, 11:14pm UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097 "2004-09-02T23:14:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hendrixcatt](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hendrixcatt](https://forum.kirupa.com/u/hendrixcatt)
#### Post date: [September 2, 2004, 11:14pm UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/1 "2004-09-02T23:14:57Z")

</div>

I’m trying (and failing it seems) to teach myself Action script and I’m having a really tough time with what I’m sure is something that quite easy to do.

Basically I have one button. When this button is pressed I’d like it play a movie. When the button is pressed again I’d like to stop playing the movie.

In the first frame of the movie I’ve put a stop action so that it doesn;t repeat itself when it finishes playing. In the last frame of the movie I’ve put gotoAndStop(2);

In my main timeline I have 2 layers each of which has one frame. The button is one layer and the movie on the other.

I selected the button on the stage and gave it the actionscript  
on (press){  
gotoAndPlay(“vcsound\_mc.play(2)”);  
}

I then selected the movie clip and added the action script:

this.vcsound\_mc.onPress = function() {  
play();  
};  
trace(“frame 2”);

When I checked the syntax in Flash it said there were no errors. But when I test the movie it doesn’t work.

All you clever flash people out there will probably be howling at this infantile attempt at actionscript but please remeber what it was like the first time you struggled with actionscript…I’ve read so many tutorials now that I’m completely confused…

---

<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 3, 2004, 4:28am UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/2 "2004-09-03T04:28:44Z")

</div>

on (press){  
\_root.gotoAndPlay(2);  
}

on (press){  
\_root.gotoAndStop(15);  
}

---

<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 3, 2004, 6:07am UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/3 "2004-09-03T06:07:08Z")

</div>

on (press) {  
(playing=!playing) ? stop() : play();  
}

you can use gotoAndStop(whatever) instead of stop()  
and gotoAndPlay(whatever) instaed of play() if needed

---

<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 3, 2004, 8:33am UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/4 "2004-09-03T08:33:04Z")

</div>

Thank you.  
Even dumber question (told you I was hopeless at this!) Do I add this code to the movie timeline or the movie in the main timeline or do I add it to the button timeline or the button in the main timeline? (as you can see I’m completely clueless!) also for the button - do i need two frames in the main timeline one for play and one for stop?

---

<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 3, 2004, 4:55pm UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/5 "2004-09-03T16:55:40Z")

</div>

Ok - just to say that I worked it out!!! thank you so much 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: [September 3, 2004, 6:09pm UTC](https://forum.kirupa.com/t/basic-button-to-play-movie-as-question-please-help/63097/6 "2004-09-03T18:09:44Z")

</div>

> [@hendrixcatt](#):
>
> Ok - just to say that I worked it out!!! thank you so much for your help.

Glad you worked it out
