Archive for December, 2007

Classes within swfs within swfs gotcha

Sunday, December 16th, 2007

I’ve been bashing my head away at a problem this morning. An AS3 project I’m working on here features a swf within a swf. The encased swf has a bunch of graphics in it most of which are linked to visual classes (classes that extends Sprite, SimpleButton, etc.). Likewise the encasing swf has its own Document class which instantiates a whole other bunch of other abstract and data classes.

Now it just so happens that one of these classes - lets call it ViewClassA - was imported into one of the wrapping abstract classes in the outer swf; not used but just imported. I compiled that swf was compiled yesterday and haven’t touched it since because I’ve been concentrating on the inner swf. ViewClassA was one of the classes linked to a onstage graphic and I’ve been making changes to it over the past 24 hours until I got it to the point this lunchtime that I was happy with it and thus wanted to see how the inner swf looked within and interacted with its wrapper swf.

So I launched the encasing outer swf in a browser and… what is this? All the functionality added over the past day was gone and the trace statements were outputting old content. Eh? OK, so, I cleared the cache, deleted and recompiled the inner swf which was all working nicely and tried again. Same result, what? How puzzling.

I tried this, I tried that: no cigar. Then I was about to head off to a forum and pose a question about this odd behaviour when it struck me that the encasing swf hadn’t been recompiled since yesterday and perhaps it was overwriting the new implementation of ViewClassA with its own embedded version. So I recompiled that too and: bingo! Our inner swf was suddenly kicking out the correct, up-to-date trace content.

So interestingly there is some sort of hierarchy here. There were two versions of the same class existing within the totality of the swf-as-two-swfs and the version accessed was the one stored in the containing outer swf, which embedded the contained inner swf into itself. I gotta get on with some stuff so don’t have time to test this more thoroughly but thought a blog post about it might be useful to anyone out there suffering similar problems.

A good gotcha to be aware of. Heads up everybody!

:)

We are better than we think

Monday, December 3rd, 2007

I’ve been doing a bit of extra-curricular work these last few days. A local design company which has a great little team of illustrators has decided to branch out a little and teach its employees a little bit of Flash and I agreed to go over to their office a couple of evenings a week to show them some Flash basics. Nothing complex; a bit of timeline animation, some simple ActionScript, importing video, some drawing techniques, that sort of thing. But it was amazing how so little went down so well and how much the guys really got out of the session.

I guess like any field, when one is up to the eyeballs in it one can lose sight of just how much one knows and how much of it one takes for granted. I’m doing this little spell of teaching for the money really but I’ve been really happily surprised by just how rewarding passing on this simple knowledge is too.

We are better at our jobs than we give ourselves credit for. This is just another reminder that we should take as little for granted as possible.