Sign in to follow this  
IDamiez

Any suggestions for a beginner flash user?

Recommended Posts

i am completely new to flash. I managed to get my hands on adobe flash cs3. im leaning more towards learning action script 2.0 instead of 3.0, why? no reason . . . id rather learn the more updated version, on the contrary if 2.0 is more beginner friendly i would gladly study that version prior to my 3.0 experimentation. My first small goal is to achieve a very basic side scrolling game. I'm requesting any known tutorials that are beginner friendly and thoroughly explain things. preferably a tutorial to program a basic sidescroller. I'm also requesting that experienced flash developers give me some advice to how i should go about learning the system, getting used to adobe cs3, learning action script 3.0 etc. I would love to hear how people of the sort went about things like that.

Share this post


Link to post
Share on other sites
If you're not doing vector graphics just pick up FlashDevelop from flashdevelop.org and follow the installation instructions. Remember to download the Flex 3 SDK. In FlashDevelop go to tools -> program options and in the AS3 Context set the Flex SDK location. (I normally put it in C:/)

Create a new AS3 project by going to project -> new project.

In the project -> properties dialog you can set the FPS (30 fps is good) and stage size and set the flash player to 10.

In the project tree you'll notice a src folder with main.as in it which is your entry point. The following code demonstrates a simple template to start working from. I tend to use a single BitmapData object to render to since it's extremely fast with copy pixels.

package
{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

public class Main extends Sprite
{
public var renderBuffer:BitmapData;
public var tickFPS:uint, fps:uint;
public var fpsText:TextField = new TextField();
public var intervalFPS:Timer;

public var moveUp:Boolean = false;
public var moveDown:Boolean = false;
public var moveLeft:Boolean = false;
public var moveRight:Boolean = false;
public var leftMouseButton:Boolean = false;

public function Main():void
{
renderBuffer = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFF);

stage.addEventListener(Event.ENTER_FRAME, EnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);

stage.addChild(new Bitmap(renderBuffer));

intervalFPS = new Timer(1000, 0);
intervalFPS.addEventListener("timer", UpdateFPS);
intervalFPS.start();
fpsText.x = 10;
fpsText.y = 10;
fpsText.autoSize = TextFieldAutoSize.LEFT;
fpsText.text = "FPS: 0/30";
stage.addChild(fpsText);
}

public function EnterFrame(event:Event):void
{
Update();
Render();
}

public function Update():void
{
fpsText.text = "FPS: " + fps.toString() + "/30";
tickFPS++;
}

public function Render():void
{
// Render using renderBuffer.copyPixels
renderBuffer.fillRect(new Rectangle(10, 10, 70, 20), 0x0000FF00);
}

public function KeyDown(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case 87: //w
moveUp = true;
break;
case 83: //s
moveDown = true;
break;
case 65: //a
moveLeft = true;
break;
case 68: //d
moveRight = true;
break;
}
}

public function KeyUp(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case 87: //w
moveUp = false;
break;
case 83: //s
moveDown = false;
break;
case 65: //a
moveLeft = false;
break;
case 68: //d
moveRight = false;
break;
}
}

public function MouseDown(event:MouseEvent):void
{
leftMouseButton = true;
}

public function MouseUp(event:MouseEvent):void
{
leftMouseButton = false;
}

public function UpdateFPS(event:TimerEvent):void
{
fps = tickFPS;
tickFPS = 0;
}
}
}





You'll end up creating many .as files with classes and such probably.

If you want to load textures externally from your swf you can use this texture manager class. It's more advanced so it might take you a little while to understand.

A big part about learning AS3 is to read the documentation online. In FlashDevelop just select a keyword or name like "BitmapData" and it'll take you to the documentation by pressing f1.

There's a lot of bad information out there for flash so be careful. Read this 2D tile based games. It covers a lot of the basics for tile based games like side scrollers.

[Edited by - Sirisian on February 14, 2010 1:52:54 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this