Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 10.1. Pausing a Movie After It Loads

Problem

You want to prevent the movie from playing when it loads.

Solution

Insert a stop( ) action on the first frame (or the first frame following the preloader), or, if applicable, set the play parameter/attribute in the HTML document to false.

Discussion

Because you want to pause playback automatically and immediately, rather than relying on a user-initiated event, such as a button press, you can add the stop( ) action to frame 1:

  1. Create a layer in the timeline called Actions.

  2. Select frame 1 of the Actions layer of the main timeline.

  3. Open the Actions panel (Window Actions, or F9, or Option-F9 on the Mac).

  4. Add the stop( ) action by typing it into the Script pane (the main portion of the Actions panel).

The stop( ) action doesn't require that you specify any additional information when you call it; it stops the current timeline (the timeline from which it is executed) as soon as it is called. Frame scripts are indicated by a small "a" character in the timeline in the keyframe in which you added the action. If you test the movie (using Control Test Movie), you'll see that when the movie loads, it is paused in the first frame. When testing movies with ActionScript, you should test the actual .swf file (Control Test Movie) rather than using playback in the authoring environment (Control Play). Though you can activate simple actions during playback in the authoring environment (Control Enable Simple Frame Actions), it is best to get in the habit of testing the actual .swf file. When a timeline's playhead stops, the Flash movie is still running. That is, the movie is still rendering graphics, responding to events, and playing sounds. In addition, other timelines, such as movie clip timelines, may continue to play back.


After you've used a stop( ) action, be aware that unless you create another script restarting playbackon a button, for examplethere is not necessarily a way for the user to get the movie to play again.

Users have some control over playback from the context menu, accessed by right-clicking (Windows) or Control-clicking (Macintosh) in the Flash player. Commands include Play, Rewind, Forward, and Loop. Making users rely on the context menu for playback is not good design for at least two reasons. One reason is that it is not an obvious user interface, and that makes the application less usable. Secondly, it is possible to customize the context menu such that the playback options are not displayed. As such, the context menu is not even a standard or consistent mechanism for playback control.


Although adding a stop( ) action is probably the easiest and most common way to stop a movie in the first frame, it is not the only way. You can also use HTML to prevent initial playback. To do so, set the play parameter of the <object> tag to false (for example, <param name (exp 3pod.com)=play value=false>) and likewise set the play attribute of the <embed> tag to false. The following code snippet shows the HTML code needed to embed a Flash .swf file in a web page, so that it is visible in all major browsers. The attributes needed to prevent playback are highlighted. This code is discussed in detail in Chapter 21.

	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://
	fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
	width="550" height="400" id="someMovie" align="middle">
	<param name (exp 3pod.com)="allowScriptAccess" value="sameDomain" />
	<param name (exp 3pod.com)="movie" value="someMovie.swf" />
	<param name (exp 3pod.com)="play" value="false" />
	<param name (exp 3pod.com)="quality" value="high" />
	<param name (exp 3pod.com)="bgcolor" value="#ffffff" />
	<embed src=" someMovi.swf" play="false" quality="high" bgcolor="#ffffff" width="550"
	height="400" name (exp 3pod.com)="someMovie" align="middle" allowScriptAccess="sameDomain"
	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/
	getflashplayer" />
	</object>

Alternatively, you can use Flash to generate the HTML that sets the play parameter to false for both the <object> and <embed> tags. To do so, use the File Publish Settings HTML Paused At Start checkbox.

Generally, using stop( ) is better that relying on HTML parameters/attributes, because it works in all environments. The HTML option works only if you publish the SWF in an HTML document. If you publish the movie in a projector, or test it during authoring, HTML parameters and attributes aren't available.

See Also

Recipe 10.4, Recipe 21.1

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations