ActionScript 2: Create dynamic FLVPlaybacks with attachMovie

There is a simple way in ActionScript 2 to dynamically create instances of the FLVPlayback component:

  1. Put the FLVPlayback component into your library (you can drag’n’drop the component from the components window into the library).
  2. Use the following two lines of code to attach the FLVPlayback to a MovieClip (_root in the simple example) and to set the path to the flv to play:
    _root.attachMovie("FLVPlayback", "myFLVPlayback", _root.getNextHighestDepth());
    myFLVPlayback.contentPath = "video.flv";

The id of the FLVPlayback in the library needs to be “FLVPlayback” (case sensitive).

A running example (Flash CS3) can be found here.

Leave a Reply

Your email address will not be published. Required fields are marked *