Linked In Profile 
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 26 February 2009

In: Flash | HTML & CSS

1 Comment

sIFR (or Scalable Inman Flash Replacement) has long provided an alternative to the default fonts available to web designers everywhere. However, it has also long provided endless migraine headaches, slowness, and other shortcomings.

Enter Cufón, a technology that aims to change all that without the need for a plug-in, and compatible with all type-a browsers. Let the tinkering begin!

[update]: Cameron Moll has a good post on using Cufón – the good and the bad.

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.

Posted 20 October 2008

In: AS3 | Flash | Tips

3 Comments

As mentioned in my previous post, some things about AS3 are finally beginning to click. Others are still dark and murky, but we are all fortunate to have lots of smart people figuring things out and posting them online for the rest of us. In an effort to further their efforts (and to document some of these things for myself so I’m not hunting for them frantically next time I forget them), here are some simple tips I have found:

Stage=null

I ran into this one today. I was trying to preload a swf into another swf and everything seemed to work fine, except when I tried to simulate download speed so I could preview my work. As soon as I tried simulating the download, AS3 would spit out this cryptic error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Which translated into plain speak means: Stage = null. The error happens because on the swf I’m loading, I have several references to the stage (such as stage.stageWidth, etc). Well, since nothing has been added to the displayObject yet (I’m assuming), AS3 is kindly pointing out the error of my ways. Problem is, I need to figure out the width of my stage as soon as my movie starts!

Google to the rescue: Mark Ledford explains in more detail what the problem is – but more importantly, here’s the fix (which was actually posted by Steven Sacks – in a somewhat arrogant tone I might add):
if (stage == null)
{
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
else
{
onAddedToStage();
}
private function onAddedToStage(event:Event = null):void
{
// init code that requires stage
}

Clear out an object

I can’t remember where I found this one, but the problem/solution is simple. Say you need to make sure an object has only one child (and for some reason it has something in it already). Simply clear out the object with this:

function clearObjectChildren(which:Object):void {
while (which.numChildren > 0) {
which.removeChildAt(which.numChildren-1);
if (which == null )
break;
}
}

onReleaseOutside in AS3

One of my gripes about AS3 is that many simple concepts were replaced by ridiculous complexity. Such is the case with the onRelease function that used to exist in AS2. If you’re looking for it in AS3, good luck. It’s gone. So what do we do when we’re dragging something (like a slider) and want to make sure it stops dragging correctly? We add an eventListener to the stage. (random, but it works).


slider_mc.buttonMode = true;
slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(e:MouseEvent):void {
var bounds:Rectangle = new Rectangle(0, 0, 100, 0);
slider_mc.startDrag(false, bounds);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}

function mouseUpHandler(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
slider_mc.stopDrag();
}

Using names

Another big difference between AS2 and AS3 that took me some time to figure out was instance names. In AS2, you named everything on the stage (and off) using instance names or variables. In AS3, if your item is physically on the stage (i.e. a movieclip you created on the stage), you can still reference it by instance name, however…if you are creating an object dynamically, you will need to implicitly add a name to it like so: my_mc.name = “my_mc”;

So if you need to access an mc by name (because you’re not sure what number it is in the display line), you can look for it like this:
some_mc.getChildByName("my_mc");

Makes sense really.

So those are some of the things I’ve learned so far. There are plenty more, but I’m gonna stop while I’m ahead and put some more up later. Hope this helps someone out there. :)

Posted 17 August 2008

In: Flash

51 Comments

As I venture into the depths of AS3 – I find myself pulling my hair out yet again (and those of you who know me know I have no hair left, so that’s not a good thing). Loading multiple images in Flash is (in my opinion) one of the most basic tasks you should be able to perform – and yet I have struggled with this for the past several hours in AS3. This will be basic knowledge to many of you, but bare with me.
Read More…

Posted 1 July 2008

In: Flash

No Comments

One of the most difficult problems to overcome whenever selling the idea of a Flash site is the almighty Search Engine Optimization issue — and rightly so. After all, if your audience can’t find your site, who cares if it’s the mother of all Flash sites? Granted, I think SEO can be taken to an unhealthy level and as with all things, the key is to balance relevant content with keywords and Google-food. But that’s a whole different post.

Adobe has long been trying to overcome the issue of Flash indexing and there have been a number of homegrown solutions that have made things slightly more usable. But the good folks at Adobe have taken it a step further and provided the major search engines with their very own version of the Flash Player — which can dig deep into the bowels of your movies and extract key information. It is rumored that Google has already implemented this new player into their system and Yahoo is following shortly thereafter.

So what does this mean really? Well, difficult to say until we understand exactly how to tap into this functionality (much like the way you build an HTML site affects your search engine visibility, I would assume that the way you build your Flash site will affect how this tool indexes your movies). Regardless, this is a very welcome move by the powers that be.

And while I’m on the subject of Flash and SEO, don’t forget there are other tools out there that help Flash sites become much more usable:

Track Flash events using Google Analytics
Better browser integration and deep-linking with SWFAddress
Better Flash object embedding with SWFObject
Accessible Flash type with SiFR
Image replacement with swfIR

Happy Flashin’!

Posted 26 May 2008

In: Flash | Tips

No Comments

I recently had the opportunity to re-design Best Buy’s corporate site (www.bestbuyinc.com), and as part of that effort, I encountered a problem I had not worked through before — different languages in Flash. I learned a great deal about dealing with different languages and for the most part, it was not as complicated as I expected (and feared it) to be — that is, until I needed to include Mandarin Chinese in the mix.
Read More…

Posted 23 May 2008

In: Flash | Tips

No Comments

What is the modulos anyway? I have used this operator (%) only twice before and I didn’t quite understand it either time. All I knew is that it was doing what I hoped it would. I figured I should probably know what the modulus operator does so I called on the mighty name of Google and voila!:

The easiest explanation I found so far can be found at Mote Interactive. For some interesting uses, check out Grant Skinner’s post on the matter. And finally, if all you’re looking to do is figure out odds or evens, Keith Peters found a nice post on an alternative to modulos.

I love Google.

[update]: Well, this wasn’t so helpful was it? Looks like the primary link is dead, so to better understand what modulo is: The remainder of expression 1 divided by expression 2. In plain english: if you have something like 12 % 5, the returned value is 2. Five goes into 12 twice, and the remainder is 2.

Posted 22 May 2008

In: Flash | HTML & CSS | Opinion

21 Comments

Coda vs. TextMate vs. BBEdit[update]:This post is about a year old, and since then, BBEdit made some significant changes and we also have a new player in the market (Espresso). Some of my observations may be obsolete – though after playing around with the new BBEdit and Espresso, I still stand by my conclusions in this review.

You might have better luck solving the chicken and the egg question compared to determining which of these is the better editor. I truly think there is no perfect answer for anyone out there, but I can tell you that there are certain things about each one of these editors that I love — and things that I loathe.

I could write a long-winded review of each editor but there are many such posts on the web already — instead, I will just give you a quick bulleted list of things I like and dislike.

Right off the bat, I have to say that I have used both BBEdit and TextMate extensively in the past whereas my experience with Coda has been very limited. The primary languages I develop in are HTML, CSS, XML, and Actionscript. I also do a little PHP and Javascript, but not enough to really make a difference.
Read More…

Posted 1 May 2008

In: Flash | Technology

No Comments

Well, this should certainly prove to be interesting. Looks like Adobe is making some interesting changes to the licensing of Flash — particularly in the mobile device front — where it has now decided not to charge licensing fees and has opened up the API to anyone with a keyboard!

I find the move particularly interesting as Microsoft continues to push its Silverlight software in an effort to topple Flash’s foothold. Could this be Adobe’s preemptive measure against Redmond? Or are they thinking ahead in order to dominate the rich mobile market as they have done with web browsers? Only time will tell, but my gut tells me that Adobe’s sites are dead set on the multi-billion dollar world of mobile technology.

Here’s to hoping Apple gets their junk together and uses this as an opportunity to add Flash to the iPhone. Bottom-line is, whether they like it or not, Flash is all over the web, and no mobile web browsing experience will ever be complete unless you’re able to completely browse as you would on your pc.

Posted 12 April 2008

In: Flash

1 Comment

About a week ago I decided to finally give AS3 a real test drive as every other attempt I have made to understand the language has ended up in complete frustration that it doesn’t do things the way I’m used to. I have to say the experience has been painful, but I am beginning to understand (albeit slightly) how to work with classes and objects and all that fancy stuff.

[Warning: Geek-talk ahead]
Today, I ran into a particularly interesting problem. In AS2, any time you referenced Stage…from anywhere, Flash knew what you were talking about. In AS3, it’s not that simple. Sometimes you will want to reference stage from a class that hasn’t yet added anything to the DisplayObject (in other words, you haven’t used any addChild commands yet), and therefore Flash has no clue what the stage is, therefore throwing stage = null.
Read More…

Posted 7 April 2008

In: Flash

No Comments

I have just signed up for this year’s Flashbelt event to be held June 9th — 11th in Minneapolis. This will be my first time at this particular event as I have opted not to attend in the past. However, it seems like the event is gaining momentum and is getting some interesting speakers this year which I wouldn’t mind listening to. I’m also hoping to get a glimpse on what’s in Flash’s horizon, as it seems there are a number of recent developments (the release of AIR, the slow adoption of AS3, Microsoft’s Silverlight, etc) that might make for an interesting Adobe Keynote. Plus, it’s never a bad idea to get a handle on what everyone else is up to.

Space is limited (only 400 attendees) and the price is right, so I hope to see some of you there.

Posted 12 February 2008

In: Flash | Technology

4 Comments

Just recently I started playing around with adding PayPal buttons to a Flash file and was pleasantly surprised at how simple it was. Granted, I only did a basic “buy now” button which is about the simplest piece of code they offer. For those of you interested (and for my own code archiving), here is how to go about doing it:

Set up your Sandbox

First thing I did was set up a sandbox so I could spend money like it’s going out of style. Monopoly money that is. Paypal has set up a nice area for developers to test their applications and their code. And considering all of this is dealing with money, it’s a good thing to test things out before you go live.
Read More…

Posted 4 December 2007

In: Flash

No Comments

Adobe announced an official update to their Flash Player today which supports the H.264 video codec and AAC audio – both of which have been widely used by Apple. I wonder if this is a way for the two companies to work easier with a little iPhone love in-between! We can only hope. :)

Next Page