**UPDATE**
Creating and using this custom template is no longer needed. Papervision now includes a BasicView.as see updated tutorial:
Getting started using BasicView.as
![]()
Now that you've created you're base template, you'll probably be eager to try it out.
Let's start by simply creating a rotating cone, much like this one:
By using the base class that you created, you can really quickly build this simple example.
First, create a new project in FlashDevelop.
Call it "ConeExample" or something similar.
Go to "Project > Properties..." and type "cone.swf" into the Output File field.
Under the Classpaths tab, you need to add two classpaths this time.Firstly in the classpaths tab, click Add Classpath...
Navigate to your GreatWhite source code directory and click OK
Now we need to add our template to the project. Click on "Add Classpath..." again, and this time go into the directory where you saved your base template. This will probably be "My Documents/PaperBase", if you called the project the same name as mine.
Find the folder that contains PaperBase.as and click OK.
We now need to create the code.
Right click on "ConeExample" under the project tree, go to Add and choose New Class.
Name the class Main.as.
Right click on Main.as, under ConeExample in the project tree, and click on Always Compile.
You're now ready to start coding.
Firstly, add the following lines to Main.as, under the line "package {"
-
import PaperBase;
-
import org.papervision3d.objects.primitives.Cone;
Those lines will import all of the packages we need.
Next, change the line:
-
public class Main {
To
-
public class Main extends PaperBase {
This will make our project import all of the functions and code that we wrote in PaperBase.as. We can now add just a few lines to make our papervision project work.
We'll need a cone object to add to the scene. Directly underneath the line
-
public class Main extends PaperBase {
You need to insert the line:
-
public var cone:Cone = new Cone();
This line will make a new cone object, and hold it in the variable called "cone"
Now, when the project is run, the code in "public function Main() {" is called. We want to initialise our papervision skeleton when our project runs. To do this, change the function so that it looks like this:
-
public function Main()
-
{
-
init();
-
}
This will run the PaperBase init function when your project runs.
You now need to override two functions from PaperBase. These are init3d and processFrame.
We'll need to add our cone to our scene in init3d, then rotate it a bit every time processFrame is called. To do this, add the following code directly below the Main() function.
-
override protected function init3d():void {
-
cone.scale = 3;
-
// Make the cone bigger cone.pitch(-40);
-
// Tilt it towards the camera default_scene.addChild(cone);
-
// Add it to the scene
-
}
-
-
override protected function processFrame():void {
-
cone.yaw(5);
-
// Rotate it a bit
-
}
These two "override" functions will be run instead of the ones in PaperBase. When you run your project you should see the cone rotating! Try playing with the values, adding and changing bits in the two functions above.
The final code should look like this:
-
package {
-
-
import PaperBase;
-
import org.papervision3d.objects.primitives.Cone;
-
-
public class Main extends PaperBase {
-
-
public var cone:Cone = new Cone();
-
-
public function Main() {
-
init();
-
}
-
-
override protected function init3d():void {
-
cone.scale = 3;
-
cone.pitch(-40)
-
default_scene.addChild(cone);
-
}
-
-
override protected function processFrame():void {
-
cone.yaw(7);
-
}
-
-
}
-
-
}
Flash IDE friendly version:
-
package {
-
import PaperBase;
-
import org.papervision3d.objects.primitives.Cone;
-
public class Main extends PaperBase {
-
public var cone:Cone = new Cone();
-
protected var sceneWidth:Number;
-
protected var sceneHeight:Number;
-
public function Main() {
-
sceneWidth = stage.stageWidth
-
sceneHeight = stage.stageHeight;
-
init(sceneWidth,sceneHeight);
-
}
-
override protected function init3d():void {
-
cone.scale = 3;
-
cone.pitch(-10)
-
default_scene.addChild(cone);
-
}
-
override protected function processFrame():void {
-
cone.yaw(7);
-
}
-
}
-
}
*EDIT*
Added Flash IDE friendly version.
Updated 20th August 2008 to accomodate GreatWhite codebase changes


solved…thank you !!
path to papervision was wrong it has to be to the trunc/src not to tags/src
Hi all!
Great stuff, found some great examples etc. but i just cant seem to get any flash 3d engine to work :S.
Anyway, followed all your tut’s so far, and nothing was wrong until now. I’m not getting any compiler errors or anything, all i get is a blank screen when building. Got the exact same code and followed all your steps carefully, even tried to reinstall flex & flashdevelop and downloaded Papervision3D again and started all over, yet nothing works :S, any idea’s?
Thnx
Argh! I’m sure I have followed the directions to the letter but the Flash Viewer crashes every time I try to pulish it. It doesn’t do it for anything else, what am I doing wrong?
big thanx!! Very very good tutorials!! Charlie You good teacher!
big thanx!!!!!
Hi NOOB,
Did you also added the line:
default_scene.addChild(cone);
in your “override protected function init3d():void {” function?
This should ask the program to draw the cone on the screen
Kind regards,
Pei-Yin
Having a bit of issues as well – N00B’s problem is exactly the same as mine – it compiles perfectly, just no display.
And yes, I have the addChild line in there – in fact, I copied the code straight from this page after prolonged failure.
using Flash CS4, Great White PV3D, Actionscript 3.
Using Flex SDK3 and PV3D 2.0
Handy tutorial. Thanks a lot for posting.
Same problems as NOOB. Compiles, but no output.
And is it possible to get trace() to standard output? Some sort of basic debugging?
FIXED — I think needed to set Always Compile. on Main.as.
Thank you! I’ve been dying to dive into Papervision for about a year now, and after finally getting my head around Flex/AS/Flash + learning Blender, I desperately tried to find a good starting point for pv3D 2.0… And your tutorial really helped glue the missing bits!
For other beginners like myself, my initial difficulties had to do with the correct import statements and also remembering adding the Sprite to a UICompenent (for flex).
Cheers
phiat
I get the following error when I compile this in Flash CS3 using Papervision3D_2.0.883 (the latest version I found available at http://code.google.com/p/papervision3d/downloads/list):
Vertices3D.as, Line 144 1061: Call to a possibly undefined method getPosition through a reference with static type org.papervision3d.core.geom:Vertex3D.
How do I fix this?
Same problem. Compiles perfectly, then when I run it, the flash player comes up but is totally blank.
I figured out why I have a blank screen. If you look in the project window, under coneexample there is a src area. At least in my case, THAT source file (main.as) is not the one you’re editing, so none of your source changes are going into the final output. The clue was that no matter what I added, the build size never changed.
The solution for me was to locate the real main.as (it is underneath, but at the same level as the src folder) and MOVE it into the src folder, overwriting the one that was there.
Now my build size is 98K instead of 828 bytes and it actually works!
The empty scene may be caused by the flash player verson , it seems can’t play on ver.8
I am getting the following error.
C:\Users\Sam\Documents\Adobe\Resource Central\as classes\org\papervision3d\core\geom\Vertices3D.as: Error: Can not resolve a multiname reference unambiguously. org.papervision3d.core.geom:Vertex3D (from C:\Users\Sam\Documents\Adobe\Resource Central\Papervision 1_5\PV3D_1_5\src\org\papervision3d\core\geom\Vertex3D.as) and org.papervision3d.core.geom.renderables:Vertex3D (from C:\Users\Sam\Documents\Adobe\Resource Central\as classes\org\papervision3d\core\geom\renderables\Vertex3D.as) are available.
the 2 lines in vertices3D.as that are noted call for Vertex3D.
I checked my downloaded copy of Vertices3D.as against the latest on code.google.com and each line is identical.
Anyone know what is happening?
Swimminem, did you see the comments on the get the tools tutorial? Someone else had the same prob, and they were pointing to “I had PV3D 1.5 in my classpath..”
Same problem as mentioned above: blank screen in flash player. No errors, no nothing! I used the exact code as in this part4 of the ‘Basic Template Usage’ tutorial. What is Wrong? I’m using PV3D latest version as well as Flex SDK 3 and the latest version of FlashDevelop.
Regarding the error: 1061: Call to a possibly undefined method getPosition through a reference with static type org.papervision3d.core.geom:Vertex3D
I did the reinstall of papervision several times, but I found that by removing my Classpaths to my own custom class directories under Preferences > Actionscript 3 Settings did the trick.
@michabre
This tutorial has been updated. You should now be extending basic view.
See:
http://papervision2.com/getting-started-using-basicviewas/
and / or:
http://papervision2.com/basic-texturing-v2/