Game Development Reference
In-Depth Information
protected function securityError(e:SecurityErrorEvent):
void {
trace(e);
}
protected function asyncError(e:AsyncErrorEvent):void {
//IGNORE ASYNCHRONOUS ERRORS
}
}
}
Using the CutsceneManager
At this point we
ve written less than 100 lines of code, and they will
allow us to easily call in a video for use as a cutscene in less than five.
Open up a new FLA file in Flash and save it next to the Cutscene-
Manager class. Set the FLA dimensions to 710
'
×
386, the original size
of the video we
regoingtoload.IfyoufollowedtheAdobeMedia
Encoder example mentioned earlier in this chapter, copy the Cuts-
cene.f4vfileyoucreatednexttotheFLA.Ifnot,youcanfindthis
same file in the Chapter 9 examples folder. Then, on the first frame of
the FLA, add the following lines:
'
var cm:CutsceneManager = new CutsceneManager(stage.stageWidth,
stage.stageHeight);
addChild(cm);
cm.playCutscene( " Cutscene.f4v " );
You should see the video starts to play, filling up the whole
Stage. Since we haven
t specified another key, press the space bar
before the video finishes and you will see it go away quickly and
cleanly. If we want to get information about when the video
finishes playing, all we need is a few more lines:
'
cm.addEventListener(Event.COMPLETE, cutsceneFinished, false, 0,
true);
function cutsceneFinished(e:Event) {
trace(e);
}
s it. This class will work with any format of Flash-compatible
video and will save a lot of time when you
That
'
re in a crunch. This
class could also be modified pretty easily to work with a menu
background loop as well. Instead of clearing itself when the
video reached the end, it would simply need to loop back to the
beginning. You would also probably want to remove the skip
functionality.
'
Search Nedrilad ::




Custom Search