Sunday, January 9, 2011

Grav's source code part II

Here's the last part: gameScreen.as.

Oh, and by the way: work on the new game is progressing, but rather slowly. I keep running into errors and mistakes, and sometimes it just behaves in completely nonsensical ways... I guess I only have myself and my inexperience to blame. But then I look at this code and I realize I already learned a lot compared to when I wrote this. :)


edit: So, blogger ruined the layout, but if you just paste it into your favorite actionscript editor and autoformat it, there'll be no problem, right?

Grav's source code.

Like I promised a while ago, here's the source code for grav:
Main.as:
package asfiles{
import flash.display.*;
import flash.events.ProgressEvent
import com.newgrounds.API;
import asfiles.*;
public class Game extends MovieClip {
var startscreen:*
public function Game() {
var preloadbalk:Sprite = new Sprite
preloader()
function preloader() {
gotoAndStop(1)
preloadbalk.graphics.beginFill(0x000000);
preloadbalk.graphics.drawRect(0,0,550,400);
addChild(preloadbalk);
loaderInfo.addEventListener(ProgressEvent.PROGRESS,loading);
}
function loading(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
preloadbalk.scaleX=pcent/100;
if (pcent==100) {
loaderInfo.removeEventListener(ProgressEvent.PROGRESS,loading)
removeChild(preloadbalk)
startscreen = new startScreen()
gotoAndStop(2)
addChild(startscreen)
}
}
}
}
}