Sunday, 16 May 2010

NetStream problem

Right, I just had one of those 'what the...!?!' moments, where something works, and then you make some entirely unrelated changes, and then it all falls apart, for no apparent reason.

These things normally drive me to distraction, and I just delete it and try a workaround. But today, there was no workaround, and I learnt an important lesson.

The error that I was getting was one of these:

TypeError: Error #1010: A term is undefined and has no properties.

I hate these errors, because they never tell you the name of the term that they did not recognise, is that so hard? Anyway, under the error phrase, there is usually, to the best of my recollection, a list of functions. The lowest one down is the first one to be called, the next one is one that called by the one beneath it, and so on, until you get to the one at the top, which is the one that contained an unrecognised term.

The quickest way to figure out exactly which one it is, is to comment out all the actual code, and get flash to trace out each variable that the function is supposed to use. For me this worked, because something came out null, when it should have been a NetStream object.

Here is the thing that really confused me, the 'stream' variable was clearly declared at the beginning of the script, and as I said the whole thing was working just a few changes ago.

The next step I took was to trace out a message saying what stream was several times in the script, and it only traced out the first one! The problem was not in the function that had the unrecognised term (stream), actually, it was at the top of the script, and it had nothing to do with 'stream'. I had a line of code referring to a movie clip that I had just deleted, and it's absence was preventing the rest of the script from running properly. I should have picked up the error, but old trace statements meant that I didn't see the relevant error.

I'm glad I figured this one out - its so frustrating when you can't.

No comments:

Post a Comment

Please enter your message here...