Tutorials

Easy solution for one annoying HGroup/VGroup layout issue

Text elements in horizontal and vertical layouts are sometimes coward. When text is small, layout looks nice:

If the text is controlled by user and layout is not smart enough, it can look this way:


“Logout” button is invisible, search

Storing icons in external ZIP and seamless work with composite icons

There are a lot of ways to work with icons in Flex, e.g.:

  • Use @Embed(...) directive inline
  • Use [Embed(...)] metatag and store all icons in class like Assets.as

All this is good until you have too much assets because:

  • Each

Cloud Layout

Here is the CloudLayout.as [plain] that does nice Web 2.0 tag cloud:


View Source

Horizontal Multiline Layout

Sometimes it is necessary to place elements horizontally (like HorizontalLayout) in several lines instead of just one line:

Fit buttons in the toolbar

Sometimes buttons does not fit in the toolbar:

Runtime icons for Flex components

Bitmap or BitmapData can not be used as icon in Flex components like MX Button because they want Class that will instantiate as BitmapAsset.

Solution

Create cache of special classes. Each of them will be able to become an …

Start/stop all nested MovieClips

Animation takes CPU time and sometimes it’s useful to stop/play it. The problem is that MovieClip’s in animation can be hardly nested.

Solution

Stop/start MovieClips recursively:

  1. public static function massStop(target:DisplayObjectContainer,
  2.     frame:Object = 1)

Change font size in the whole app with Ctrl+/-

Browser supports changing page font size with Ctrl+/- and Ctrl+scrolling, but Flex applications are not affected by this. People with failing sight can not use such applications.

Solution for Flex 4

Work with StyleManager and set fontSize style at …

Generate color theme for Flex application using Camera

User may want to make Flex application look like himself, his room or his jacket.

Solution

Use Flex 4 color styles chromeColor, accentColor and screenshot from the Camera.

http://kachurovskiy.com/f/ria/10/camera-theme/ColorSchemes.html

Flex 4 provides coloring via styles chromeColor, color, …