Archive for the ‘Flash and Actionscript’ Category

Loader vs URLLoader

Friday, October 30th, 2009

Today I tried to load an image, and I failed.  I failed because I was trying to use the URLLoader class.  As I discovered this won’t work, because although it will perform a load and happily dispatch a complete event, it doesn’t have the facility to display anything.

What you need for displaying is the Loader class, or more specifically it’s content property, which is a DisplayObject.  Like so:


//create new Loader object
var myLoader = new Loader();
//set up a listener
myLoader.contentLoaderInfo.addEventListener(
Event.COMPLETE,loadComplete);
//trigger the load
myLoader.load(new URLRequest("my_image.gif"));
//
function loadComplete(evt:Event):void {
//clean up the listener
evt.target.contentLoaderInfo.removeEventListener(
Event.COMPLETE,loadComplete);
//add the image to the display
addChild(evt.target.content);
}

So basically the difference is this: Loader for display objects, URLLoader for data connections.

Auto-Save for Flash

Wednesday, September 30th, 2009

My CS4 just crashed.  Again.  Although I try to be good about saving, sometimes I get focused on what I’m doing, and it’s always at these times when Flash decides that clicking that last frame was in some way offensive.  Much swearing ensues and a short break is taken, then I begin that complex string of animations again.

This time though I thought to employ google, and turned up a neat little extension on flashguru: Flash Auto-Save.

Pay no attention to the comment about it not working on CS4, I’ve installed it and it works fine.  The only thing to be aware of is that it needs to be visible at all times, and hiding it in a panel group will stop it working.

I hope this saves more people a bit of fury :)

Find SWF dimensions with PHP

Tuesday, July 14th, 2009

Wow, so it’s been a long time since I posted here.  It’s quite alarming to think how much has happened since March 2008!  Hopefully I’ll start posting here more often again, more as a written record of things I’ve found useful that will benefit me.  With that in mind,  here’s something that came up today.  It’s a very simple thing, but I’m going to find it very useful in developing the banner section of Biff’s portfolio site.

It is possible to find the dimensions of a SWF using PHP’s  getimagesize() function.  Here’s an example:


print_r(getimagesize('example.swf'));

// Outputs:
//
// Array ( [0] => 400 [1] => 300 [2] => 13 [3] => width=”400″ height=”300″ [mime] => application/x-shockwave-flash )

I’ve been published!

Tuesday, March 11th, 2008

Well, kinda.

Last weekend I wrote a tutorial on an AS2 sliding tile puzzle game I wrote a little while ago. It was my first attempt at writing coherent instructions for others to follow, so I was very pleased when it was accepted by the wonderful folks at </dream.in.code>. Thanks to Chris et al!

For anyone who isn’t familiar, DIC is a large community of programmers and web developers who are very helpful and knowledgeable on a huge range of technologies.

Here’s the direct link to the tutorial: http://www.dreamincode.net/forums/showtopic45655.htm

Enjoy!