2
votes

I've got a flex application that is dependent on a class that slightly abstracts flex's resourceManager. The (pure AS3) class I'm using extends EventDispatcher, and deals with runtime loading of localization information as well as returning the translated tokens. I can't use the base resourceManager, as I don't want it to return null if the token is not found.

/endexposition

My problem comes when I attempt to make my getString function bindable.

[Bindable(event="bundleLoaded")]
public function getString...

The "bundleLoaded" event is dispatched appropriately. This function works correctly in 90% of the applications I'm involved in the development of. However, for ONE application, I get the following obfuscated error:

1084: Syntax error: expecting rightbrace before s. Resource=(ProjectName) Path=(null) Location=line 301

The application compiles and works (minus the bindings, obviously) before I add the [Bindable...] line, but after I add that line it refuses to compile correctly. There is nothing even mildly interesting located on line 301 of any of the application or support classes.

Any tips? Anyone have a similar experience?

1
+1 for a wekk written question. This seems bizarre to me. Is the Bindable line the one that throws the error? IS the application throwing the error using the same SDK as apps that don't throw the error? Are there compiler setting differences? I'm grasping at straws, but what if you switch to single quotes instead of double quotes? - JeffryHouser
what is the code on line 301? If the code on line 301 is the [Bindable] then you probably have an issue with some code on the line before it. Try moving those lines to the top of the class and see what error you get. I bet you are missing a "}" or a "]" somewhere in the function before 301 - The_asMan
@Flextras, yep, same SDK (3.5). Shouldn't be any compiler settings differences, but I'll double check. The other applications are in the same project (dev'd in Flash Builder 4.0) though, so it's unlikely (impossible?). Will try single quotes, I've been grasping at straws for hours :) - Sam DeHaan
@asMan, this particular class doesn't have 300 lines. I've attempted to move them around, added white space, found no difference in the error. At this point I'm assuming it's a problem in the auto-generated code created by the [Bindable...] metadata, which (thanks to a response on the flexcoders yahoo group) I'll take a look at shortly. - Sam DeHaan

1 Answers

0
votes

Well, after searching through the generated code, I found an issue (which wiiiiill be bug reported to the flex sdk).

My code bound a text property to a resource (for localization).

That property used a ternary operation. Once I created this binding, the generated code stripped out the ":" and "?" from my ternary operation, and caused an error.

    myResourceManager.getString('bundle','token',[numDays, numDays != 1 ? 's' : ''])

The compiler turned that into...

    new mx.binding.FunctionReturnWatcher("getString", target, 
        function():Array 
        { return [ "bundle", "token", [target.numDays, target.numDays != 1"s"""] ]; }

Leaving me with a nice, ambiguous compiler error. Thanks for looking, guys! This one's fixed.

EDIT: If anyone's interested: https://bugs.adobe.com/jira/browse/SDK-30937