AS3 ApplicationDomain misbehaves in subloaded SWF

Tuesday, December 20th, 2011

This post is not meant to be a comprehensive tutorial on Flash’s ApplicationDomain class and how it is used, for that I recommend Senocular’s excellent guide on the subject.  Rather, I just wanted to make a quick note of what I have observed when using ApplicationDomain.currentDomain in a subloaded SWF – that it doesn’t seem to work properly.

When I have a SWF that is loaded into another SWF, and it uses ApplicationDomain.currentDomain.getDefinition to grab a class from its own library, it fails with the following error: ReferenceError: Error #1065: Variable [VARIABLE_NAME] is not defined.  I assume that ApplicationDomain.currentDomain is mistakenly returning the parent SWF’s ApplicationDomain, instead of the child SWF, though I don’t really know why.

So here’s the quick fix, for those of you looking to cut to the chase: instead of using ApplicationDomain.currentDomain in your child SWF, use loaderInfo.applicationDomain instead.  This will explicitly grab the child SWF’s ApplicationDomain, not the parent’s, and your code will work as expected.  Note: I have not tested whether loaderInfo works as expected if your SWF is not subloaded, i.e. if it is the root SWF on the stage.

So to recap – when instantiating dynamic classes in a subloaded SWF, don’t use this:


Rather, use this:


And save yourself the hassle I went through the last day or two!

AS3 for each … in vs for … in

Friday, December 16th, 2011

If you’re like me, remembering which version of the AS3 for … in loop does what is practically impossible.

So here is a reminder:

for each … in

Very simply, the for each … in loop iterates through the values of all properties associated with an object.


var obj:Object = {
  name:"Will Smith"

for each (var prop in myObject){

The above snippet will print the following:

Will Smith

for … in

Conversely, the for … in loop iterates through the name of each property associated with an object.


var obj:Object = {
  name:"Will Smith"

for (var prop in myObject){

The above snippet will print the following:


Hope this helps clear up some confusion!

iPad lockdown

Saturday, June 11th, 2011

This is my first post from an iPad. No, not mine, but my uncle’s. I’m visiting family in Texas and my grandparents and several aunts and uncles and cousins flew up from Hawaii so it’s kind of a bit of a family reunion. I am actually faster on my iPhone’s smaller touch keyboard. Typing with multiple fingers on a keyboard with no tactile response will take some getting used to.

What a crazy world we live in, always-connected and always-on. I have been going through internet withdrawal this week cuz my mom doesn’t have a home internet connection. I’m writing this post from a mobile touchscreen computer, on a mobile wifi hotspot, from the car, while en route to the beach.

And yet some things about this device are so locked down it feels like a step backward. The iPad doesn’t have a file system I can use, doesn’t let me upload or download files, and I can’t save pictures to it to upload unless I connect it to a different computer. As a result, I can’t add any pictures to this post. I’m connected, but still feeling the withdrawal.

Nelson Mandela is a stud

Tuesday, May 24th, 2011

Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our light, not our darkness that most frightens us. We ask ourselves, Who am I to be brilliant, gorgeous, talented, fabulous? Actually, who are you not to be? You are a child of God. Your playing small does not serve the world. There is nothing enlightened about shrinking so that other people won’t feel insecure around you. We are all meant to shine, as children do. We were born to make manifest the glory of God that is within us. It’s not just in some of us; it’s in everyone. And as we let our own light shine, we unconsciously give other people permission to do the same. As we are liberated from our own fear, our presence automatically liberates others.

-Nelson Mandela

On change

Saturday, May 21st, 2011

They say “nothing in life is more constant than change.” Life is basically one long string of adjusting to changes that happen, through our own choices or through others’. In the last almost-a-year, there have been a ton of changes in my life. I have basically re-built my life from the ground up, after the nuclear bomb of divorce shattered it. All my old patterns and habits disappeared in the aftermath, and I was left a shell of my former self. I found myself actively clearing away the rubble of lost inside jokes, habits that were never me, traits that I’d picked up to keep the peace. I found myself asking the question, over and over, “but who the hell AM I?”

I’m still working on that question, but I feel I have come a long way in ten or eleven months. I still have a long way to go, but I feel in some measure like I’m healing, and somewhat adjusting to my new life. All the old has been stripped away, and some of it has been replaced by new. Some of it is still in-progress. There is one difference – I live for ME now. One thing I never quite got down while married was how to live for another without losing yourself. How to live for the new team you’ve created. I think it’s because I never knew myself to begin with. This made me impossible to live with, because I tended to chameleonize to match my surroundings. I still have a ways to go, but I know now somewhat who I am, and I am done apologizing for it. I need to find someone who will accept me the way I am, a music and computer geek, because nothing’s gonna change that. And trying to be someone you’re not never brings peace. As Shakespeare said, “to thine own self be true.”

I’m not saying I don’t need to try and improve myself – on the contrary, I am just as focused on self-improvement as I was when I was perfectionistic and saw everything in black and white. The difference now is that I accept where I am, no matter how low that might be, and I work from there. You have to start from where you are. Shaming yourself won’t change anything; it will just keep you stuck where you don’t want to be.

I’m done apologizing for who I am. I am done hiding under a bushel, so to speak, in hopes that I will fit in with the crowd, in hopes of looking “normal”. Normal is overrated! Being myself is much more fun.

It’s not like there aren’t still tough moments in my life. One change I have not quite gotten used to yet is waking up alone, post-divorce. Once you’ve experienced waking up next to your best friend, not having to say goodnight, and knowing that person will always be there in your life, it’s surprisingly hard to go back. It has been almost a year since my marriage ended, and I still don’t enjoy waking up most mornings. Looking around and realizing “oh yeah. This is my life now.”

But there are still plenty of good things in my life. They’re just, well, different things now. I’m trying to enjoy the chapter of my life I’m in, rather than wishing for something that’s not there. Yeah, sometimes I wish I had those years back that we “wasted” on marital incompatibilities and fights, but if I hadn’t gone through that pain I wouldn’t be where I am today.

I like my life, ultimately. I like myself. I’m trying new and different things, expanding my horizons, making friends and trying to make a difference in the world, in their lives. A positive difference. I am loving learning how to use power tools, working on studio improvements, networking in the music industry, learning how to take care of myself and my surroundings, becoming my own best friend, learning to be self-reliant, learning to make better choices. Learning to surround myself with positive, uplifting people. Learning from both the similarities and differences between me and my friends, learning what I agree and disagree with. Making fun, uplifting games for kids. Getting paid to do what I love. Figuring out, finally, that I am addicted to music and don’t ever want to recover. Working on my keyboarding and vocal skills. Working on my business skills. Working on being the best me I can be, instead of worrying about being alone.

Ultimately, I am trying to live the Gospel of Jesus Christ. The theory has always been there, as long as I can remember, but now I’m putting it into practice.

It’ll be exciting what the future brings.

On the importance of physical exertion

Wednesday, May 18th, 2011

I have a sedentary job. TWO sedentary jobs, actually – I am either sitting on my butt writing computer code, or sitting on my butt recording and mixing audio. When I go home, I play video games or surf the Internet. I’m always staring at a screen of some kind.

I’ve gained a bit of weight as a result, since my metabolism is not as young as it used to be. Lately I’ve been trying to be more active – working with my hands is never something I’ve felt any good at, seeing as my family growing up was decidedly white-collar. Fix something? I’m the LAST guy you should call, or so I thought.

All of this has led to a somewhat startling realization – any day where I get to use power tools is a good day.

Lately I’ve been doing a bunch of remodeling at my recording studio, and it has been SO empowering to do as much of the work myself as possible. I now own a drill, a level, a few saws, and I make as much use of them as possible.

It’s SUCH a good feeling to look at something physical – a new wall, some shelves, a paint job, or whatever – and say “I did that!” It takes away from my frustration, my depression, my cabin fever – and it gives me vigor, energy, self-esteem, and life!

And that is never a bad thing.

Permission to sleep

Wednesday, March 30th, 2011

Ok, this is weird – two blog posts in two days. I promise you won’t hear from me so much in the future ;) .

The title of this post comes from a thought I had, lying here in bed. I’ve always been a night owl, always periodically found myself awake far too late, when all the sensible people are asleep. Part of me likes this time when there isn’t anyone to distract me. Part of me thinks it’s awfully lonely. But here’s my point – I need to learn to give myself permission to sleep. After a long day’s work, my brain is tired, but still literally buzzing with activity. The frenzy of mental exertion that is my workday, working as a flash programmer, doesn’t easily stop just because I turn off the computer and get in bed. Instead, I often find myself unable to sleep as my mind relentlessly turns. Sometimes, I must admit, I’m reluctant to listen to my body and come down off the mental high once the end of the day hits. My body is complaining, begging me to sleep, while my mind chants “more, more, more!” The older I get, the less benefit I get from burning the candle at both ends. In other words, this is not a sustainable behavior. And since I am busier than ever, I need to get my sleeping habits in order so I can keep a schedule, and maintain an adult work week.


Milestone: snowboarding

Tuesday, March 29th, 2011

I went snowboarding on Saturday, for the first time in probably three years. It took a lot of initiative and determination to set the goal, and then follow through and not let setbacks get in the way. It took planning, sticking to my guns, and dealing with rescheduling. I had many other things that competed for my time that day and in the days leading up to it.


How would you like your graphic design?

Thursday, February 24th, 2011

Found this amazingly funny, but all-too-true graphic on my buddy Tracey Lee’s Facebook profile.  It applies to pretty much any creative industry.

Click for an enlarged graphic.

Snapshot of my best self

Tuesday, February 1st, 2011

On this fine day, I find myself rather introspective. I thought I would do an exercise in thought. What follows is a snapshot of my best self, the person I am in embryo but hope to become full-time. The rules are that you must start each statement with “I am” or something equivalent, and the statements must be positive – they are goals, after all. It can be an evolving snapshot – you can come back and change it later, adding, modifying or subtracting as your life needs and goals change.

I encourage you to try it out yourself, and link to your own snapshot in the comments – I’d love to hear what you come up with. Ok, without further ado, here it is:

I am……. (more…)


Saturday, January 29th, 2011

Am I being the best I can be? Am I growing like I want to or need to? These are a couple of the questions on my mind tonight. I want to be the best person I can be, really work on growing, and this year is the perfect time to do it. I am excited for the new possibilities in my life, for the opportunity for real, if painful, growth. I want to live up to my true potential, as a son of God, as a flawed but trying human being.

I want this to be the year I dig into the thoughts and patterns that hold me back, and change things that may be dysfunctional in my life. I want to grow musically, spiritually, mentally, physically. I want to grow my business and see it succeed, and learn what I need to to run it. I want to overcome bad habits, unhealthy or dysfunctional thought patterns, and learn to overcome toxic shame and guilt. I want to be a good friend, a strength in other people’s lives. A good listener. “To have a friend, be one,” as the ceramic plaque that hung on my mom’s wall said. I want to be someone that others can turn to because I don’t give them unwanted advice. Because I give them strength. I want to be someone people can count on.

You only get one life. You might as well live it to the fullest. A great quote I saw today said that life is not only to be endured, but enjoyed. Too often we (read: I) forget that. Too often I get caught up in the problems and challenges of life, losing sight of the big picture in the process. Not being able to see the forest for the trees. As nickelback so eloquently said, “This is your life. Are you who you wanna be?”

What we’ve learned in 2064 years

Thursday, January 13th, 2011

An interesting quote…….

“The budget should be balanced, the Treasury should be refilled,public debt should be reduced, the arrogance of officialdom should betempered and controlled, and the assistance to foreign lands shouldbe curtailed lest Rome become bankrupt. People must again learn towork,  instead of living on public assistance.”

-Cicero, 55 B.C.

What have we really learned in the last 2064 years?


Sunday, January 2nd, 2011

It is a new year. The time when people set resolutions for what they will accomplish or change in their lives. For me, it is a strange time. Lots of changes and transitions in my life. Lots of old things, old patterns that have gone away, replaced with new ones that I’m not so sure that I like. Life, as always, is bittersweet, filled with both happiness and tears. I suppose that is the way it’s supposed to be.

Sometimes I fear that the new patterns are too much, that I cant survive without the old ones, that I can’t fill the void that their destruction has left behind.


Inspirational Quotes for the new year

Saturday, January 1st, 2011

Here are some of my favorite quotes from the latest LDS general conference:

The world pursues enlightened self-interest. Yet the power is not in us to save ourselves. But it is in Him. Infinite and eternal, only our Savior’s Atonement transcends time and space to swallow up death, anger, bitterness, unfairness, loneliness, and heartbreak.
-Elder Gong


Thoughts on “The Secret”

Friday, December 3rd, 2010

XKCD Positive Attitude

It’s been awhile since I’ve posted anything from XKCD here, that amazing geeky web-comic that I love so much.  This strip talks about the power of positive thinking and how some people take it to an extreme.  I am all for positive thinking, and for taking responsibility for our choices, attitudes, and feelings, but some people take it to such an extreme that they use it as a club to beat others over the head with.   (more…)

Thoughts on being human

Thursday, November 18th, 2010

Sometimes, we come face-to-face with our own mortality. We think we can do anything, we reach for the sky, we aim for the stars, only to be reminded that when it all comes down to it, we’re still human. Mortal. Fallible.

don’t be a camel

Saturday, September 4th, 2010

Stubborn CamelI was just on Dr. Paul’s M-Power blog, and came across the following interesting thought (original post here).  It struck me so much I wanted to discuss it here.

Apparently camels have attitudes.  They grumble and complain no matter what  command you give them.  Dr. Paul saw a “wrangler” (I guess that’s what a camel trainer is called) trying to deal with a camel, and said: (more…)

thoughts on multitasking and relaxation

Saturday, August 7th, 2010

multitaskingI am a chronic multitasker.  I am always doing it, no matter where I am.  I can’t resist opening the laptop while watching TV, or checking my email constantly throughout the day, or putting someone on speakerphone to check the text that just came in.  Sometimes I’m on the phone, texting and chatting online all at the same time.  I am a multitasking addict. (more…)

worthwhile advice

Friday, July 30th, 2010

The thoughts in this post were adapted from a wonderful conversation with a good friend, and seem to be universally applicable.  Thus, they shall be immortalized here.  Also, if I write these ideas down here I can come back here if I forget them.

Three things that will lead to empowerment in your life:

  1. Stop asking WHY.  Instead, change it to WHAT NOW.  Instead of unanswerable questions that pound your brain you have hope, and at least some inkling of what to do to improve your situation.
  2. Don’t expect anything from yourself.  Just ACCEPT and EMBRACE yourself for who you are.  You don’t need to become a Superman to be lovable, and besides, you will be capable of accomplishing so much more if you love yourself UNCONDITIONALLY first.
  3. Don’t you EVER put yourself down!  You live with yourself 24/7.  You wouldn’t want to live with an enemy, would you?  It’s okay to make mistakes and course-corrections.  You are a child of God, and thus have limitless potential.

To combat sadness, do the following:

Count your many blessings!!  But you must abide by the following rules:

  1. You must start with “I have been blessed with …”
  2. You must not use any negative phrases.

If you follow the rules, you get a sense that a.) you really have a lot going for you, and b.) it comes from a higher source than yourself – make sure to give credit where credit’s due!  This brings your life into balance, stops you from getting a big head and brings things into perspective.  Nothing fosters love for Deity by seeing first-hand and noticing the things that God has given you, no strings attached, “just because.”

lessons learned from divorce

Monday, July 26th, 2010

EDIT: I’ve read over this post since writing it and changed some things to be more fair to Shanae.  It was pretty one-sided before and I’ve tried to make it more fair.

Broken HeartThere is only one person who is responsible for your happiness.  It is not God, it is not your parents, it is not your friends, it is not your significant other – it is you.  I am a firm believer that others can help, and that good friends are vital to our well-being as we go through life, but ultimately, when it comes down to brass tacks, every single one of us are responsible for our own actions and our own happiness. (more…)