Archive for the ‘AS3’ Category


Programmer’s Manifesto

1. I will help those who are willing to learn.

2. I will not waste my time trying to help those that will not put in the effort to learn the newer, harder, more efficient way.

3. I am not bound by law to answer your forum posts within thirty minutes of you asking the question.

4. I am willing to learn a harder thing if it helps my knowledge.

5. I will not waste my time if you can’t be bothered to post readable code (Learn 2 )

6. I will not waste my time if you can’t be bothered to figure out which line of code is the issue and instead posted all 200 lines of your class.

7. I am not psychic and will not open your thread if it does not have a meaningful title related to the issue. I.e. “I need help” is not meaningful.

8. I am the first of things to be wrong. If something bad happens, I’m the first cause to check.

9. I will follow my gut feeling. If the code feels wrong, or smells, then I will attempt to change it to the best of my abilities.

10. I will attempt to read a book or part thereof, or attempt a new challenge in a field of expertise to improve my knowledge and ability atleast once a week.

11. I will try my best to write high quality code the first time. Improving it as I learn more or as needed.

12. I will make every attempt to finish what I start, and give up only if it proves futile or fruitless.

13. I will only use one code convention for a project, and I will change any code that doesn’t match the code convention to match the code convention.

14. I will not waste my time if your code uses lots of arbitrary, non descriptive variable names.

15. I have my own personal life to take care of before I help you.

16. I will not answer to those who tell me what effect they want, expecting someone to do it for them, before they try to write the code and figure it out themselves.

17. I will try to help those who use correct grammar and punctuation in my posts.

18. I will not refer people to a trial of a popular-but-expensive proprietary tool when a viable alternative exists.

19. I will always practice the meaningful use of whitespace and indentation, and I will learn to comment my code in a useful way. Code that cannot be read easily and understood quickly is useless, and I should not expect help with it.

20. I will learn how to use the edit button and how to properly format code before I post it on any forum on the internet.

21. I will always support beginners who try to learn, I will always scold beginners who try to teach.

22. I will not overlook the importance of planning how my code should be structured.

23. I will set goals that are ambitious, but reachable.

24. My first game will not be an MMO. Pong or Tetris is fine.

25. My first game should be pong or tetris or bejeweled. Something that’s simple and there exists hundreds of tutorials on.

26. Unless I have the language completley mastered, I will always have the language reference ready for lookup.

27. I will explain any help I give to a beginner and in turn teach them rather than only providing the answer.

28. I will never assume I can remember every single intricate detail about any language because there are too many and human memory is flawed.

29. If I take up programming in any language I should also attempt to learn more languages after I have mastered the language I started with.

30. I understand the learning a programming language takes time and real effort. I will devote my time into learning, and not give up.

Advertisements

A few weeks ago I interviewed Michael James Williams of AS3 Beginner Tutorial fame.

1. What was the first time you remember using a computer? :

I remember my Dad had this laptop, as thick as a brick with a tiny tiny screen, with Windows 3.1 in black and white. But I have better memories of my own first computer: an Amiga 600. I wrote my first code on that machine, in AMOS which was a feature-rich version of BASIC. I used to edit the code of the sample games that came with it to help me understand how it all fit together. Well, OK, no — it was so that I could get infinite lives on Dithell’s Wonderland.

2. How did you discover you wanted to program? :

My interest was piqued by AMOS, and my Dad taught me a lot to get me started, but I think the point I really got into it was when I was about 11, when a friend and I discovered a version of BASIC on the school’s Acorn computers. The teacher let us mess about with that instead of whatever we were supposed to be doing in class. In retrospect, that was pretty cool of her.

3. What was the first computer language you learned? :

The summer after finding BASIC on the school computers was when I really started getting into programming, and I started with yet another version of BASIC: QBASIC. This was super-cool because (if you had the right version) you could use it to make EXE files, just like real software. How exciting!

People say that if you start with BASIC it’ll cripple you as a programmer for life. Maybe I would have a different coding style today — maybe I’d be a better coder — if I’d started with another language. I don’t know. But BASIC was fun, and I don’t regret starting with it. If I were starting today I’d probably spend hours or days reading a million different forums trying to figure out which was the One True Beginner’s Language to start with, and would likely never get into it.

4. When/Why did you start using Flash? :

My family had a copy of Flash 5 when I was about 12, and I really liked it as a drawing tool. It was nowhere near as powerful as, say, Illustrator or FreeHand, but I didn’t have Illustrator or FreeHand; I had Flash and MS Paint. I used Flash to draw almost every diagram for every piece of schoolwork, right through university.

I played around with the animation tools as well, but didn’t do anything mind-blowing: I put people’s heads on stick figures and made them do silly things, and I made a few of the types of tacky website intros that Flash was infamous for.

Funnily enough I never enjoyed Flash coding (with AS1, as it was at the time). With even the simplest tasks, I could never get Flash to do what I wanted. It’s probably because I learnt to program with BASIC.

5. When/Why did you start technical writing?

When I was studying, I wrote my revision notes in the same way that I now write tutorials, and I would give people a hand by explaining concepts on those “revision help” forums. When I was at university I took a module on scientific writing in different contexts — magazine articles, student factsheets, research papers, and so on — and found that I rather enjoyed it.

I didn’t really get started until I was trying to learn AS3, though. At the time, it was still a fairly new language, and there weren’t many tutorials aimed at my level; everything seemed to be written for either complete programming beginners or long-term AS2 experts. So I thought, heck, I can do better than that.

6. Did you ever imagine that you would be doing this for a living?

Not at first, because it was just a hobby. But once I realised that it was what I wanted to do, yeah, I thought I could make a living from it.

7. With Apple and their stand against flash, do you see any danger of it actually going away?

I don’t believe Flash will disappear, but I do believe that we’ll see a radical change in what it’s used for. We’ll see less Flash banner ads and full-Flash websites, for a start. Personally, I’m not too broken up about that.

8. Do you have any advice for people learning to program?

Stick with it. I knew a guy who wanted to learn to program; he started with Java, because it was multi-platform, but after a few days he switched to C++, because he read that it’s used in most programming industries, and then he moved to Python, because he heard it had a much friendlier syntax for beginners, and then, well, he never got anywhere with it.

Don’t worry about whether you’re learning the best language in the world; there’s no such thing. Don’t worry about whether the first language you learn will be immediately relevant to the industry; once you’ve learnt all the basics, it won’t be difficult to switch if you need to. And definitely don’t decide that your first task should be to assemble a group of artists, designers, and sound engineers so that you can build an amazing MMORPG; start with some entertaining little problems that you could do yourself over a weekend.

9. camelCase or underscore?

Depends. I’ve been doing a series of posts on this, actually 🙂

10. What is one of your favorite things to do in your spare time?

I cook a lot. This is a great hobby to have, because it leads to food. And I do enjoy eating.

11. What is the best movie ever?

It is always a draw between Terminator 2 and Harvey.

12. What is the best programming related blog?*

Definitely yours.

*Please note that I didn’t actually ask him this because toward the end of the interview he was kidnapped from my leather couch by Middle-Aged Mutant Ninja Turtles.(But I am sure he agrees with me :))


As a developer almost all games will require some form of key control. And after making a few games I can guarantee that you will become tired of adding event listeners and booleans for each key that is needed.  I have gone thru many sad custom key classes and have discovered that the best key class is…. Skyboy’s!

Skyboy’s Key Class is easy to set up and even easier to use. Download  it below and extract it to the desktop:

https://github.com/skyboy/AS3-Utilities/tree/master/skyboy/

After it has been downloaded and extracted, make a folder on the C drive. Call it “Custom Classes”. Drag the folder you downloaded to the Custom Classes folder. After that, launch Flash Develop and go to the project window.

On the right hand side of your screen you should see a project manager pane. Right click on your project and select Properties > Classpaths > Edit Global Classpaths . Push the add classpaths button and add “C:\Custom Classes” .

Congratulations! You have made it easy to add custom classes in the future!

Now to implement the Custom Class.

First you need to import it at the top of your main class:

import skyboy.ui.Key;

In the main class function add the following to have the class listen for keypresses:

Key.listen(stage)

Now whenever you want to have an action for a specific keypress just add the following to the function of your choice:

if (Key.isDown(Key.WHATEVERKEYYOUWANT))
{

PERFORM A SPECIFIC ACTION
}

That’s it! Simple wasn’t it?