Control AnimationsDownload Example
// Class Main.as
package
{
import flare.basic.*
import flare.core.*
import flare.system.*
import flare.utils.*
import flash.display.*
import flash.events.*
public class Main extends Sprite
{
private var scene:Scene3D
private var biped:Pivot3D
private var active:Boolean = true
public function Main()
{
stage.quality = "medium"
// creates the scene.
scene = new Viewer3D( this )
// define progress and complete events.
scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent )
scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent )
// loads the biped.
scene.addChildFromFile( "biped.f3d" )
}
private function progressEvent(e:Event):void
{
// ...
}
private function completeEvent(e:Event):void
{
// trace info about the scene.
Pivot3DUtils.traceInfo( scene )
// once completed, we can access to 3d objects.
biped = scene.getChildByName( "biped.f3d" )
// add some labels. ( the labels also can be defined in 3DMax ).
biped.addLabel( "anim1", 0, 50 )
biped.addLabel( "anim2", 50, 1100 )
// for smooth animation when the frameSpeed property is less than 1.
biped.animationPrecision = true
// begin update the scene.
scene.addEventListener( Scene3D.UPDATE_EVENT, updateEvent )
}
private function updateEvent(e:Event):void
{
// play and stop the animation.
if ( Input3D.keyHit( Input3D.P ) ) biped.play()
if ( Input3D.keyHit( Input3D.S ) ) biped.stop()
// inverse the frameSpeed.
if ( Input3D.keyHit( Input3D.F ) ) biped.frameSpeed = -biped.frameSpeed
// increment and decrement the speed of animation.
if ( Input3D.keyHit( Input3D.Z ) ) biped.frameSpeed -= 0.1
if ( Input3D.keyHit( Input3D.X ) ) biped.frameSpeed += 0.1
if ( Input3D.keyHit( Input3D.R ) ) biped.frameSpeed = 1
// play labels in loop.
if ( Input3D.keyHit( Input3D.NUMBER_1 ) ) biped.playLabel( "anim1" )
if ( Input3D.keyHit( Input3D.NUMBER_2 ) ) biped.playLabel( "anim2" )
// play labels with no loop.
if ( Input3D.keyHit( Input3D.NUMBER_3 ) ) biped.playLabel( "anim1", false )
if ( Input3D.keyHit( Input3D.NUMBER_4 ) ) biped.playLabel( "anim2", false )
// enable / diable bone animations.
if ( Input3D.keyHit( Input3D.SPACE ) )
{
active = !active
scene.getChildByName( "Bip01 R UpperArm" ).animationEnabled = active
scene.getChildByName( "Bip01 L UpperArm" ).animationEnabled = active
}
}
}
}

English