Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts

Monday, March 22, 2010

If statement syntax shortcut


Many times have I come across a situation where I have an extremely simple "if statement" that takes up 5 or so lines of code and I've though to myself "I really wish I could express this code in a single line without losing a great deal of readability"

Well look no more... Actionscript 3.0 code such as this:

if (myVar >= 10) {
trace("foo1");
} else {
trace("foo2");
}

can now easily be compressed in to a single line utilizing an alternate method of syntax such as this:

(myVar >= 10) ? trace("foo1") : trace("foo2");

Nice huh? Probably not as easy to read - but for those of you with large class files, or if you are slightly OCD when it comes to white-space conservation as I am, it's a perfect method of syntax compression.

Blogistential Angst


I have resisted the temptation for a while now, but I can resist no more.

Yes my friend, I am giving in to the need to add my own voice to the legion of many others... but for what purpose apart from the desire to stroke my own ego ever so slightly?

Well, hopefully this new blog will help to educate those of you on the same journey as I am - not to mention document most of the new cool stuff that I come across on said journey.

I regularly visit blogs of various nature, however most of them have one theme in common. Tips, tricks, methods and projects relating to Actionscript 3 and my own personal lord and saviour - Flash Professional (praise be to him).

For a while now I've fought the desire to start up a blog of my own to cover the same kind of content because I didn't want to come across as preachy or vain in an area that I have no formal qualifications in.

So why give in to temptation now? It is simple. My work ethic includes a procedure. I get to my desk at 9am every work day... and I do not leave it to go home until I feel that I have learnt something new or have expanded my knowledge of Flash and Actionscript.

I have been working as a professional Flash developer on a full-time basis now for close to 2 years and prior to that, as a contractor after-hours for close to 6 years. In that time I have worked on quite a few websites and web-applications. But what I am most recognized for are my flash games - amongst them is a little horror point-n-click series called Exmortis.

As you can imagine over the years I have acquired a reasonably in depth knowledge of Flash and Actionscript... and yet I still have so much more to learn. As a result, I primarily consider this blog as a way of documenting what I learn for my easy future reference and maybe - just maybe someone might stumble upon these words and also take something out of it to help build upon their own skill set.

I must also point out that I am not formally trained, nor have I a great depth of knowledge when it comes to Object Oriented Programming (OOP) methodologies - so I may not always be right nor will I always be putting forward the best/most efficient method of accomplishing something... so I always welcome comments and feedback on the content within this blog.

So without further adieu... let the fracas begin!

Cheers,
Ben Leffler