Code Samples
Move Forward
Click on the example, use the arrows to rotate the ship and the space bar to move forward.
Download the Source Files for Adobe Flash CS4
Download the Source Files for Adobe Flash CS3
About the Example
This example shows how to move a 3D model in its forward direction using the FreeSpin3D Action Script API. The API includes all the necessary methods to move a 3D model instance in all directions respective to its current orientation, meaning moving the 3D model forward/backwards, sideways and up/down.
The FLA
The FLA includes a 3D model of a ship I imported using the FreeSpin3D Import Engine. I created an instance of the ship by draging the FreeSpin3D component to the stage and in the FreeSpin3D Control Panel to assign it the Ship 3D model. In the FreeSpin3D Control Panel I checked the keyboard control to true to enable the rotation of the ship using the keyboard arrows.
I converted the Ship instance to a symbol and added a glow filter (by using the Adobe Flash filters), to add to it a 3D effect.
On the stage there is a button that when clicked initiates a single movement forward of the ship.
The Adobe Flash CS4 Actions Layer (If using Adobe Flash CS3, see code in box below)
// add a mouse keyboard event listener to the stage
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDownHandler);
function KeyDownHandler(e:KeyboardEvent) {
if (e.keyCode == Keyboard.SPACE) {
// advance the 3d model instance forward by 10 pixels
EffectsMc.my3DModel_fs.RviTranslateForward(+20);
}
}
The Adobe Flash CS3 Actions Layer
// Add a keyboard listener to the stage
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDownHandler);
function KeyDownHandler(e:KeyboardEvent) {
if (e.keyCode == Keyboard.SPACE) {
// Advance the ship forward by 10 pixels
EffectsMc.my3DModel_fs.RviTranslateForward(+20);
}
}

