Quick Tip: Flash CS Button to Flex

If are trying to embed button symbols (extended SimpleButton) from Flash CS and the results are not what expected:

[Embed(source="assets/elements.swf", symbol="my_button")]
public static const BUTTON_CLASS:Class;
...
addChild(new BUTTON_CLASS())

try exporting your elements into .swc and attach into Flex project, later in code do:

public static const BUTTON_CLASS:Class = my_button;
...
addChild(new BUTTON_CLASS())

This may also help you capturing Event-s dispatched on custom frame from loaded MovieClips.

Quick Tip: SimpleButton to SelectableButton

sk.yoz.ui.SelectableButton class may be handy for you if you decided to drop framework and make your own lightweight components. It extends SimpleButton (basic ActionScript 3 component) and ads selected state and toggle functionality by switching states on click event. You may want to extend it for selectedUpState, selectedOverState, selectedDownState, feel free to do that.

usage:

import sk.yoz.ui.SelectableButton;

// any graphics here
var upState:DisplayObject;
var overState:DisplayObject;
var downState:DisplayObject
var hitTestState:DisplayObject;

// changes selected state on mouse click
var toggle:Boolean = true;

var button:SelectableButton;
button = SelectableButton(upState, overState, downState, hitTestState, toggle);

// toggle select button without user interaction
button.selected = true;

Read the rest of this entry »

Get Adobe Flash playerPlugin by wpburn.com wordpress themes