Community

Everything in actionscript

Posted Dec 27, '08 at 11:54am

Annihalation

Annihalation

170 posts

Gold - Squire

OK, so I need help. I recently got FlashDevelop (google it im lazy) and its a program that can write in AS3. So I need someone to teach me how to write stuff and do animations using AS3 (not Adobe Flash CS3/CS4) because this program is all text :/ anyone willing to teach me a few basic things about ActionScript? I know like... absolutely nothing about it... BUT im willing to learn :D

Posted Dec 27, '08 at 12:11pm

KGuare

KGuare

26 posts

Iron - Serf

Haha, the age old question "How do i write AS3?"

It's like asking how to draw, or
how to write poetry. You can't answer it
in a couple sentences.

If you want to learn AS3, just check out
a couple tutorials through google.
Here's a nice one

Good luck. :]

 

Posted Dec 27, '08 at 12:15pm

Annihalation

Annihalation

170 posts

Gold - Squire

ugh... tutorials are horrible and never tell you what you want. what i mean is like a big list of EVERY base command in actionscript, and what each one does. kind of like a cheat sheet. then maybe a few examples of them that i could copy/paste, then tinker with. But thanks for the tutorial, ill watch it :D

 

Posted Dec 27, '08 at 2:07pm

Drace

Drace

3,984 posts

Wood - Prince

Check out the tutorials in http://www.adobe.com/devnet/flash/artic … flash.html

There pointed toward Adobe Flash users though. Why didn't you get it?...

 

Posted Dec 27, '08 at 2:45pm

Erasmus_Darwin

Erasmus_Darwin

62 posts

Iron - Serf

Zip file <-- Adobe's huge ActionScript language reference.  Unzip it and click on index.html to start at the top.

It's the same as what's on the website, but it's a lot easier when you don't have to wait for it to load.  You can also go into the flash folder to go straight to a given object.  In flash\\display is where a lot of the graphically-oriented classes are.

You might not get much from the Flash in a Flash tutorials that Drace posted, as I suspect they're geared towards building graphics in the Flash environment and then attaching ActionScript to them.

Also, here's a huge PDF on programming AS3: PDF

 

Posted Dec 27, '08 at 3:59pm

Annihalation

Annihalation

170 posts

Gold - Squire

thank you Erasmus

Drace, i couldnt get it cuz it wouldnt work (Ill email you later some time.

 

Posted Dec 27, '08 at 10:16pm

Annihalation

Annihalation

170 posts

Gold - Squire

Ok, just a simple AS3 question. Don't give me a bunch of tutorials. How do I set graphics with AS3? (like, what code is it). I guess a "AS3 Animating Tutorial" would be helpful (google is rejecting me right now). Thanks everyone! :D

 

Posted Dec 28, '08 at 12:05am

Annihalation

Annihalation

170 posts

Gold - Squire

anything at all? lol

 

Posted Dec 28, '08 at 12:19am

Erasmus_Darwin

Erasmus_Darwin

62 posts

Iron - Serf

Basically, you just create a Sprite object, draw to the Graphics object within the Sprite, and then attach the Sprite to the stage.

First select Project->New Project, select an AS3 Project, give it a name, and check the "create a new directory for the project" box.  FlashDevelop will create the project and give you a Main.as with a bit of starter code in it.

Quick sidenote: If you hit F5, the project should compile and produce a blank Flash window since you've technically got enough to qualify as a Flash application even if it doesn't do much.

Edit Main.as and where you see the import statements at the top, add the following:
    import flash.events.TimerEvent;
    import flash.utils.Timer;

Right after:
    public class Main extends Sprite
    {
Add:
        private var triangle:Sprite;
        private var timer:Timer;

And right after:
            // entry point
Add:
            triangle = new Sprite();
            triangle.graphics.beginFill(0xFF0000);
            triangle.graphics.moveTo(5, 0);
            triangle.graphics.lineTo(0, 5);
            triangle.graphics.lineTo(10, 5);
            triangle.graphics.endFill();
            stage.addChild(triangle);
            triangle.x = 100;
            triangle.y = 100;
            timer = new Timer(2000, 5);
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.start();

Finally, after the closing bracket "}" for the init function, add:
        private function onTimer(e:TimerEvent): void {
            triangle.scaleX++;
            triangle.scaleY++;
        }

What this does is it creates a triangle and increases its size every 2 seconds, stopping after 5 increases.  The main drawing bit is the triangle.graphics stuff.  Once it's done drawing on the Graphics object within the Sprite object stored in the triangle variable, then it attaches it as a child to the stage which is what makes it show up.

Another thing you can do is embedding bitmaps.  What you do is you add the image (such as a .png) to the lib directory.  Then create a new class -- in the project window, right-click on src and select "New Class..." and give it a name ("MyImage" in this example).  Part of the class will look something like this:

  public class MyImage

You want to change it so your class extends the built-in Bitmap class:

  public class MyImage extends Bitmap

Then you want to create a blank line above that line.  While your text cursor is still on that line, go to the project window, right-click on your .png file, and select insert into document, which will give you something like this:

    [Embed(source='../lib/image.png')]
    public class MyImage extends Bitmap

Then when you instantiate the MyImage class, it'll show image.png.  You'd do that like this (for example at the "// entry point" in Main.as):

var image:MyImage = new MyImage();
stage.addChild(image);

 

Posted Dec 28, '08 at 12:42am

Annihalation

Annihalation

170 posts

Gold - Squire

are you a AS3 genius or something? You deserve an award, honestly. How long have you been working with AS and the like?

Ok, so adding the image as a child of the stage is what makes the program render the image on screen? I don't need to use any "render" functions? Cool :D

 

Posted Dec 28, '08 at 12:49am

Annihalation

Annihalation

170 posts

Gold - Squire

ok, I learn AS3 MUCH easier like this than online tutorials and reading. Could you show me something that can make the triangle spin/rotate while growing?

Also, what is tweening?

 
Reply to Everything in actionscript

You must be logged in to post a reply!