Best viewed in Firefox

Awesty Productions

It’s not what you say, It’s how you say it

April 29th, 2007 by awesty

You may or may not know this, but Actionscript reads your code from top to bottom. You might not this this really matters at all, but it does. Today I was working on a platforming engine and alot of the collision detecting was messing up. I just rearranged some of the code and it ran just how I wanted.
I am finding a lot lately that when I am actionscripting if I change parts of my code around that my code will run a lot more smoother, or sometimes my code doesn’t work do what it is supposed to until i rearrange it. I thought it would be worth writing about this since there will be a lot of people that don’t realize this.

Here is an example of what I am trying to say:

//Outputs ‘Hello World’
var message:String = "Hello World";
trace(message);

//Outputs undefined
trace(message);
var message:String = "Hello World";

The first message will output ‘Hello world’, as you would expect. But the second code outputs undefined, because the string is declared after you trace it. So it doesn’t exist yet.

Think about this next time you are coding, it will make a big difference.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • Furl
  • MyShare
  • NewsVine
  • Netscape
  • Reddit
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • YahooMyWeb

RSS feed | Trackback URI

2 Comments »

Comment by LaRue Subscribed to comments via email
2007-07-15 07:53:07

 
Comment by EagleVision
2008-02-12 05:26:00

Ok, that is somthing I did not know…he he…Good! :D

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.