AS3 Embedded MovieClip Gotcha

May 6th, 2008

In AS3 you can load an asset from a SWF using the Embed metatag like this:

Actionscript:
  1. [Embed(source="Assets.swf", symbol="MySymbol")]   
  2. var mcClass:Class;
  3.  
  4. var myMC:MovieClip = new mcClass();
  5. addChild(myMC);

Where 'Assets.swf' is a swf that contains a symbol with linkage class name 'MySymbol'. Sometimes when you do this you will get the following error:

TypeError: Error #1034: Type Coercion failed: cannot convert MyClass_mcClass@12510d1 to flash.display.MovieClip.

I finally figured out why: Flash will type the symbol based on the number of frames in it's timeline. If the symbol has only 1 frame it will be typed as a Sprite, 2 or more frames it will be typed as a MovieClip.

So to fix the above error, just add another frame in your symbol's timeline. Of course you could type your object as a sprite instead of a movieclip, but there are reasons why you may not want to (for example accessing sub-movieclips, adding dynamic properties etc).

Fixing “Flex Builder requires a more recent version of the Flash Player” Error

May 2nd, 2008

If you uncheck "Generate HTML wrapper file" in your Flex Builder Project ActionScript Compiler options (which is good idea if you want to use SWFObject to wrap your SWF rather than the crud that Flex Builder generates), Flex Builder uses the system default application for opening SWFs when you run/debug your project.

If you get the "Flex Builder requires a more recent version of the Flash Player. You might need to install the Flash Player or reinstall Flex Builder." error, the solution is to set the system default application for opening SWFs to point to the latest debug player. To do this on Windows right click a SWF in explorer. The latest debug player may be in the following location: C:\Program Files\Adobe\Adobe Flash CS3\Players\sa_flashplayer_9_debug.exe, otherwise download the latest Projector content debugger and point to it.

Here is some more Mac specific help

Adobe Go Massive

May 1st, 2008

devices

With the Open Screen Project, Adobe is betting everything on making Flash the world's number one universal runtime.

They are opening up the SWF specification which will allow anyone to build their own Flash player. They are also removing licensing fees for using Flash on devices. This means loss of revenue in the short term in order to entrench the Flash player on as many devices as possible.

It's great to see Adobe continue to open up Flash, which makes it more appealing to a broad range of developers. While anyone can now build their own Flash player, Adobe are betting that their version is strong enough to remain the world standard. I guess they plan to make revenue from selling the dev tools to build SWFs.

Techies have always dismissed Flash, because of its origins as a web animation tool. Techies are scared of anything with a timeline. In spite of this, Flash may be able to sneak under the radar to become the world's most ubiquitous platform, ahead of Java, Silverlight etc. It's interesting that the web and technology in general is moving towards better designed user experiences, something that Flash has always excelled at.

According to techcruch's great analysis, Silverlight's answer to Flash's increased ubiquity is "Live Mesh". With good timing, Joel Spolsky just posted a scathing attack on Live Mesh. Frankly I am not at all worried that Silverlight will crush Flash, especially judging by the embarrassing state of their showcase (hello 1998). Maybe MS should just build their own version of flash player.

Applying Alpha Transparency to the System Font in Flash 9

April 15th, 2008

If you have tried applying an alpha transparency fade to the '_sans' system font in Flash 9 you'll know that it doesn't work. The fix is to apply a filter to the textfield first:

myTextField.filters = [new BlurFilter(0,0,0)];
myTextField.alpha = 0.5;

Please Can I Have Permission to Delete My Own Fracking Files?

April 13th, 2008

I've been using Vista for about a year now and overall I'm pretty happy. It's essentially XP with nicer drop shadows. But there is one thing that drives me absolutely nuts and I've yet to find a solution for it.

Almost every time I try to delete a folder off my machine I get this message: "Destination Folder Access Denied. You need permission to perform this action." It's my folder, I created it on my own machine. Who do I need permission from? Bill Gates? My mother?

permission

The whole idea is ridiculous. This is my machine, I'm logged in as an Administrator - I should be able to delete any file I want. If the file is in use by another process, please let me know about it, but ultimately the decision to delete should be mine.

This issue is symptomatic of a general level of distrust in the user. It's great to prevent newbie users from deleting the 'windows' directory, but please have a power-user mode where I don't have to be nannied with warnings and wizards every step of the way.

Unlocker is a nice freeware app that sometimes fixes this problem but often it too is helpless against vista's security restrictions. I did disable the UAC (another vista annoyance is the fact that you get a warning message every time you reboot telling you that disabling the UAC is a terrible idea) but this does not help with this issue.

(This anti-Microsoft rant is here to provide balance for some of my previous anti-Apple rants).

PostcardViewer Update

April 13th, 2008

PCV

I completed the viewer update trifecta - PostcardViewer has been updated to v1.2.

I actually re-wrote the code from scratch, since the previous code was starting to show it's age. The main new feature is captions. Since the images are rotated slightly the text requires an embedded font to render. This means that non-english characters, italics and bold are not supported (PostcardViewer-Pro allows you embed different character sets as required). View the complete list of updates here.

I always liked this viewer since it is very simple but fun and effective. It uses Flash's fast scaling code to produce nice zooming transitions. About the image rotation in PCV - a few people have complained that the rotation degrades image quality. I think the slight rotation adds a subtle real-world cue that makes the images more visually interesting and 'real'. Think about it - when you look at a set of actual photos, they are not all perfectly perpendicular to each other. Your brain does a fine job of working out which direction is up and which direction is down within the image. Let's break free of the tyranny of the 90 degree angle ;) (PCV-Pro allows you to disable the image rotation).

PostcardViewer-Pro customers are notified via email when there is an update. All 1.x updates are provided free of charge.

SimpleViewer v1.8.5 Released

April 6th, 2008

SV grab

When I first created SimpleViewer back in 2003, it was mainly a reaction against the multitude of bad web photo galleries that were out there. The idea was to create a gallery that was simple, unobtrusive and usable. I did not expect 5 years later that it would be getting over 15,000 downloads a week!.

This popularity has spurred me to keep improving the gallery. The 1.8.5 updates include:

  • Added full localization support
  • Allow direct links to images within gallery
  • Added PNG and GIF support (publishing to Flash 8 )
  • Added 3 new XML options: vAlign, hAlign, navPadding. These improve layout for small format galleries.
  • Added 5 new Pro AS options: showCaptionOnRollover, captionUnderThumbs, captionFontSize, titleFontSize, captionPadding
  • Allow setting caption and title colors via HTML font tags

As usual, these new features are mainly based on the awesome feedback that comes from the forums. Unfortunately due to the high volume of posts I do not have time to answer each one, but I do read every post and take note of the issues raised.

SimpleViewer-Pro customers are notified via email when there is an update. All 1.x updates are provided free of charge.

Please download the latest version, give it a whirl and let me know if you see any bugs. Thanks!

AutoViewer Update

March 17th, 2008

I've spruced up AutoViewer a little as part of my spring cleaning. The biggest change is that captions now support HTML formatting, including hyperlinks. The UI was tweaked to be more useful in small format situations (see example below). Also added localization support and some new config options. See a list of all the changes here. Most of the new features are based on feedback posted to the autoviewer forum.

AutoViewer-Pro customers are notified via email when there is an update. All 1.x updates are provided free of charge.

The ‘Add to Friends’ T-Shirt

March 2nd, 2008

Add To Friend Shirt

The ultimate blurring of the line between the real and virtual worlds? Or just a really geeky t-shirt? You decide. The 'Add to Friends' t-shirt allows anyone with a camera phone to friend you on facebook with one snap.

Towards the Next Generation of 3D Visualization

February 28th, 2008

desaxis

I love Flash - I've been using it for years and know most of it's tricks. Now with papervision and away3D we have a some nice 3D APIs. While these are great, 3D in Flash is seriously lacking in rendering power. Once you throw a few hundred simple 3D shapes on the stage, your frame rate starts to plummet.

Flash is still the best choice for ubiquitous interaction on the web, but for 3D graphics, there are some better alternatives. Please note that I am not lobbying for native 3D graphic card support inside Flash (that didn't work out too well for shockwave).

From my research so far, 2 of the most interesting apps for creating next-gen realtime 3D graphics are processing and vvvv.

PROCESSING

Processing has been around for a while and is gaining traction as a 3D visualization tool. Processing is free and cross-platform. The flickr processing pool shows the kind of stuff you can build with it. Since Sun updated the java preloader graphic to be cool and orange, we might even start seeing some all processing websites.

proccessing IDE

I've resisted learning processing for a while, but when Robert Hodgin generously released some of his source code I had the motivation to download and try it out. Surprisingly, processing comes with a nice, lightweight IDE. Each project is a sketch which is basically a folder containing simple text files. Processing has a number of libraries and examples for handling 3D graphics.

Lennyjpg is creating some beautiful work with processing:

...

As is Flight404:


VVVV

vvvv is a 'toolkit for real time video synthesis'. It's a crazy app built by some crazy german people. The tutorials are written with typical deadpan teutonic humor. It's currently windows-only and free. Jitter is a similar cross-platform app.

The concept of vvvv's UI is 'patches'. Modules are laid out in a 2D space and patched together with virtual wires. The beauty of this paradigm is that there is no compilation - results are rendered in realtime as you tweak the patches. Since I come from a textual programming background I find this to be quite baffling, but maybe it's good to have your head turned around now and again.

patches

Desaxismundi has been creating some fantastically beautiful pieces using vvvvv such as this deconstructed sphere:


and these:

desaxis

desaxis


Bad Behavior has blocked 6030 access attempts in the last 7 days.