Next Page
Linked In Profile  RSS Feed
Posted 13 July 2009

In: AS3 | Flash | Tips

1 Comment

It’s been some time since my last post. My apologies - I have been sucked into the Twitter vortex which I find fascinating to be honest. I mean, whodda thunk that 140 characters could reveal so many brand insights! But that’s a different post altogether.

Today I’m sharing some tips that I learned from Todd Dominey’s Twitter feed (@tdominey). For those of you who don’t know Todd Dominey, you’ll certainly know his work: SlideShowPro - the completely ubiquitous (and awesome) Flash slideshow gallery.

Both tips are AS3 specific, and oh so helpful.

Tip 1: A simpler trace function
I can’t tell you how many times I have had to type long, convoluted trace statements to see if whatever I’m working on is doing what I think it should be doing. Usually those trace statements look something like this:
trace ("array item " + i + ": " + my_arr[i]);

which would turn out something like this:

array item 0: blue
array item 1: red
array item 2: green

You’ll notice a lot of plus signs and quotes and stuff. Well, instead, try replacing the + signs with commas:

trace ("array item ", i, ": ", my_arr[i]);

Though it’s nothing truly magnificent, I find typing commas vs. + signs is much faster and easier to understand.

Tip 2: A simple for loop for arrays
This one is also quite simple in its function, but saves a lot of typing. Instead of looping through an array with a for statement, like so:

for (var i:int = 0; i < my_arr.length; i++) {
myFunction(which:int);
 }

you can use this:

my_arr.forEach(myFunction);

so long as myFunction accepts the right params:

function myFunction(element:*, index:int, arr:Array) {
trace (element, ": " , index);
 }

Pretty nifty eh? Yeah, I thought so too. Thanks @tdominey!

Posted 22 April 2009

In: AS3 | Flash | FlashDen

No Comments

Hi all. Just added three new files to my FlashDen profile (yes, I know it’s been a while since I’ve done anything on there). They’re all simple time-savers which hopefully makes people’s lives a bit easier. The more significant accomplishment, however, is that they are all AS3 - which I’m now becoming increasingly comfortable with. So without further ado:

MD AS3 Accordion Viewer - FlashDen Item for Sale

MD AS3 Accordion Viewer
A simple accordion viewer that’s XML and CSS driven. Completely resizable and easy to modify (at least in my opinion). I find these useful when having to present multiple items in a small area.

62956

MD Slider
I have used this file (or a similar iteration of it) so many times in my work, with such good results, that I figured why not just package it up and put it up! It’s a simple way of presenting multiple images in a given area.

100106 AS3 Video Player
The hardest one to build by far is this fully AS3 Video Player, built from the ground up and thoroughly tested on PC and Mac! The kicker to this one is that it uses a simple configuration object to work, which can be passed via FlashVars or set up directly inside Flash. I’m most proud of this one.



So that’s what I have for now, but I’ve been toying with some other ideas. I’ll keep ya posted. Oh yeah, and Happy Earth Day!

Posted 20 December 2008

In: AS3

No Comments

A great subject/post by Lee Brimelow (be sure to read the comments too). I have myself tried a number of Tween libraries, including Fuse, Tweener, TweenLite, and TweenMax and completely agree with Lee that they are all great, and in the end, it’s all about what your needs are.

Posted 20 November 2008

In: AS3 | Tips

15 Comments

Quick AS3 tip that may be self-explanatory to most of you out there, yet stumped me for a while. In AS2, if you set a variable on your main timeline and wanted to access it from inside a movieclip, all you would need to do is call it by name. AS2 would then proceed up the scope chain looking for the variable by name. First, inside the movieclip, then on the parent of the movieclip (in this case…stage).

AS3 is a little different. Say you declare a variable on your main timeline like so:

var my_arr:Array = ["one", "two", "three", "four"];

Then you place a movieclip on your stage, and INSIDE your movieclip, you want to reference my_arr (which is on the main timeline, or the movieclip’s parent). Back in AS2, you would simply type out my_arr, and Flash would automagically find the variable as it searched the scope chain. In AS3, however, if you type this (again…inside the movieclip):

trace (my_arr); or even trace(this.parent.my_arr);

You would get this error:
1119: Access of possibly undefined property my_arr through a reference with static type flash.display:DisplayObjectContainer.

Well, to avoid this little annoyance, you can try a strict coercion like so:
trace (MovieClip(this.parent).my_arr);

I wish I knew the exact reason as to why this behavior exists, but I do have my suspicions and theories in case you’re interested. What I believe is happening is that in AS3, the movieclip doesn’t want to assume it knows what its parent is. In fact, as far as it’s concerned, it only worries about whatever is in it, or “below” it (the concept is called encapsulation). Anything outside of it (or “above” it) is basically anybody’s guess and unless you specifically tell it “your parent is a movieclip,” it doesn’t make any assumptions.

Again, that’s my own theory - so if anyone out there knows the real reasons for this behavior (or even a better way of handling this) - let us know!

Posted 14 November 2008

In: AS3 | Flash | Rant

3 Comments

I recently got upgraded to CS4 at work and for the most part, the many changes that have taken place in Flash have been pretty cool. I’m having trouble adjusting to the new interface (in particular, having the timeline be at the bottom of the screen vs. the top). Many of the changes have been requested for years - like more AfterEffects integration, 3D, etc. And to be honest, Adobe has delivered some pretty cool new features.

Now for the bad news. As is always the case (or so it seems), every major release comes with its own baggage and behavior that isn’t so welcome. For me (and many others), it’s the new CS4 help system โ€“ or lack thereof. It turns out that the folks at Adobe decided that if you’re looking for help, you should be going to their servers โ€” you know…those slow snail-paced things that adobe.com is hosted on โ€” and get your answers there. The help that we’ve all grown accustomed to is now gone, and to quote Bentley Wolfe, an Adobe engineer “The old help format is gone, and not coming back. Sorry.” Nice.

So there you have it. If you’re like me and use the help files constantly as a reference while developing in the Flash IDE, stick to CS3. Otherwise, if you don’t mind waiting for the slow server to load, then finding the right section, then searching for a class or function, then sorting through irrelevant search results until you find something the resembles what you’re looking for, then realizing it’s not it and starting another search, and finally finding something that is already confusing to begin with…well then, be my guest. :)

More on CS4 later.

[ update ] Well, thanks to David Stiller in this thread, I now at least have access to the local help files when pressing F1 - though it still opens in a browser. Here’s how you do it:

1. Go to Window/Extensions/Connections
2. Click on the context menu (upper right-hand corner)
3. Select “Keep me offline”
4. You’re good to go. Now when you press F1, the browser will open and look for the local files.

Next Page