Director Tutorials

 

Flash Video (FLV) Template

When using a FLV with Director, you need to create a SWF to call it. The Flash Video tutorial page describes various aspects of using FLV with Director. This page gives a template to get around the video flash when using the video component (FLVplayback) to play the FLV file. The template files were created by Toby De Ieso (Astro) and are also available on his site.

How to use the Basic Video Player

The source files and template can be downloaded from here.

1. Open the file basic_video_player.fla in Flash CS3.

2. Change the dimensions of both the stage (document > properties > size) and the flash video
object (myVideo > properties > W & H) to match that of your FLV file (default is 320x240).

3.
Edit the code found in the 'actions' layer so that the line var videoFile:String =
"test_video.flv";
is modified to reflect the name of your flash video file. For example:
var videoFile:String = "happy_panda.flv";

4. Publish the Flash file (it does not matter what name you use for the SWF).

5.
Open or create a new Director movie.

6. Import the file into the cast (I recommend you link to the external file).

7. Drag the swf member to the stage and your done!

8. If you need basic controls or feedback add the following code to your flash sprite.
(See basic_video_player_d10.dir or basic_video_player_d11.dir for an example.)

-- AstrO Controls :: Video Player

-- version 1.0b1-18Jul08

-- Created by Toby De Ieso

 

property pSprite

property pActive

property pObject

 

on beginSprite me

  pSprite = sprite(me.spriteNum)

  pActive = FALSE

end

 

on exitFrame me

  if not(pActive) then

    pObject = pSprite.getVariable("_root", 0)

    pActive = TRUE

  end if

end

 

on videoEvent(me,tEvent)

  trace(tEvent) -- this line is not needed but it does show you all the values of tEvent

  case tEvent of

    "NetStream.Play.Start":

      -- add code here to run when the video starts here

      nothing

    "NetStream.Play.Stop":

      -- add code here to run when the video finishes here

      nothing

  end case

end

 

-- The following commands give you basic controls over the flash video BUT before you

-- use any of them make sure that pActive = TRUE

-- pSprite.playFlashVideo() : this will rewind and play the flash video

-- pSprite.pauseFlashVideo() : this will pause/unpause the flash video