Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.


B3006 - How do I set up an event to happen at the end of a sound playing?

by - Joseph Ganci

I've got a sequential decision loop set to "until true" with the condition of:

MediaPosition@currentSound >= MediaLength@currentSound,

This is set up to check the current sound icon's MediaPosition and, in milliseconds, display a bullet at the appropriate time using if/then statements. This all works just fine.

After the sound in question finishes playing, shouldn't MediaPosition and MediaLength be equal therefore "true" thus moving the program down the flow line to the next icon?

It's not moving though. I put a display icon with "test" text inside of it and placed it after the sequential decision icon and it's not displaying.

What it's really supposed to do is encounter a calc icon with (PressKey "n") in it which presses the "next" key and automatically advances the slide show.

Compounding the problem is the fact that it does operate properly from time to time but never twice in a row.

Your question intrigued me, so I did some investigating. Here's what I did:

1. I placed a Sound icon on the flowline and called it "sound".
2. I placed a Decision icon below it and set it to Sequential, Until True with the Until True field set to MediaPosition@"sound" >= MediaLength@"sound"
3. I placed an empty Display icon after the Decision, figuring Authorware would stop and open its toolbox if it reached that far.
4. I ran it several times and got to the Display icon just fine.
5. Still not convinced that this wasn't a case of my just having a really fast machine, I put a new Display icon above everything else, set it to Update Displayed Variables and put the following on the screen:

{MediaPosition@"sound"}           {MediaLength@"sound"}

6. I ran it again and saw the MediaPosition value incrementing quickly as the sound played. Then I noticed something interesting. When the sound finishes, MediaPosition reports a 0 when the sound finished!

Over and over I tried it and it always did the same thing. It doesn't "freeze" on the last millisecond, it just goes back to 0. That's why the expression will not always work, especially on a slower machine. If it doesn't happen to be checking the expression at just the right millisecond (the last one), the millisecond count goes back to 0 and it won't work. It makes sense in retrospect.

You may want to try this expression instead:


MediaPlaying will be false when the sound is done, so that the expression (notted) will become true and execution will continue.

There are 0 reviews
Add your review