automating attachMovie for ActionScript2 UI Builder classes
Monday, October 29, 2007
We finally upgraded to the Adobe CS3 suite at work, so last week I wrote up a recommendation document for importing PSDs into Flash efficiently and to the standard we want to receive our files in. (I will likely post the gist of that document here soon, it's pretty informative.) Generally speaking, the way I do my Flash development is to keep the stage of my movies completely blank and attach every element through code. The FLA file generally exists more as a library than anything else. However, during the initial graphic production stage, in order to get all of the coordinates for the attachMovie script, I still had to rebuild the entire PSD in Flash.So now that that rebuilding part of the process is automated, I've come up with a quick and simple way to automate the script-writing process that attaches the movie clips to the stage. For this to work, you have to have your movie set up correctly -- or modify my script to work within your constraints. My movie clips always have the suffix "_mc" and buttons end with "_btn". In my library, movie clips have the same linkage name as the instance name that I use, though without the "_mc". So linkage is "logo", instance name is "logo_mc", etc. For buttons, linkage is "logoBtn", instance name is "logo_btn". Got it? Great.
So now you've got an FLA with your design all laid out just like the PSD, everything is on the stage, everything has an instance name and a linkage name in the library to match. It's all set up right? Great, run this script:
(Pardon line breaks:)
for(var i in _root){
var linkage = (i.indexOf("_mc") != -1) ? i.substr(0,i.indexOf("_mc")) : i.substr(0,i.indexOf("_btn")) + "Btn";}
trace('var ' + i + ' = evtObj.attachMovie("' + linkage + '","' + _root[i]._name + '",evtObj.getNextHighestDepth(),{_x:' + Math.round(_root[i]._x) + ',_y:' + Math.round(_root[i]._y) + ',_alpha:' + _root[i]._alpha + '});');
stop();
That's going to output a bunch of code that looks like this:
(Again with the line breaks:)
var topnav_mc = evtObj.attachMovie("topnav","topnav_mc",
evtObj.getNextHighestDepth(),{_x:741,_y:0,_alpha:100});
var footer_mc = evtObj.attachMovie("footer","footer_mc",
evtObj.getNextHighestDepth(),{_x:284,_y:567,_alpha:100});
var navbar_mc = evtObj.attachMovie("navbar","navbar_mc",
evtObj.getNextHighestDepth(),{_x:10,_y:24,_alpha:100});
var field_mc = evtObj.attachMovie("field","field_mc",
evtObj.getNextHighestDepth(),{_x:10,_y:456,_alpha:100});
var sky_mc = evtObj.attachMovie("sky","sky_mc",
evtObj.getNextHighestDepth(),{_x:10,_y:0,_alpha:100});
var logo_mc = evtObj.attachMovie("logo","logo_mc",
evtObj.getNextHighestDepth(),{_x:765,_y:556,_alpha:100});
Paste that into your class that builds your ui and stop writing all of that pesky code.
Two things to keep in mind... define or replace "evtObj" with your correct path, and keep in mind that if you're using components, getNextHighestDepth() don't work so well. Use DepthManager or bake your own.
Labels: actionscript, flash
posted by j. Permanent Link
0 comments
![]()
![]()
What happened to my September?
Sunday, October 14, 2007
I have about half an hour of free time while I sit here in the car, hanging out while my daughter is in gym class. I've been sick or having allergies lately and I've been trying to figure out what the deal is. At first I thought I had a slight cold, but it just doesn't go away. I eventually had to assume that it was allergies, though it was hard to know for sure since I've never had allergies before. I started to wonder if this was a result of living in the new New Orleans, or perhaps there's something in my office or my apartment that I'm allergic to. But last night my wife raised a good point-my allergies pretty closely coincide with my project at work shifting in to high gear. I've been keeping insane hours, sitting at my desk in my office and at home, neither of which have very good ventilation. I think more than anything I just need some fresh air. Not that I'm complaining about work. My current project is sooo close to being done and it's really awesome. And in a way it's reassuring. One of my primary concerns with moving and taking a new position was the potential for the quality of clients / projects to go down slightly. I can't judge solely by this one project, one that's been going for two months, but I have to say that I'm pretty happy with it. More specifics will follow later, but the bigger point that I'm getting around to is that I feel like my hard work is paying off.I took on a freelance project in August, working into Sept, which was an interesting situation to be in - having two fairly large projects going with over-lapping timelines. Because they both started around the same time I was able to do all of the analytical and structural work on them concurrently, which I think helped keep things fairly straight in my head. Three things really helped keep me from being overwhelmed. First the design on my contract project was due to come to me late, so I was able to take the lead on the project and direct the design with my functionality, second was that the timeline for the piece I was doing, a flash quiz game, was significantly shorter than my project at work. Last was the possibility that, when it was all done, I'd have some money to get a Vespa.

Which, as it turns out, I did! I got a new midnight blue 2006 Vespa GT200. It should arrive in 10 days or so. I'll be sure to say so when it does!
posted by j. Permanent Link
0 comments
![]()
![]()
I think everyone in nola has been interviewed
Saturday, October 13, 2007
This is really old, but I hadn't the time to post it till now. Better late than...Aug 21:
I was interviewed for CNN.com today. I got in this morning and had an email from one of the owners of the company to call him on his cell asap. So I called him and he mentioned this article from nola.com about "young professionals" moving or returning to new Orleans. (I don't know who the original source for the article was, I thought it was CNN). That article has a theme about people working for non-profits, so they were doing a followup abort people working for private employers. So my boss asked me and another guy to participate, figuring we pretty much fit the profile.
There was a guy holding a mic and taking a few pictures and a girl doing the interviews. There was a funny interaction between the two of them where she offered to hold the mic and he said no- he'd do both. She was trying to help. But it's cool, he just wanted to be in control. I find that I've been doing this a lot lately, where I'm just reading people's body language and listening to people's choice of words, and people just do these quirky things. I laugh at odd moments when people do things like enunciate their words in such a way that it sounds like they're saying something else. Communication between people is odd. It's like a constant series of small conflicts of understanding that get resolved and you continue. My wife has this unique manner of communicating where she'll give you all of the information she has, to get right to the crux of the issue. I appreciate it, but other people get thrown off like they're not quite prepared for it. They need a second to get a bit or context. It's fun to hear her call people like plumbers. They invariably wind up responding to her in their trade jargon, further confusing the situation.
So the interviewer and the tech guy had this polite little misfire and the whole thing was recorded on tape.
Anyway. The interviewer talked to my co-worker first, who spoke quite well about his path to New Orleans 6 months after the storm and his desire to be here and help. Then I stammered through my loosely formed thoughts about the city and why I moved back. She asked us about challenges and we both agreed that we hadn't really faced much challenge that is really caused by the city. I told her that I'd have concerns about investing in the city, buying a house etc, due to concerns about safety from crime and floods. I also told them, though, that I choose to be willingly naive. Heh.
Sept 8:
It's already been 2 1/2 weeks since that interview! The article came out the day before the 2nd anniversary of Katrina and they didn't quote me at all. The article, honestly, was pretty weak. I realized afterward why they didn't quote me. I didn't talk about how my being here is helping the city, though I actually do believe that it is. I didn't talk about the deeper meaning of the work that I'm doing or how I'm a good Samaritan for putting my money into the New Orleans economy instead of Milwaukee's. I talked about taking a pragmatic approach to dealing with a city that I see, essentially, as a beautiful mess. Everyone wants to come here and "pick up a hammer." But in reality we need to know that we can come here and just exist in a meaningful way. I'm pretty aware that, having been away, I sort of have an advantage as a citizen of New Orleans now. I don't have a house rotting away in Lakeview. I'm not in a Fema trailer, I'm not waiting for Road Home money or assistance from George Bush. (I'm so ready to be done with Bush).
But really, if there's any compelling reason to come back here, it's BECAUSE we don't have those issues to deal with. The point I tried to make was that I need to figure out how to be here without setting myself up to deal with those issues in the future. It all comes down to one thing, really (at least where storms and flooding are concerned) -- levees.
Crime, on the other hand... lets just say this for now: it's much easier to build levees than it is to build a fair, equal capitalistic society that doesn't impoverish the lower classes in meaningless service industry jobs.
posted by j. Permanent Link
0 comments
![]()
![]()


