How To: [AwayBuilder] Basic Tutorial – Part 2 | Setting Up Flash

I literally just grabbed this from Andreas “BasicScene” setup from the AwayBuilder Lessons directory in the SVN. But I will Explain it in the comments. (Except for the IMPORTS… if I have to explain those you are reading the WAY wrong tutorial. Also make sure to read Part 1 of this tutorial first.

package
{
import awaybuilder.WorldBuilder;
import awaybuilder.collada.ColladaLoader;
 
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLRequest;
 
public class Main extends Sprite
{
/* Setup a Variable for world builder, you will use
 * this to access all of the objects in
 * your scene once setup
 */
protected var world : WorldBuilder ; 
 
public function Main ( )
{
//Collada Loader used for loading
//the exported Collada file.
var loader : ColladaLoader = new ColladaLoader ( ) ;
 
this.stage.align = StageAlign.TOP_LEFT ;
this.stage.scaleMode = StageScaleMode.NO_SCALE ;
 
/* Setup an Event Listener for the Loaded,
 * then a Handler for its onComplete
 */
loader.addEventListener ( Event.COMPLETE , this.loadComplete ) ;
 
//Make it Load
loader.load ( new URLRequest ( "maya/basicTutorial.dae" ) ) ;
}
/* Function used to handle the loading of the Collada File
 * event.target is casted as ColladaLoader
 * so that you have access to that
 * classes methods
 */
protected function loadComplete ( event : Event ) : void
{
var loader : ColladaLoader = event.target as ColladaLoader ;
 
//Initialize your world variable declared at the top of the class
this.world = new WorldBuilder ( ) ; 
 
// pass the loaders data to WorldBuilder
this.world.data = loader.collada ; 
 
//set the initial camera of your scene
this.world.startCamera = "overviewCam" ; 
 
//add an Event Listener for when worldBuilder
//finished parsing the Collada file
this.world.addEventListener ( Event.COMPLETE , this.worldComplete ) ; 
 
// add world to the DisplayList
this.addChild ( this.world ) ; 
 
//START BUILDING... YEAH!!!
this.world.build ( ) ;
}
 
//Self Explanatory
protected function worldComplete ( event : Event ) : void
{
trace ( "worldComplete" ) ;
this.stage.addEventListener ( Event.RESIZE , this.resize ) ;
this.resize ( ) ;
}
 
//Makes sure your scene is nice, pretty,
//and centered regardless of how you size the stage
protected function resize ( event : Event = null ) : void
{
this.world.x = this.stage.stageWidth * 0.5 ;
this.world.y = this.stage.stageHeight * 0.5 ;
}
}
}

Thats it. You’re done, you’ve now build your first AwayBuilder Scene…. Was it really that hard?Roblox HackBigo Live Beans HackYUGIOH DUEL LINKS HACKPokemon Duel HackRoblox HackPixel Gun 3d HackGrowtopia HackClash Royale Hackmy cafe recipes stories hackMobile Legends HackMobile Strike Hack

Hope you enjoyed it.

Comments