Tuesday, December 2, 2014

Work Completed (12/2/2014)

I wasn't able to get around to creating rooms because I spent the time working through some bugs. I learned something critical about AS3 today while working through different SAVE CHANGES button and ADD ROOM button scenarios. The most common error I get is Error #1009: Cannot access a property or method of a null object reference which means I tried to access something from an object that hasn't been added to the world. What I'm now realizing is that this happens often due to objects adding other objects to the world in their added() function. Up until now, my thinking was those secondary objects get added to the world the same frame as their parent. However, I now think that this delays adding those secondary objects to the world until the end of the next frame. As a workaround to this issue, I've been setting an alarm to call whatever function is generating the error. That way, by the time the alarm goes off to call the function, the secondary objects have already been added to the world. The alarm only waits a tenth of a second so it would hardly be noticeable to the user but is still a cheap workaround and not the right way to do things.

No comments:

Post a Comment