Spark: Alert

Spark doesn’t include an s:Alert control and I’d put one together previously as a bit of test so I thought I’d push it out there.

It differs in its use from the mx:Alert in that you can add whatever buttons you want instead of being limited to a single set of predetermined flags (you can create you own predetermined flags as constants in a class as used in the example).

The component supports the following SkinParts (all are optional)

  • messageDisplay : TextBase
    - defines the appearance of the message text
  • buttonGroup : Group
    - defines the appearance of the button area
  • iconGroup : Group
    - defines the appearance of the icon display
  • and the following inherited from spark.components.Panel…

  • controlBarGroup : Group
    - defines the appearance of the control bar area
  • titleDisplay : TextBase
    - defines the appearance of the title text
  • The inherits the styles from Panel and adds the following:

  • buttonStyleName
  • messageStyleName
  • titleStyleName
  • On clicking a button the Alert removed itself and dipatches a CloseEvent specifying the index of the button click in CloseEvent.detail.

    (right click for source)

    The source for the Alert code can be downloaded from our Google Code repository (I promise to get some sort of SWC action going on there and I’m working on docs). The following 2 classes have been added.

  • ws.tink.spark.components.Alert
  • ws.tink.spark.skins.AlertSkin
  • 14 Responses to “Spark: Alert”

    1. polyGeek says:

      Nice work. I’ve been missing this in Spark.

      BTW, How come you aren’t on Twitter? Inquiring minds want to know. :)

    2. polyGeek says:

      Frak! I wanted to be your first follower!

    3. Tink says:

      Strangely enough someone else got in there 18 mins & 9 mins before ya.

      I’ve had the account for a while, prob never tweet anything.

      Seems to me people mainly have public conversations over twitter. If you want a convo with me, just send me an IM ;)

    4. [...] is no Alert spark component in Flex 4. A quick search for “Spark Alert” will bring up a solution by Tink, part of his set of custom Spark components. Unfortunately, it didn’t work in my project. [...]

    5. pavlo says:

      fyi, in flex hero (latest build), got the following error:

      typeError: Error #1006: setDefaultStyles is not a function.
      at ws.tink.spark.controls::Alert/set moduleFactory()[/Users/tinktink/Documents/tink/libraries/Tink Google Code/flex4/spark/src/ws/tink/spark/controls/]
      at ws.tink.spark.controls::Alert$/show()[/Users/tinktink/Documents/tink/libraries/Tink Google Code/flex4/spark/src/ws/tink/spark/controls/]

    6. Ben says:

      I also got the above error that pavlo submitted.

    7. Tink says:

      Are you sure you guys are using the most up-to-date version. I just checked and it ran fine for me, although i made a change to the default button heights and committed it in.

      Looks like i refactored the code that was causing your error back in Feb.

      The SWC hasn’t been updated though. You’ll need to check out the source and rebuild a SWC

    8. Gabri says:

      I also got the same error…

    9. Jamal says:

      Same here same error.

      This component is buggy.

    10. Kumar says:


      I downloaded the latest swc from Goodle code repository. I added the swc to your example project. First it gave me an error that it could not find ws.tink.spark.components. So using code hint I had to change the components to Controls. Compiled fine but gave me the folowing error:
      ReferenceError: Error #1065: Variable mx.accessibility::AlertAccImpl is not defined.
      at _AlertExample_FlexInit$/init()
      at mx.managers::SystemManager/[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\]
      at mx.managers::SystemManager/[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\]
      at mx.preloaders::Preloader/timerHandler()[E:\dev\hero_private\frameworks\projects\framework\src\mx\preloaders\]
      at flash.utils::Timer/_timerDispatch()
      at flash.utils::Timer/tick()
      Is the correct SWC in the repository? I am running Flash Builder 4.5.
      Thanks for your help.

      • Tink says:

        Hi Kumar

        TBH i wouldn’t recommend using this component instead favoring the use of SkinnableContainer, or better yet, make your own SkinnableComponent and extend it. I don’t maintain that class in the most up-to-date version of the lib. I really should remove it!

    Leave a Reply