Hi David,
thats because the sequenceDone listener is triggered only when a
setSequences([]); method is used. Not for a regular play
It allows you to build a series of animations to be played after each
other.
lets say you have "touch", "fall", "roll", die" animationSequences
you can use cycle to let your avatar go from touch to fall, then to
roll etc... using the play method.
To ease your code, you can pass an array of animationSequences using
this method, and you can add a listener
to know when the avatar is dead. The event is triggered when all
sequences have been played.
The beauty behind this, is to be able to compose series of animations
by reusing sequences.
Fabrice
On Jul 30, 2009, at 5:17 AM, David Zirbel wrote:
Hi Everyone,
I can't get AnimationEvent listeners to work. I'm using the ogre
animation from
Rob Bateman's superb FLARToolkit Away3D demonstration at
"http://www.infiniteturtles.co.uk/blog/away3d-the-flartoolkit". I'm
trying to
run the various animations included in "ogre.md2" based on mouse
interactions
with the AR ogre. All the animations run fine, and the MouseEvent
fires when you
click on the mesh, but none of the AnimationEvent listeners fire.
I'm using CS3
and updated from SVN today. I tried to trace back through the source
but I got
lost pretty quickly. I'm hoping I'm making some noob mistake that
will be
obvious to more experienced eyes:
// ***begin code excerpt*** //
// Load up the md2 at runtime:
private function loadModel():void {
modelURLRequest = new URLRequest(MODEL_PATH + "ogre.md2");
modelURLLoader = new URLLoader();
modelURLLoader.dataFormat = URLLoaderDataFormat.BINARY;
modelURLLoader.addEventListener(Event.COMPLETE,
onModelURLLoaderComplete);
try {
modelURLLoader.load(modelURLRequest);
} catch (e:Error) {
trace("Error loading document: ",e.message);
}
} // end of onMarkerURLLoaderComplete
private function onModelURLLoaderComplete(e:Event):void {
model = Md2.parse(modelURLLoader.data, {material:"blue#white"}) as
Mesh
model.scale(shapeDimensionASlider.value/3000);
model.y = -1*model.minY*(shapeDimensionASlider.value/3000);
model.addEventListener(MouseEvent3D.MOUSE_DOWN,
onMouseDownNoMigration);
model.addEventListener(AnimationEvent.SEQUENCE_DONE,
onSequenceDone);
model.addEventListener(AnimationEvent.SEQUENCE_UPDATE,
onSequenceUpdate);
model.addEventListener(AnimationEvent.CYCLE, onCycle);
model.play(new AnimationSequence("stand",true,true,10)); // <---=
loops fine
// The following three traces show true:
trace("SEQUENCE_DONE: ",
model.hasEventListener(AnimationEvent.SEQUENCE_DONE));
trace("SEQUENCE_UPDATE: ",
model.hasEventListener(AnimationEvent.SEQUENCE_UPDATE));
trace("CYCLE: ", model.hasEventListener(AnimationEvent.CYCLE));
} // end of onMarkerURLLoaderComplete
private function onSequenceDone(e:AnimationEvent):void {
trace("onSequenceDone"); // <---= Does not fire
} // end of onSequenceDone
private function onSequenceUpdate(e:AnimationEvent):void {
trace("onSequenceUpdate"); // <---= Does not fire
} // end of onSequenceUpdate
private function onCycle(e:AnimationEvent):void {
trace("onCycle"); // <---= Does not fire
} // end of onCycle
private function onMouseDownNoMigration(e:MouseEvent3D):void {
trace("onMouseDown:"); // <---= Fires when you click on ogre
} // end of onMouseDownNoMigration
// ***end code excerpt*** //
Thanks in advance,
David Z