How to change bitmap and label of an Button component [Flash CS5, ActionScript-s]
I have created one button component using one Bitmap and one Label in it.
Thing is that when user Clicks on on the button I want to changes button's Icon/Image and Label Text.I want to do this using FlashCS5 and ActionScript-3.
I have tried following but it gives me runtime Error
[Bindable开发者_C百科]
[Embed(source="/Images/test.png")]
var testIcon:Class;
testButton.setStyle("icon", testIcon);
Is there any other way of doing this.
Thanks.
You need to instantiate testIcon
first. Try doing this:
[Embed(source="/Images/test.png")]
var testIcon:Class;
var btnGraphics:Bitmap = new testIcon();
testButton.setStyle("icon", btnGraphics);
Looking at what you want to archive i think you should follow following steps 1. Create one movie clip using new symbol 2. Create Two new Button Symbol using 2 different images and label 3. insert these button into the key frames for the created movie clip
you can use this movieClip to create new buttons that can have 2 states just use gotoAndStop to display the proper button.
This is an answer for a followup that ppp asked:
There is a property
labelPlacement="right|left|bottom|top"
property. Default isright
if you set it to bottom, the icon will show above the text.You can create a button skin in flash and import them into flex. My experience with flex 3 skins imported from Flash is that it takes a bit of work and back and forth to get it working perfectly. Flash Catalyst for Flex 4 has greatly improved that workflow.
精彩评论