melanie_me,
[quoted text, click to view] > know this must be simple to fix!
Maybe! Maybe not. ;)
[quoted text, click to view] > I want the movie to "wait" until play is pressed again after
> the movie plays through once...
>
> I've tried placing stop(); and gotoAndStop(1); on the last
> frame of the movie with no luck...
Let's take a look under the hood.
[quoted text, click to view] > Here's my code:
>
> movie_mc.stop();
> playing = FALSE;
So far, we're asking a movie clip with the instance name movie_mc to
perform the MovieClip.stop() method -- that is, we're asking that particular
clip to stop.
We're also setting a variable named playing to the boolean value false.
[quoted text, click to view] > this.onEnterFrame = function() {
>
> _root.movieSound.onSoundComplete = function() {
This next part gets a bit dicey. The global property "this" refers to
the timeline or object it's in. In this case, "this" refers to the timeline
that contains the frame in which this code sits. So far, so good. All
timelines are movie clips -- even the main timeline, so it's fine to assign
a function to this timeline's MovieClip.onEnterFrame event. The problem is
what you're putting inside this function.
Your first line assigns a function to the Sound.onSoundComplete event of
a Sound instance (movieSound) located in the _root (aka the main timeline).
You only need to assign a function to movieSound's onSoundComplete event
once, but you're doing again and again; in fact, every time the movie enters
a frame. By default, SWFs are 12fps, which means you may be assigning this
same function to that Sound object's event 12 times a second!
In addition (again, perhaps 12 times a second), you're doing the
following ...
[quoted text, click to view] > playing=false;
> stopped=true;
> paused=false;
> _root.movieSound.stop();
> _root.movieSound.start(0,0);
> _root.movieSound.stop();
> }
So you're setting three variables to either true or false, then telling
movieSound to stop, start, then stop again. This happens continuously
throughout the duration of your movie -- until the user goes to another page
or closes the browser.
Now, separate from that, you're assigning yet another function (in fact,
the same one), to movieSound's onSoundComplete event again!
[quoted text, click to view] > // Detect end of audio----------------------------------
> _root.movieSound.onSoundComplete = function() {
>
> playing=false;
> stopped=true;
> paused=false;
> _root.movieSound.stop();
> _root.movieSound.start(0,0);
> _root.movieSound.stop();
> }
This wouldn't necessarily cause your problem, but it's definitely asking
a lot of the processor -- and, heck, it *might* just be contributing to the
issue you're seeing.
[quoted text, click to view] > play_btn.onRelease = function () {
> if (playing != true) {
> movie_mc.play();
Here, you're assigning a function to the Button.onRelease event of a
particular button instance. The first thing you're asking this button to do
is to check if a variable named playing is not true (that is, false). Where
is this variable scoped? Does the playing variable appear inside play_btn?
Does playing appear in the main timeline?
Elsewhere in your code, you've used _root and "this" to let ActionScript
know where a given object was -- so you may want to consider doing the same,
here. Every object in ActionScript has a "home," and objects nest inside
each other just like movie clips do. In fact, movie clips *are* objects
(they're instances of the MovieClip class), so that hierarchical business
makes perfect sense.
Moving on, this button checks if another variable, named paused, is not
true.
[quoted text, click to view] > //
> if (paused != true) {
> _root.movieSound.start(0, 0);
> playing=true;
> stopped=false;
> paused=false;
If it's not true (that is, if it is false), the button tells movieSound
to invoke its Sound.start() method, then sets a few variables. Notably, the
button is instructed to set the paused variable to false. So if paused is
false, set paused to false, otherwise ...
[quoted text, click to view] > } else {
> _root.movieSound.start(_root.soundPosition,0);
> playing=true;
> stopped=false;
> paused=false;
.... set paused to false.
Do you see where some of this stuff is unclear? I'm not slamming you,
by the way. I promise. :) Sometimes it helps, I think, to step through
code in a conversational way, to see what you're actually asking
ActionScript to do.
Now, we have another button.. Again, here's a function assigned to its
Button.onRelease event.
[quoted text, click to view] > pause_btn.onRelease = function () {
> _root.soundPosition = _root.movieSound.position/1000;
When the pause button is clicked and released, set the value of a
variable in the _root. In this case, you are using _root as a prefix to
indicate where the variable is located. This is a good idea, for sure. It
means you're purposefully guiding ActionScript where it should go.
Next, you stop a movie clip and set a few variables. I would use _root
or other pathing mechanisms here, too, to be consistent.
[quoted text, click to view] > movie_mc.stop();
> playing=false;
> stopped=false;
> paused = true;
Here, you tell that poor Sound instance to stop, start, then stop again.
Then, you're asking it to stop a third time.
[quoted text, click to view] > _root.movieSound.stop();
> _root.movieSound.start(0,0);
> _root.movieSound.stop();
> //
>
> _root.movieSound.stop("_root.movieSound1");
> }
Finally, we have a few more buttons. A Stop button tells the movie_mc
MovieClip instance to gotoAndStop() at frame 1 ...
[quoted text, click to view] > stop_btn.onRelease = function () {
> movie_mc.gotoAndStop(1);
... and then sets some variables ...
[quoted text, click to view] > playing=false;
> stopped=true;
> paused = false;
... and again tells the Sound instance to stop, start, stop, and stop.
[quoted text, click to view] > _root.movieSound.stop();
> _root.movieSound.start(0,0);
> _root.movieSound.stop();
> //
> _root.movieSound.stop("_root.movieSound1");
> }
And then two additional buttons set the volume of the Sound instance.
[quoted text, click to view] > on_btn.onRelease = function () {
> _root.movieSound.setVolume(100);
> }
> off_btn.onRelease = function () {
> _root.movieSound.setVolume(0);
> }
I think you can consolidate a bunch of your code. Almost certainly, you
can get rid of most of the Sound.stop(), .start(), .stop() repetition -- and
doing so may reduce the overall size of your code down to a less
intimidating volume. Definitely, get rid of (or modify) your
MovieClip.onEnterFrame event handler.
I can't tell from your description if your *whole movie* is looping or
merely the movie_mc clip. If you understand the basic concepts of assigning
functions to object events, of pathing to objects, and of invoking object
methods, you're most of the way there. In cases like this, where something
unexpected is happening and I can't figure out why, I generally start a new
FLA -- brand, spankin' new, without the "baggage" of whatever currently