Posts Tagged ‘flash’

This tutorial will assume that you have already created your custom video buttons, and allocated them the name of

  • pauseBtn
  • playBtn
  • stopBtn

now to allow the buttons to actualy do something with the current FLV video, we need to link the buttons to some actionscript code in order to do this you must first open up the actions frame dialogue (press F9) and write the following basic lines of code for basic functionality:

//first we must create the Event Handlers
pauseBtn.addEventListener(MouseEvent.CLICK, pauseHandler);
playBtn.addEventListener(MouseEvent.CLICK, playHandler);
stopBtn.addEventListener(MouseEvent.CLICK, stopHandler);

//Changing cursor to hand, so that the user knows that the button can be pushed
pauseBtn.buttonMode = true;
pauseBtn.useHandCursor = true;
playBtn.buttonMode = true;
playBtn.useHandCursor = true;
stopBtn.buttonMode = true;
stopBtn.useHandCursor = true;
//End Changing cursor to hand

//finaly calling the fucntions for each handler event
function pauseHandler(e:MouseEvent):void{

function playHandler(e:MouseEvent):void{;

function stopHandler(e:MouseEvent):void{
	vid.pause(); //pauses video; //resets it to frame 1

and that its, very simple and easy – if you need help in understanding how to add custom buttons and converting them to movieclips, then please leave a comment!

This is a tutorial showing how to create a very clean and basic preloader for Flash CS3, using Actionscript 3.

to begin with  we must create our file.

  1. click on File > New or (Ctrl + N)
  2. Select Flash Actionscript3 and click ok
  3. No we must give it a name, so Click File > Save As and give it a name, i called mine preloader
  4. Once this is done we have the ablity to start editing our file

As usual you can set the file size for the document etc from the properties tab, but you can leave the settings as default if you like.

We now must create a new layer and call it actions, now in frame 1 of the actions tab (if you can not see the Actions tab, press F9) and type the following code:

Read the rest of this entry »

This tutorial will show you a quick and easy way of allowing your objects to spin/rotate automaticaly.

Firstly you need to either import or create your shape.

creating a plane:

private var object:Plane;...object = new Plane(...)

If you need a more detailed explanation of creating standard shapes, please visit this tutorial for more information.

Importing a .DAE:

public class Example extends BasicView
var dae:DAE;
var daeFile:String;
var daeMaterialName:String;

public function Mainscale()
daeFile = "yourDAEfile.dae";
daeMaterialName = "YourTextureName";
dae = new DAE();
dae.scale = 120;

after you have imported and added your Object to the scene, you need to add a loop in the code (i.e an event listener) then call the function.
so stragiht after we have added the object to the scene i.e using scene.addChild(yourobjectName);

add an event listener:

addEventListener(Event.ENTER_FRAME, loop3D);

Then create a new function, that listens for the event:

private function loop3D(e:Event):void{
//either use
yourobjectName.yaw(2); //changing the number will increase or decrease the speed
//OR use

And that should do it!
need any extra help? leave a comment, and i will get back to you!

Here is an example code, of how to enable mouse and keyboard interaction within your papervision actionscript file.

I know I was lazy, and have not put any comments in the source code, however if you need any extra help or explanations, please leave a comment, and I WILL get back to you

May promise a better full tutorial later on….

import flash.display.Sprite;
import flash.geom.Point;
//Import Camera, Scene, etc..
import org.papervision3d.view.BasicView;
//Mouse Movements
//rotation calculations
import org.papervision3d.core.math.Matrix3D;
import org.papervision3d.core.math.Number3D;

*@Author: Thierry Zoghbi
*@Date: 2009.

[SWF(width="800", height="600", backgroundColor="#0066F", frameRate="25")]

public class Mainsack extends BasicView

private var container : DisplayObject3D;
private var previousMousePoint : Point = new Point();
private var targetScale : Number = 1;
private static const FORWARD:Number3D = new Number3D(0, 0, 1);

public function Mainsack()
var yourobject = new Collada("yourDAEfile.dae");

this.stage.doubleClickEnabled = true;
this.stage.addEventListener( MouseEvent.DOUBLE_CLICK, onDoubleClick );
this.stage.addEventListener( MouseEvent.MOUSE_DOWN, whenMouseDown );
this.stage.addEventListener( MouseEvent.MOUSE_WHEEL, whenMouseWheel );
this.stage.addEventListener( KeyboardEvent.KEY_DOWN, whenKeyDown );


private function whenKeyDown( event : KeyboardEvent ) : void
trace( event.keyCode );
switch ( event.keyCode )
case 187: //
case 107: //
zoom( 3 );
case 189: // –
case 109: // –
zoom( -3 );
case 82: // r (reset)

private function whenMouseWheel( event : MouseEvent ) : void
zoom( );

private function onDoubleClick( event : MouseEvent ) : void
zoom( 10 );

private function whenMouseDown( event : Event ) : void
previousMousePoint = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);
this.stage.addEventListener( MouseEvent.MOUSE_MOVE, whenMouseMove );
this.stage.addEventListener( MouseEvent.MOUSE_UP, whenMouseUp );

private function whenMouseUp( event : Event ) : void
this.stage.removeEventListener( MouseEvent.MOUSE_MOVE, whenMouseMove );
this.stage.removeEventListener( MouseEvent.MOUSE_UP, whenMouseUp );

private function whenMouseMove( event : Event ) : void
var currentMousePoint:Point = new Point(viewport.containerSprite.mouseX, viewport.containerSprite.mouseY);

var difference:Point = currentMousePoint.subtract(previousMousePoint);
var vector:Number3D = new Number3D(difference.x, difference.y, 0);

var rotationAxis:Number3D = Number3D.cross(vector, FORWARD);

var distance:Number = Point.distance(currentMousePoint, previousMousePoint);
var rotationMatrix:Matrix3D = Matrix3D.rotationMatrix(rotationAxis.x, -rotationAxis.y, rotationAxis.z, distance/(600*Math.pow(container.scale, 5)));
container.transform.calculateMultiply3x3(rotationMatrix, container.transform);

//this line used to apply transform to actual rotation values, so that if you change scale, the changes are persisted

previousMousePoint = currentMousePoint

trace( container.rotationX, container.rotationY, container.rotationZ, container.scale );

private function zoom( delta : Number ) : void
targetScale = targetScale (delta * .01);
targetScale = Math.max( targetScale, .5 );
targetScale = Math.min( targetScale, 1.6 );
Tweener.addTween( this, {sceneScale:targetScale, time:1, transition:"easeOutQuart"} )

public function resetView() : void
Tweener.addTween( container, {time:3, rotationX:0, rotationY:0, rotationZ:0, transition:"easeOutQuart"} )
//Tweener.addTween( container, {time:3, rotationX:-45, rotationY:0, rotationZ:0, transition:"easeOutQuart"} )
Tweener.addTween( this, {sceneScale:1, time:3, transition:"easeOutQuart"} )

public function set sceneScale( value : Number ) : void
container.scale = value;

public function get sceneScale() : Number
return container.scale;


This tutorial will explain how to enable keyboard commands in Flash Actionscript 3 CS3.

Firstly we need to import the Keyboard class in flash this can be done by:


After we have imported the keyboardEvent package, it is necessary to add an event listener to the stage, otherwise Flash will not know that we are pressing a key, and will not know what to do with it.

stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);

We need to create a function for our KeyPressed event listener but inside our function we create a switch statement to determine what the function should do when a certain key is pressed. Inside our parameters we have the argument evt.KeyCode this gets the key code for the key that was pressed to trigger the event.

function KeyPressed(evt:KeyboardEvent):void {switch (evt.keyCode){
case Keyboard.UP :break;case Keyboard.DOWN :break;case 
Keyboard.LEFT :break;case Keyboard.RIGHT :break;

After you have specified what keys you would like to use, you can link them for example to move something. For example, if you want a square to move in the x direction when the “up” arrow is pressed on the keyboard you would add square.y += 5;

so the code above would be modified to look like this:

case Keyboard.UP :square.y += 5;break;
Follow me on Twitter
free counters
PayPal Donation
If you like this blog and the help it has given you, why not donate for this good cause? Click on the button below to pay Safely and Securely through PayPal.