WTF? FD embedding problem?

4 posts

Flag Post

OK, so I’m trying to push myself to work on the GiTD thing, and I’m testing just to make sure the player’s character moves properly. Lo (and behold), it gives me a “sourceBitmapData must be non-null” error for the copyPixels call. The thing is, I’m embedding the image and assigning it to a bitmapData object exactly like I did for the last GiTD (which worked fine).

I had updated FD before working on this (actually, un- and re-install), but I wouldn’t think that would be the issue…

[Embed(source = "images/horseman.png")] protected static var horsemanGFXClass:Class;
…and in the constructor:
actorMap = (new horsemanGFXClass() as Bitmap).bitmapData;
…and the render call:
renderer.copyPixels(actorMap, actorScrollRect, at);

So I tried changing it to extend the Sprite class and adding the image directly to the screen (commenting out the lines that give the aforementioned error), but nothing appears. If I double-click on the image in the directory list on the right, it opens and shows exactly what it is supposed to show.

Flag Post

Trace actorMap immediately after assigning to it. If it’s null, recheck the path you use (I know you’ve checked it already; do it again). Otherwise, search your code for “actorMap =” to see if it gets set anywhere else.

Flag Post

Did you generate the embed tag by right-click/generate embed code in the project pane? I ask because your source path looks…unconventional. Try the generate embed code again and make sure the directory matches what you have.

Flag Post

Well, thanks for the suggestions, both of you. It turns out it was something far more stupid: I had typed “Horsemen” as the constructor name instead of “Horseman”, like the class name…. I kept wondering why the damned trace statements were showing up everywhere but there. If I had paid closer attention, I might’ve noticed that the function name colour wasn’t light blue…

Sorry about that. I kept screwing with it, trying to figure it out, but I couldn’t seem to make any headway (no wonder)…