Selecting and Playing Sound and Video | 345
ActionScript file, copy the contents of Example 9-8, and save it using the caption
name for the filename.
The template method is namedmediaProducer( ), and it orders the three operations,
selectMedia( ),playNow( ), andfromMediaDesign( ). In the concrete classes, details are
added to the selection and play operations, but thefromMediaDesign( )function is all
set to go, and requires no further details or reference.
Example 9-8. VidAudio.as
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
//Abstract Class
class VidAudio extends Sprite
{
private var mText:TextField;
//Template method
public final function mediaProducer ( ):void
{
selectMedia ( );
playNow ( );
fromMediaDesign ( );
}
protected function selectMedia ( ):void
{
//Awaiting instructions
}
protected function playNow ( ):void
{
//Awaiting instructions
}
private final function fromMediaDesign ( ):void
{
mText=new TextField( );
mText.autoSize=TextFieldAutoSize.CENTER;
mText.background=false;
mText.text="Welcome to Template Media!";
addChild (mText);
var pos:Number=mText.length;
mText.x= 200-(pos/2);
mText.y=10;
}
}
}