0 Replies Latest reply on Sep 11, 2009 4:20 PM by FlexPHX

    AS3 class inheriting from MXML problems

    FlexPHX

      Hi,

       

      I had some pretty strange (and only intermittent) compile errors, eventually I figured out that the culprit was our custom Button class - the CustomButton class was an AS3 class that inherited from ButtonBase.mxml, and ButtonBase.mxml inherited from mx:Button. The compile errors didn't really make any sense - a bunch of embed errors in our stylesheet  (all the embedded assests were in place) and then some nonsensical errors like "Implicit coercion of a value of type CustomButton to an unrelated type Object" and "Comparison between a value with static type Object and a possibly unrelated type CustomButton". I mean - everything (perhaps besides the basic types like int) is an Object, right?  At first I figured out that the CustomButtons that had an id property assigned, but not referenced was causing the issue - so removing the id prop. or referncing the CustomButton somewhere else solved the issue as well. However, I didn't like this solution as even unreferenced ids help code readability so I dug deeper and eventually I've changed ButtonBase.mxml to ButtonBase.as. This solved the issue to my satisfaction.

       

      So the questions for you experts is - is AS3 class inheriting from MXML a big no-no? Why were the errors so weird and obviously nonsensical?