Thursday, September 27, 2012








So this is  your flash develop IDE. to get to this basic starting point first you have to download and install Flash Develop from flashdevelop.org. Next open it up and click project at the top of the IDE. Create a new project. Name it HowtolearnAS3 or whatever you want. make sure you select as3 project (the one that does not indicate that it comes with a preloader).  from the menu. Tick the option that says create directory for project.
     Okay you are doing great. At the far right of your screen you see the folders labeled "bin""lib"and"src" these stand for bin library and source code. double click on the source code folder -- the one labeled "src" -- and click on the class main which should appear under it.
     In flash develop when you run your program the code in Main is the only thing that gets run. Specifically the code you put in the constructor function of main. If your eyes glazed over that last sentence that's because I'm an awful writer. What I meant to say it that the thingy that says "public function main" and then has the { } brackets with words inside them is called a function. and when you start your game the stuff that you write in there happens.

right now that function is saying
if(stage) // this means that if the game has loaded to a certain point run the next thing
init() // run the initialization function that plays the rest of the game
else // if it hasn't loaded to a certain point
addEventListener(Event.ADDED_TO_STAGE, init); // then wait till it does load and then run the init function.

knowing all this isn't really required to make something cool so let's do that right now.
ok see the line that says //entry point? our code for now is going to go between that and the next bracket
so make a few spaces there.

now add these lines
//entry point
graphics.beginFill(0xFF0F0F, .9)  // this tells the graphics class to fill in the next shape we draw with color
graphics.drawCircle(0,0,200) // this draws a circle at point 0,0 (top left) that has a 200 pixel radius

try pressing cntrl+enter and you should see a circle. make that 1 fourth of a circle. the center of the circle went to point 0,0 so if you want to see the whole thing try substituing the 0,0 for something like 250, 250

graphics.drawCircle(250,250,200) 

if you change the parameters of the function draw circle to that then the circle should appear 250 pixels to the right and 250 pixels downward of the top left corner. try experimenting with different values in the parameters of both the functions e.g. change FF0F0F to 0000FF or any other rgb value.

Till part 2 I'm out of here cya!

No comments:

Post a Comment