This video tut is the first in a series of Papervision3D tutorials.
In this tutorial we will create an empty Papervision3D scene:
What to watch for
Create a container, a scene, and a camera
Center the container on the stage
Render the camera
(I’m using FlashDevelop so all classes will be automatically imported. As you can see towards the end, I accidentally import a class which I have to delete.)
[flv:http://flexyouras.com/tutorials/Papervision3D/01_Setting_Up_The_Scene/01_Setting_Up_The_Scene.flv 604 508]
<?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="init()"><mx:Script><![CDATA[import flash.filesystem.File;
import flash.data.SQLStatement;
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.events.SQLEvent;
import flash.events.SQLErrorEvent;
//Serves as your connection to the SQLite Database
privatevar dbConn:SQLConnection;
//Holds SQL Syntax, i.e, "CREATE TABLE…"
privatevar dbStatement:SQLStatement;
//Shows the path to where the SQLite database is stored
privatevar dbFile:File;
privatefunction init():void{//call the Open Database function
openDB();
}privatefunction openDB():void{//The link to your new database named whatever you want
dbFile =new File("app-resource:/mySQLiteDatabase.db");
dbConn =new SQLConnection();
//Opens the SQLlite dbFile to access db info
//If dbFile doesn't exist, the "open" method will create it
dbConn.open(dbFile);
//Listen for the OPEN SQL event
dbConn.addEventListener(SQLEvent.OPEN, onOpenDB);
}privatefunction onOpenDB(event:SQLEvent):void{//If the OPEN event fired correctly, create the SQLlite db
if(event.type =="open"){
createDB();
}}privatefunction onErrorDB(event:SQLErrorEvent):void{//Place error handling code here
trace("sql error occurred")};
privatefunction createDB():void{
dbStatement =new SQLStatement();
dbStatement.sqlConnection = dbConn;
//Create your SQL statement using standard SQL syntax
//You'll find millions of SQL syntax tutorials by googling SQL
/*"IF NOT EXISTS" is required or else the swf will throw an error
saying the table has already been created.*/var dbQuery:String ="CREATE TABLE IF NOT EXISTS "+"myTable(myColumn1, myColumn2, myColumn3);";
//Assign you SQL query to the text property of the SQL statement class
dbStatement.text = dbQuery;
//Listen for the SQL result
dbStatement.addEventListener(SQLEvent.RESULT, onResultDB);
//Execute the statement
dbStatement.execute();
}privatefunction onResultDB(event:SQLEvent):void{/*Handle the result by checking the getResult()
method of the SQL statement class*/if(dbStatement.getResult()!=null){trace("Succesfully opened myTable from mySQLiteDatabase.db!");
/*You will now find a file called "mySQLiteDatabase.db"
in the bin folder of your project folder. This is where
all the SQLite database information will be stored in future tutorials*/}}]]></mx:Script></mx:WindowedApplication>
When embedding the font, the source= line is the path to the font in relation to your project folder. In this case, the font is in the root of the project folder sitting alongside EmbeddingFonts.mxml. That’s why I only had to write ‘MICKEY.ttf’.
private var mickeyFont:Class; is only there so the compiler will link in the font.
The ‘fontName’ (‘mickey’) within the embed tag has to be the same as the ‘fontFamily’ within the style tag.
The name of the style inside the style tags (‘mickeyStyle’) is what you use to reference the style from the ’styleName’ property of your component.
A short example outlining the use of dispatchEvent to send an event from a custom component to the main application (this video assumes you know the basics of creating custom Flex components :
Here are the basics of getting a movieclip out of the library and onto the stage using a custom Actionscript class. The key point is to import the linkage name you assigned the movieclip in the library (in this case, “Box”) to make it accessible in within the class. You can then assign whatever properties you want to it (in this case, x and y):