Articles Archive
Articles Search
Director Wiki
 

Pause, continue and Flash interaction

June 11, 2000
by Pat McClellan

Dear Multimedia Handyman,

I have Flash buttons which I need to pause, play and rewind my Director movie. I tried using the getURL in Flash, but it doesn't seem to work. Can you help?

Matias

Dear Matias,

Director 8 and Flash 4 have a new level of interaction, with lots of new Lingo commands available. I encourage you to take a look in the Director Help utility (select Contents, Lingo by Feature, Flash). Pay particular attention to the getVariable() and setVariable() commands, which let you send data back and forth between Director and the self-contained Flash members. Now, let's look at your question.

You say you want to pause your Director movie. The Lingo command pause will pause the play head. To continue, you use the Lingo command continue. That part is easy, but not recommended. The problem with pause is that when the play head is static, the movie is essentially dead -- with the exception of button members on stage. When the play head is not moving, the stage is not updated, and more significantly, a lot of your Lingo will go dead: anything in a prepareFrame, enterFrame, exitFrame or stepFrame handler. For these reasons, I recommend that you never use pause. A better alternative is to set things up so that you loop in the current frame of the score. That allows the stage to update continually, while Lingo continues undisturbed.

Choosing to loop instead of pause is particularly important if you're using Flash members. If the Flash members use rollovers, then pausing will kill the rollover. In fact, it will kill the button functionality as well. If the Flash member is an animation, the animation will stop dead. Take a look at this demo.

Director 8 and Flash 4 download for Mac or Windows.

This movie demonstrates a number of key issues. I've set it up so that it shows you what's actually going on in the Director score and the Flash timeline when you do various operations. (Note that the Flash buttons I used are in the Flash button library, so I take no blame for the fact that they're ugly.) First, let's look at the top part of the demo -- controlling the Director score playback.

The Director button members and the red, blocky Flash buttons are redundant to each other -- just so you realize that the effects of the buttons can be accomplished with either type. The pause button (though I don't recommend doing it) issues the pause command.

In Director:

on mouseUp me
  pause
end

And for the Flash button, a Get URL action is attached and the Lingo command to pause is given.

On (Release)
  Get URL ("lingo:pause")
End On

When you hit either of the Pause buttons, note that the Flash animation below comes to a stop. The rollover functionality of the Flash buttons also ceases. You can only continue the program by hitting the Director button member that says Continue. That continue button could have been as simple as...

on mouseUp me
  continue
end

However, I wanted to use the same continue button for the frameLoop, so let's look to see how the frameLoop works. In the representation of the Director score, you'll see a frame script stretched across the frames we're moving through. That script is the key to the frameLoop behavior. What we're going to do is use a global variable called gPlayStatus. When the frameLoop button is pressed, gPlayStatus will be set to #frameLoop. The behavior in the script channel will check to see if gPlayStatus is set to #frameLoop and, if it is, will loop in its current frame.

global gPlayStatus

on exitFrame me
  
  if gPlayStatus = #frameLoop then
    go to the frame
  end if
  
end

When the frameLoop buttons (Director or Flash) are pressed, you'll need to set gPlayStatus to #frameLoop. I wrote this movie script to do that:

global gPlayStatus

on loopInFrame
  gPlayStatus = #frameLoop
end loopInFrame

This movie script is called from the Director button:

on mouseUp
  loopInFrame
end

... and from the Flash counterpart:

On (Release)
  Get URL ("event: LoopInFrame")
End On

Pretty easy. Now, we'll want to be able to get out of this loop, so the continue button will need to set gPlayStatus to anything else but #frameLoop. I've created a movie script called playOn, which does exactly that. The if statement in playOn takes care of getting us out of the frameLoop. But remember that the continue button is dual-purpose in this demo: it also needs to "un-pause" us. To that end, I've inserted the continue command as the last line (this is not needed if you're not using the pause command).

global gPlayStatus

on playOn

  if gPlayStatus = #frameLoop then
    gPlayStatus = #play
  end if
  
  continue -- only needed if you are using pause
  
end

With this movie script written, it's easy to call the handler from either a Director button member or a Flash member.

on mouseUp
  playOn
end

And in Flash.

On (Release)
  Get URL ("event: playOn")
End On

The Lingo for going to a marker is so basic that I won't bother showing you the script on the goMarker button. But the corresponding Action Script in Flash looks like this (note that the entire parameter for the Get URL statement is a string, so that's why there are double quotes at the end of the line):

On (Release)
  Get URL ("lingo: go to frame "looper"")
End On

That pretty much takes care of answering the question you submitted, but I do want to show you some other interesting things you can do. So far, we've talked about using Flash buttons to control the Director score. But we can do the opposite as well -- the bottom part of the sample movie shows how you can use Lingo to control the playback of a Flash movie member. The commands are very simple:

sprite(yourFlashSpriteNum).play()
sprite(yourFlashSpriteNum).rewind()
sprite(yourFlashSpriteNum).stop()
sprite(yourFlashSpriteNum).goToFrame(flashFrameNumber)

When you hit the stopFlash button, the Flash animation stops -- but note that the play head continues to move in the Director movie. We haven't paused the Director play head. I know this can be a bit confusing, but when you're using Flash members you have to remember that they have a timeline (like a score) of their own, including their own frame numbers.

I encourage you to explore the many ways that Flash can add a lot of value to your Director movies. Be sure to check out the Flash in Director forum in DOUGthreads.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2024, Director Online. Article content copyright by respective authors.