setStyle == Huge CPU drain

Sam Neff recently explored how setStyle notifies components of style changes, and the results are definitely worth noting (this may save you some major headaches, so listen up). It seems that every time you call setStyle, it calls notifyStyleChangeInChildren(), which iterates through EVERY movieclip in your movie, checking to see if it should notify it of the style change… ouch! Double-ouch even.

This was very useful information for me, as I’m presently working on a (top secret) project that has 100+ components instantiated at a time, and I was a little confounded as to why initializing the first interface was taking about 12 seconds. It all became very clear when I realized that I was setting about 40 different styles, which resulted in literally TENS of THOUSANDS of movieclip “style checks”. Moving the setStyle calls to the first frame solved the problem completely.

The moral of this story: always set all of your global style information before instantiating ANY movieclips, and then don’t change it – at least until Macromedia changes their EULA, and someone can legally distribute a fix for it (jab, jab). 😉

‘Tis the season: Snow FLA

Well, the -20c temperatures (that’s -4f for those of you stuck with archaic systems of measurement), and 20cm+ of snow (8″) we got over the past week tells me it’s about time to dust off the old snowflakes code, and make it available to the community. There’s a lot of code available for simulating snow, but I think my extensive real-life experience (brrr!) gives mine an edge, plus it comes with a cute peacenik snowman.

This is the same FlashMX version that’s been available on my site for a year and a bit now, with a few minor modifications. I plan to post an MX 2004 class based version, just for the helluvit, in the near future.

You can take a look at the Flash snowfall swf, then download the free FLA. Peace on Earth, and goodwill to men. 🙂

Also, here’s a nice (though completely uncredited – Oscar, you bastard! 🙂 usage of my code with some nice snowflake artwork tossed in.

FlashMX 2004 Enterprise-level Development

My apologies for the lack of posts lately – things have been comfortably busy, with client projects, and a few other endeavours, one of which is a new advanced Flash course I will be instructing at the Northern Alberta Institute of Technology (NAIT) in January and February ’04.

If you’re an intermediate Flash developer in Edmonton or area, check it out – it might be “the course to take your game to another level”. It also helps that NAIT is running it for an amazingly good price.

Read on for the full press release from NAIT…

Continue reading →

Added some anti-spam logic

Well, I finally got pissed off enough about having to delete at least 15 spam comments a day to get off my duff and do something about it.

I have implemented two solutions, one that is preventative, and one that is a clean up tool for after spam is posted.

The first change I made was to rename my comments script, and then remove ALL direct links to it. I accomplished this by:

  1. Removing the links from my index and date-based archives, linking instead to the comments section of the individual posts.
  2. Obsfucating the comment script’s url in the comment posting form using javascript. Now, when a user hits the submit button, the script url is assembled and assigned by javascript. It’s a simple bit of code that should prevent most bots from posting comments.

Unfortunately, there are also spammers freaky enough to post spam manually, and there’s not really anything I can do to stop them. What I can do though, is make deleting their comments easier to save myself some clicks, and some time. To this end, I followed step 6 of this great post on preventing blog spam at Yoz Grahame’s Cheerleader blog. Now, when I receive an email notice that someone has posted a new comment to my blog, I also receive a direct link that lets me delete their comment with only 2 clicks. Based on some of the feedback on Yoz’s post, I also moved the delete link above the comment text in the email notice, to fix an issue with spammers leaving open html tags to obscure the link.

I hope this all works – it didn’t require a huge investment of time, and I expect it will save me a lot of frustration. I’ll post my results after a couple of weeks.

Please let me know if you encounter any issues with using the comments, beyond needing to have javascript enabled in order to post. Thanks.

I also got sick of people typing search terms in my subscription form at the top left, so I added a bit of javascript to validate the email before posting.

Dominatrix Girl Guides

Does your mother know you click on links with titles like “Dominatrix Girl Guides”? Sicko. 🙂

Just some unintentional porn my girlfriend dug up while looking through her old Girl Guide stuff for costume materials. At first glance, it looks like a pretty interesting handbook…

Man, I can’t wait to see my search engine referral logs for this post. 😛

Third party components? Not legally.

Gregg Wygonik raised another really good point regarding Macromedia’s wonderful EULA for F04. It basically prohibits distributing third party SWCs (compiled components) built on Macromedia’s framework.

In order to build proper SWCs, you have to use Macromedia sample code (this includes all of the component base classes such as UIObject), which is then compiled into the SWC. However, Macromedia’s EULA specifically disallows you to distribute any “product or application designed for website development” that uses their sample code. Seems to me, any third party Flash component fits that description dead on.

Oh, and you can’t call it a “Flash component” if it uses Macromedia’s component code, either. That would be using “Macromedia trademarks to market your application”, which is also prohibited.

Looks like the only real answer here (unless MM revises the EULA, or gives each of us specific written permission to distribute) is writing a new framework, that isn’t bound by this restrictive licensing agreement. Or, we could just go back to distributing movie clips – then we wouldn’t have to include MM’s sample code. Macromedia wonders why the adoption rate for F04 is so low? Could it be, in small part, because of the derth of code for F04 being shared by the community, and some hesitation as to what this new EULA means to building client projects.

Does anyone at Macromedia know if there’s been any progress on this topic?

Function scope in temporary vars

I just smacked into an interesting phenomenon with function scope in temporary variables, that appears to be new in F04.

When you call a function that has been assigned to a temporary variable in F04 (a variable declared with var in an execution block), it’s scope is, well… uh, it appears to be non-existant… it has it’s own little scope, in some distant galaxy, far, far away. While this sort of makes sense, it wasn’t what I was expecting.

This occurs in FLAs published to AS1 and AS2 in F04, but does not seem to occur in FMX. It would be interesting to know what exactly has changed, and why.
Continue reading →