Archive for the ‘Actionscript’ Category
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{ vid.pause(); } function playHandler(e:MouseEvent):void{ vid.play(); } function stopHandler(e:MouseEvent):void{ vid.pause(); //pauses video vid.seek(0); //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.
- click on File > New or (Ctrl + N)
- Select Flash Actionscript3 and click ok
- No we must give it a name, so Click File > Save As and give it a name, i called mine preloader
- 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:
This Part of the Shaders Tutorial series will show you how to add Flat shader material to either a dae imported object or to a basic primitive.
If you are a novice, it is advised that you follow this tutorial from the initial section that can be found here, which explains how to set up the files and the scene. Otherwise please read on.
For those following on the shaders tutorial series, i will be calling this .as file flatMat
to begin with we must begin the package and import the relevant classes
package flatMat { import flash.display.Sprite; import flash.events.Event; import flash.text.TextField; import flash.text.TextFormat; import org.papervision3d.cameras.CameraType; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.shadematerials.FlatShadeMaterial; import org.papervision3d.materials.shadematerials.CellMaterial; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.BasicView; import org.papervision3d.objects.parsers.DAE; import org.papervision3d.objects.DisplayObject3D;
now we must begin the class, and add the variables that we will be using
This Part of the Shaders Tutorial series will show you how to add an Environmental Material Shader to your objects.
What this basically does is take a texture imported from the background and use it to reflect off the object, giving the object a highly reflective coating which is faked. This keeps processing power down, while giving a nice effect.
For this tutorial we will be creating an effect that looks something like this: (please be patient while the video loads)
If you are a novice, it is advised that you follow this tutorial from the initial section that can be found here, which explains how to set up the files and the scene. Otherwise please read on.
To begin with, we must begin our new package and import our classes.
package environmentMat{ import flash.display.BitmapData; import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.net.URLRequest; import flash.text.TextField; import flash.text.TextFormat; import org.papervision3d.cameras.CameraType; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.shadematerials.EnvMapMaterial; import org.papervision3d.objects.primitives.Sphere; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.view.BasicView; // import org.papervision3d.objects.parsers.DAE; import org.papervision3d.objects.DisplayObject3D; //Ability to add materials import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.materials.BitmapFileMaterial; import org.papervision3d.materials.utils.MaterialsList;
Then initialise our class and create the variables that will be using
public class environmentMat extends Sprite { private var view:BasicView; private var img:Loader; private var environment:EnvMapMaterial; private var light:PointLight3D; private var sphere:Sphere; private var angle:Number = new Number(0); private var tf:TextField; private var format:TextFormat; private var dae:DAE; private var daeFile:String; private var daeMaterialName:String;
This is to be the first of many tutorials on different shaders, and how they can be applied to dae files. Most tutorials you will find online explain how to add shaders to basic papervision objects, but not to DAE (COLLADA) files.
To begin with, we will start to learn about the simpler shaders, such as wireframe and solid colour shaders and work up to more complicated shaders such as envMapMaterial (environment material) shaders and Movie clip shaders.
All tutorials will be explained with the COMPLETE source code to allow you to get it going on your own machine!
Creating the initial project .Fla and .as Global files
These files will help link in all shader files so that you can learn how to add different shaders to more that one dae file, or different shaders to the same dae file.
first off, we will create an empty .FLA file (this will allow us to read the .as file we will make
and will help us run it!)
File > New (ctrl+N)
select Flash File (Actionscript3) and click ok.
Now save that under whatever name you like.Now we need to create an Actionscript file (.as)
File > new (Ctrl+N)
select Actionscript File and click ok.
Now save this using whatever name you like – I will call it MainShader.as
It is in this MainShader.as file where we will write our code. but first we need to link
it to the .FLA file we made earlier.
click on the tab to open your .FLA file and look near the bottom of your screen, in the
properties tab, for something called Document Class in the text box to the right of it, enter
your .as file name – in this case “Shader” (without the quotes) and click on the little pencil icon to scan for the file.
You will see a pop up message, just click OK to close it.
In this Tutorial, we now have yourfile.FLA and a MainShader.as file.
The MainShader.as file will be the Main file that will link all the other .as files
To find the Relevant Shader Tutorials, please use the drop down menu from the tabbed links at the top of this page, titled Papervision Tutorials.