Flex 3 – Errors in the Problem Pane May Not Actually Be Where They Appear To Be

I just ran into a pretty weird problem during some Flex development that had me cursing and throwing things around the office…ok, not really, but it was still frustrating.

After getting the latest code from our source repository, I kept getting compile errors in Flex Builder but the line that had the error *didn’t even exist* in the file that was causing it to break.

Long story short: our designer had built various doodads in Flash to use as style components, then referred to those doodads in a stylesheet.  Any item in my Flex code that used those styles was breaking because Flex couldn’t find the object that the style was referring to.  But it gets even more interesting!

As you may be aware, when Flex Builder does a compile, it turns your nice, pretty declarative MXML tags into plain ‘ol nasty ActionScript before it does the actual compilation.  The *true* place in the code that was killing the compile was in fact in the generated ActionScript files.  And every place in those generated files where the Flash components were referenced was causing an error.

During the course of figuring this out, I checked the “save generated code” checkbox (it’s in the Project properties) which gave me a nice folder full of ActionScript files (generatedCode, i think it was called).  Guess what was in there?  The lines with errors.  Through those files I was able to figure out that the style stuff was causing the problem.

But if I got latest code, why wasn’t the CSS finding the nifty Flash doodads?  Great question.  It’s because I needed to add the SWF (or SWC, or whatever you use) as a library reference in my project.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: