CategoryResources

Things You Need

A Fountain Of Color – AS3 Animation Example from Foundation Actionscript Animation Book

If you are remotely interested in Actionscript, Flash, computer animation, games, or pretty stuff on computers – go get Kieth Peters’ book, “Foundation Actionscript 3.0 Animation: Making Things Move.”  Then check out
Keith Peters blog (but really his other sites).  After reading parts 1 and 2 of the book, which cover basic animation, I felt compelled to take one of the examples a bit further.

In Part 2: Basic Motion, the concepts of moving pixels programatically around the screen by shifting the x and y position every frame is introduced.  A ‘veloctiy’ is assigned to both the x and y values to determine how many pixels the object moves per frame.  The fountain example in the book demonstrates these concepts by shooting a bunch of colored balls from the bottom of the screen, with slightly random values for the x and y velocity.

I added some controls, just for fun.  Use the up and down arrow keys to increase or decrease the height, and use left/right to change the direction.  Also, if you look at the code, I changed the concept of x and y velocities to speed and angle. So rather then setting a velocity value for the x and y values of each ball, I set a speed and angle, and use this information to update the balls’ positions.  The original code remains in comments for reference.  Take a look.

FOUNTAIN DEMO |  SOURCE CODE

ColorTransform in AS3 – What? How?

ColorTransform is this mysterious class that had me baffled for quite a while.  You punch in a bunch of numbers, and somehow it is supposed to create one color from another.  But how?  How do the colors change? How do I get this thing to change the color of something on the screen when I want it to?  A fair bit of guesswork and luck was my answer.  Then I got learned up.  The Adobe LiveDocs got me started, but as for actually putting ColorTransform to good use in a real, live Flex project called for some additional know-how.

First, learn about colors on computers. You need to know what RGB stands for, and the difference between hexadecimal and decimal numbers.  Here’s a fun site called “Color Tutorial” (aptly named) to get you started.  And here’s a nice little page that demonstrates how RGB and hexadecimal numbers fit together.

Once you understand how colors are constructed from numbers, then understanding ColorTransform comes naturally.  All it does is jumble up the numbers with some simple math.  The math is explained in the AS3 documentation like this:

When a ColorTransform object is applied to a display object, a new value for each color channel is calculated like this:

New red value = (old red value * redMultiplier) + redOffset
New alpha value = (old alpha value * alphaMultiplier) + alphaOffset
New green value = (old green value * greenMultiplier) + greenOffset
New blue value = (old blue value * blueMultiplier) + blueOffset
If any of the color channel values is greater than 255 after the calculation, it is set to 255. If it is less than 0, it is set to 0.

So there you have it.  A DisplayObject has some colors, and you can transform those colors by fiddling with the RGB values.  You can even transform the alpha channel (transparency).  But how do you know what colors you will end up with?  That was a head scratcher.  Unless you have color codes memorized and are quick with the arithmetic, it’s darn tough to get an exact idea.  Here are a few resources that explain ColorTransform, and show it in action:

  • ColorTransform in Flash CS3 and ActionScript 3, from flashandmath.com
  • ColorTransform explorer by Kelvin Luck
  • Adobe – Style Explorer

There, lots of nice examples.  However, in order to really take advantage of colors and ColorTransform, you should really know how to manipulate color values on your own.  In the flashandmath page, you may have notices a line like this:

RGB=(red<<16) | (green<<8) | blue;

What?  Yeah, this is an example of a bitwise shift operation.  Double what?  Well, follow the link from flashandmath to get a brief rundown.  The gist of it is, the little carrots >> help separate the R, G and B values from a color value, or put separate R, G, and B values back together as a single color with the << symbol.  The nitty gritty is still a little fuzzy, but you don’t need to understand all the nuts and bolts to use the tool.

Of course, I haven’t mentioned HSV as an alternative to RGB.  But these resources are just the tip of the iceberg when it comes to color manipulation.  Check out these sites for extra credit if you are feeling ambitious:

Enjoy!

Use Balsamiq to show website ideas to people that don’t know anything about making websites.

So I’m currently working on a project for the House of Mews in Memphis, TN.  It’s a volunteer project, and kind of a long story on how I got wrapped into it – so I’ll save it for another time.  Anyway, a problem I’ve run into is how to effectively communicate ideas to the House of Mews proprietor.  Using words like content management system, web services, and flex app only draw blank stares.  Bumbling through a long discription of site features elicits some nodding, but the only response I get are questions like, “Can we keep the same music from the old site?”

Argh.

Enter Balsamiq.  The folks at Balsamiq Studios were nice enough to give me a free license since I’d be using it for a non-profit project.  I can’t be more grateful.  This app blows visio out of the water.  It’s so ridiculously easy to use. I cranked out a handful of wireframes in about an hour.  Since it’s all drag and drop, it appeals to the whole ‘instant gratification’ thing.  And when you’re done, you have this neat drawing that looks like you drew it yourself on a piece of paper.

Showing this to the ‘client’ avoided comments like, “that’s the wrong font,” and “that shade of red needs to be lighter.”  Instead I get, “Ohh, so you can click on the little pictures, and the cat’s bio appears. Great!”

Smile.

Here’s an example of a ‘first draft’.

Neat, right? Too bad it looked like crapola when I built it.  So I started over.  After shuffling things around, adding new ideas (and subtracting new ideas), I wound up with this – the mighty ‘work in progress’.

Go try Balsamiq.

Learn All About WordPress Themes FAST!

A great way to get a blog or simple website up and running very quickly is to use WordPress.  Blogging couldn’t be easier when using WordPress, as it provides a handy interface for writing and categorizing posts, adding features via widgets, creating RSS feeds for syndication, and allowing for static pages.  Another insanely useful feature is the ability to change the look and feel with the click of a few buttons using themes.

Themes allow your blog or site to take on a look of its own.  There are literally thousands of WordPress themes available for download. Many (most, even) are available directly on the WordPress website.  Searching Google for wordpress themes will get you a few million results, but many websites simply repost the free sites available on wordpress.org and wrap advertisements around them.  Premium themes are also available for purchase at many places, but again, some sites are more reputable than others.

However, if you want to graduate past premade themes and make your site completely unique, you need to learn how WordPress themes are created and make your own.  This may seem like a daunting task when viewing the WordPress.org documentation, but I stumbled upon a little gem that can’t be beat.  Go directly to Wpdesigner.com created by a young man named SmallPotato and view his tutorials.  The site is now defunct, but the tutorials remain, and are priceless.  There are actually two tutorials, one as HTML, and another as an eBook in 3 parts:

After reviewing these tutorials and referencing the WordPress Codex a few times (for widget code in WP 2.5 and 2.6), I was able to construct my own WordPress themes from scratch.  There are tons of WordPress tutorial sites out there, but this is by far the best place to start (IMHO).  Good luck!

Learn Some Damn HTML (the right way)

Everyone’s seems to be head over heels about standards based HTML/CSS these days.  Web designers and consultancies all seem to tout their ability to create standards compliant and accessible sites.  You just can’t use deprecated tags, and you must separate content from presentation if you want to be a high class webfellow. I remember way back when

and were considered perfectly good HTML tags, but today web developers  scowl at these tags like a half eaten egg-roll in the buffet tray – it just shouldn’t be there any more, and anyone who considers partaking is icky.  Time to get serious and learn the correct way of doing things…

Getting Familiar with XHMTL/CSS

I thought I’d do some homework (boring!) and re-learn the HTML that I thought I once learned many moons before.  I fired up my web browser and looked up “HTML and CSS tutorials”.  There were only 22 million results, and the first one had something to do with learning HTML from a dog.  No thanks.

I eventually found the w3 schools, which is a great primer, and has the spectacular feature of trying out bits of code as you learn (learn by doing!).   There are scads of websites that are good for reference, but since I like to learn something new by doing something practical, rather than just reading text, a good tutorial or three suits me just fine. Here are a few links to do some good ol’ research on standards based XHTML/CSS:

Sometimes You Just Need a Good Book

Despite spending hour after hour poring over instructional websites, I didn’t feel like I was pulling it all together, nor in a position to build a fully functioning website.  I needed something comprehensive, something I could put my hands to, and something else that I couldn’t quite put my finger on.  I decided to swallow my pride and buy a book.

My first attempt at learning XHTML/CSS came a few years ago when I was first introduced to WordPress and Drupal.  I wanted to know more about how these tools worked, so I bought .  It was large, comprehensive, and utterly boring.  In short, it was a textbook.  Reading a standard textbook without a teacher to guide you and classmates to discuss the material with is an absolute challenge.  Needless to say, I didn’t get very far.  This was not the case with my most recent purchase – .  This book was spectacular!  It reads like a real person is talking to you, does not take itself seriously, and is based around bite sized projects large enough to teach you something, but short enough to keep your attention.

I did a fair amount of research before selecting the book, and the Head First series has received a lot of praise.  O’Reilly is definitely on to something here, and I’ll probably pick up a few more of their books as I progress in my career.  Rather than regurgitating tons of facts in an enormous tome and tacking on sample problems at the end of each section, the Head First book considers how people learn effectively and applies those educational principles in a way that makes it easier to learn difficult material.  Combine this book with the endless reference material and tutorials on the web, and it’s a snap to get up to speed on the foundations of building websites.

Get Graphics, Get More Practice

After wrapping my head around XHTML and CSS, I went in search of applying this knowledge to building a real site.  In order to have a halfway decent site that people want to look at, it’ll need to be visually appealing.  This requires graphics.

Before coding a site, one will often start with a mockup or wireframe.  These pre-websites are often made in Photoshop, with fancy graphics and what not.  There are a number of decent tutorials that walk through the practice of going from design to code using popular design packages (namely Adobe Photoshop and The GIMP).  Here are a couple good ones:

There is Always More to Learn

This post is a brief summary of what got me started down the path of building standards based code for the web.  There is much more to learn, and techniques are ever changing.  I didn’t even touch on cross-browser compatiblity and the necessary (but troublesome) browser hacks, nor any advanced CSS techniques.  I’ll likely post more info on these in time, as I get a greater handle on things.  I think the most important thing to know when starting to create websites is that not everyone views the web the same way I do.  Some people use Macs, or Internet Explorer 6, or Opera, or a cell phone.  Starting with a solid foundation in standards based code will go a long way towards pleasing a demanding audience.

© 2017 Eric Terpstra

Theme by Anders NorénUp ↑