Making games with Flash

Started by Kinoko, Mon 25/08/2008 04:51:03

Previous topic - Next topic

Kinoko

I actually have a little game I'd like to develop using Flash. But I've never used it before!

Can anyone here recommend a good place to learn how to program with Flash? Any tips?

esrix

Hm...  Well, what area of Flash are you trying to get into?  Coding or animation? And what type of game are you looking to develop?

If you are going for coding, you may want to check out Flash Develop at http://www.flashdevelop.org/community/.  It requires a bit of setup (downloading Java, the Flex Compiler, .NET runtime for Windows version) but it is free of charge.

If you are going for art/animation, then you'll probably want to stick to the Flash Professional IDE.

I actually work on Flash games for my job, and there's a lot of interesting things you can do with Flash, as well as some tricks you have to learn to make it do what you want.  Which ever route you choose to go, I'd recommend learning some code at some point.  ActionScript 3.0 will be your best bet, as it has a significant performance increase over ActionScript 2.0.

It may also help you to read some books about Flash and game development (and there are even books on developing Flash games).  You can easily find them at Barnes & Nobles or Amazon.com.

Kinoko

#2
Well, it's going to be a very simple game in theory. I have no idea how to answer really, it's going to involve coding and animation... because it's a game! Gosh, I dunno. It's a game. So I guess coding is the main focus.

I will need to make use of some basic sorts of physics though, velocity and acceleration, etc. And if you can imagine in the style on Line Rider, I'd like to make a kind of user-input based platform creation, where the player is essentially drawing lines and they become platforms.

I mean, I'd like to learn the basics of Flash obviously before I go delving into this but this is the ultimate goal.

EDIT: At this stage, I have Flash CS3 Professional and I've been reading and watching tutorials all night. I'm having trouble because they've made a lot of very unituitive changes to the code in ActionScript 3 and most of the tutorials for coding deal with ActionScript 2. I'm sure they have their reasons for doing so, but it makes it VERY DIFFICULT for people just learning.

So if anyone has any good tips or knows any good game-centered tutorials (or just doing very beginner things in Flash!) dealing specifically with ActionScript 3, that'd be great.

Oliwerko

I know some Flash basics, and when I was learning them I sticked to the original Flash Help file.

Anyway, this site is full with flash tutorials of all kinds, be sure to check it out:

http://www.tutorialized.com/tutorials/Flash/1

ildu

I work with Flash professionally, as well. As far as I know, AS3.0 isn't much different to AS2.0, though there are some conventions that they've changed fundamentally for whatever reason. I also don't think AS3.0 is in wide use yet, and most developers, even professionals, still work in 2.0 because there's little reason to change over. Overall I would recommend learning 2.0 for now, mainly since all of the prefab code done by fellow developers may not be compatible with 3.0. As you're learning, you really want to have a common platform seeing as Flash can screw you over in a great variety of ways with little troubleshooting.

Anywho, at this point the version of AS is quite irrelevent for you. You first need to learn the basics of Flash, the mechanics, the time-based system, embedding of assets and timelines, sequences, different types of animation, etc. You really need to understand how the program works structurally, before you delve into the code. If you're going for something like Line Rider, I can tell you that you're gonna get in trouble mainly with the physics, coding the forces, and creating the collision detection with user-generated lines. It's giving me a headache just thinking about it - I'm more of an art guy than a coder :D.

Kinoko

Hmm, thanks guys!

Actually, I'd been looking at those tutorials all day, and while they had been somewhat helpful, they can also be frustrating as well because they are just snapshots of explanations. Something like the AGS manual was FAR more helpful. But I have been learning by doing and I've already picked up quite a lot. I went from, "WHAT THE HELL DOES THIS PROGRAM DO?!?" to a more mild frustration at not being able to enter in code but coupled with a basic understanding.

I had been wondering if I should just use 2.0 and now that you've suggested it, I think I shall. I wasn't sure how much of a problem it would be but it certainly seems that, given how new 3.0 is, it should be fine. It certainly makes a LOT more sense to me.

As for the physics... well, early days yet, but that's why I'm learning it. Also, I'm hoping to see how far I can use engines and code other people have already created. Anyway, we shall see.

Thanks!

InCreator

#6
I tried that idea awhile ago and quit; ActionScript is total mess in my opinion, it does resemble C-like languages but is somewhat... strange. And not so flexible.

Still, movie-style execution makes it super easy to test right away and you can really quickly see something really graphical happening once you pick the language up. Results, i mean. It's really cool that you can almost instantly jot down some sketch graphics for your game, and animation is just a matter of few clicks. And even this looks great!

I wish you more luck than I had.

neon

I don't know what is you main reason for developing an adventure in Flash. Is it to get experienced in Flash programming or just to make an adventure?

I'm asking, because there is an adventure engine for Flash.

http://lassie.gmacwill.com/lower.php?section=news&page=index


Oliwerko

Quote from: InCreator on Tue 26/08/2008 09:17:43
Still, movie-style execution makes it super easy to test right away and you can really quickly see something really graphical happening once you pick the language up. Results, i mean. It's really cool that you can almost instantly jot down some sketch graphics for your game, and animation is just a matter of few clicks.

Exactly, no more pixelated walkcycle headaches. Some more coding ones instead  :P

Kinoko

Quote from: neon on Tue 26/08/2008 10:02:40
I don't know what is you main reason for developing an adventure in Flash. Is it to get experienced in Flash programming or just to make an adventure?

I'm asking, because there is an adventure engine for Flash.

http://lassie.gmacwill.com/lower.php?section=news&page=index



I'm not making an adventure game! I just... like this forum :(

I do have plenty of reasons for wanting to develop this in Flash though. It's not an adventure game being one of them.

neon

Oh, sorry. I misunderstood.

Traveler

I specifically recommend against learning AS 2.0, for multiple reasons. First, it's an outdated language (AS 3.0 is out, right?) Second, it's an appalling language as well, with lots of quirks - you'll continously learning workarounds for limitations.

AS 3.0 is an almost-properly designed language, with massively different approaches to many things in programming. (AS 2.0 wasn't designed by anyone, they simply kept tacking on features until it got out of hand.) Code written in AS 3.0 is also much, much faster - at least an order of magnitude faster than AS 2.0. The AS 3.0 compiler is still #@!#$ when compared to any real compiler (C++ or C#, for example), but what came with AS 2.0 was a joke from the start.

If you take the time to learn AS 3.0, it'll pay off over time. <shameless plug>Incidentally, my soon-to-be-released website will have tutorials on learning AS 3.0, because I found most tutorials lacking over the net when I took up Flash. :) </shameless plug>

Ildu: how's it going? Long time no see. :)

Kinoko

Oh, now I'm conflicted. I've heard a lot of people complaining about 3.0.

See if you can help me out here then - my major problem right now is that I've been following this tutorial here: http://mikestickney.com/wordpress/flash-tutorial-character-movement-with-arrow-keys/

And everything has gone smoothly until it came to adding the code into the movie clip's action panel. From what I can gather, I need (with 3.0) to add the code into my main timeline in an 'actions' layer, but I need to change the code to indicate what I want it to act on.

But I'm not sure how to change it. Also, even that "stop()" code doesn't seem to work. Same deal?

Anyway, sorry! I'm not going to turn this thread into my tech support, but if anyone could help me out, I'd appreciate it. It'd be a nice hump to get over to just see this working.

esrix

#13
Quote from: Kinoko on Thu 28/08/2008 02:43:11
Oh, now I'm conflicted. I've heard a lot of people complaining about 3.0.

This is most likely due to the vast differences between AS3.0 and AS2.0.  For example, in AS2.0, if you wanted to pull an image to the front based on it's Y coordinate, you could call "SwapBuffers" and be done with it.  However, in AS3.0 the function does not exist and you have to go through the display list on the movie clip and pull some strings to get it the way you want it.

Even if you change something in hopes of making it better, there will be those that oppose it.

As for the earlier claim that the majority of people still use AS2.0... I dunno.  I'd have to see the stats, but there are a lot of people who use 3.0.

...As for the code in that tutorial:

Code: ags

    onClipEvent(enterFrame){
        if(Key.isDown(Key.RIGHT)){
            this._x += 5;
            this.gotoAndStop(”right”);
        }

        if(Key.isDown(Key.LEFT)){
            this._x -= 5;
            this.gotoAndStop(”left”);
        }

        if(Key.isDown(Key.UP)){
            this._y -= 5;
            this.gotoAndStop(”up”);
        }

        if(Key.isDown(Key.DOWN)){
            this._y += 5;
            this.gotoAndStop(”down”);
        }

    }



would become something like this:

Code: ags

    //Flash key codes constants
    const UP:int = 38 // up arrow
    const DOWN:int = 40 // down arrow
    const LEFT:int = 37 // left arrow
    const RIGHT:int = 39 //right arrow

    //You have to add event listeners to the movie clip with AS3.0
    //if you want to get key board events
    //In this case, I don't believe you need an enter frame event listener,
    //just the keyboard one...

    //Essentially, event listeners wait for an event to happen, and then call a function
    this.addEventListener(KeyboardEvent.KEY_DOWN, keyDown, false, 0, true);

    //The function it's calling
    function keyDown( e:KeyboardEvent ):void
    {
        if(e.keyCode == RIGHT){
            this.x += 5;
            this.gotoAndStop(”right”);
        }

       if(e.keyCode == LEFT){
            this.x -= 5;
            this.gotoAndStop(”left”);
       }

       if(e.keyCode == UP){
            this.y -= 5;
            this.gotoAndStop(”up”);
       }

       if(e.keyCode == DOWN){
            this.y += 5;
            this.gotoAndStop(”down”);
       }
    }


In the end, what you choose should be based on what you are comfortable with.  I do AS3.0 because that's what they use where I work and I prefer its syntax over AS2.0.  Pick your poison well :)

Snarky

That snippet doesn't exactly make a strong case for the superiority of AS 3.0. They went from some kind of enum for the keycodes to having to manually define constants using magic numbers? Is time moving backwards in Flash-land?

esrix

#15
Quote from: Snarky on Thu 28/08/2008 06:06:05
That snippet doesn't exactly make a strong case for the superiority of AS 3.0. They went from some kind of enum for the keycodes to having to manually define constants using magic numbers? Is time moving backwards in Flash-land?

Wasn't making a case for any superiority, just providing an example and stating my personal preferences.  They made changes in ActionScript in HOPES of making it better, not guaranteeing the results.

The "Magic Numbers" and the keys they stand for are listed online here:
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001686.html

Some of them follow their ASCII counter parts, but there are some exceptions.

Yeah, having constants for the keys like they did in the past would be nice... but life goes on.

Quote from: Kinoko on Thu 28/08/2008 02:43:11
And everything has gone smoothly until it came to adding the code into the movie clip's action panel. From what I can gather, I need (with 3.0) to add the code into my main timeline in an 'actions' layer, but I need to change the code to indicate what I want it to act on.

Sorry, didn't mean to leave you hanging there...

Remember, the ActionScript is going to stop working if there is a keyframe that comes after it on the same layer.

Best to place the ActionScript on its own separate layer with the same number of frames as the entire movie, but only one keyframe at the beginning if you want it to be used throughout the entire movie.  If you want it to just apply to a few frames, put in a key frame where you want it to start, put in the actionscript, and have another keyframe at the point where you want it to stop on the same layer.  It should work for both AS2.0 and AS3.0.

Hope it helps.

fred

I'm still using AS2, but that's mostly because I haven't had time to learn AS3. AS3 runs much faster when it comes to stuff like physics, 3d, and particle systems, so I'll change to it eventually. But I expect it will take some time to get used to the new syntax and concepts.

Kinoko, you do realize the tutorial is for AS2, right? You may need to do things differently in AS3.

Kinoko

Yes, I did realise after trying it out, which is why I started looking into AS3.0 tips and how I might alter the existing code.

Does anyone know of any half decent tutorials for beginning with AS3.0? Not changing from 2 -> 3, but beginning with 3.0.

fred

Wish I could help you, but I haven't looked into AS3 too much yet. I can recommend the Mochiads.com forums for getting help on flash issues, good luck :)

SMF spam blocked by CleanTalk