Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-24-2012, 09:16 PM   #1
Hummerr
Registered User
 
Join Date: Jun 2012
Posts: 8
Default [AS3] UI component "Button"

Hi everyone, I need to realize the UI component "button" with it's own logic, that has methods or properties which allows to change: Number, color, lock-unlock and other. But there is one important detail - if the number that is centralized on the button will be longer than five symbols - the button must expand. Do you know where to find some examples, or may be you can give some advices :-) Thanks!
Hummerr is offline   Reply With Quote
Old 06-24-2012, 10:56 PM   #2
CodeVisual
Registered User
 
Join Date: Jun 2012
Location: USA
Posts: 27
Send a message via Yahoo to CodeVisual
Default

The changes you speak of can be done with the button component as is.

Change color:
Code:
var btn:Button = new Button();
addChild(btn);

var ct:ColorTransform = new ColorTransform();
ct.color = 0x00000;

btn.transform.colorTransform = ct;
Disable/enable:
Code:
btn.enabled = false;
//or
btn.enabled = true;
However, I'm not sure what you mean by changing the "Number" of a button.

To expand the button according to the amount of text you want in it, you can use code similar to this.

Code:
var str:String = "This is a lot of text for a button";
btn.label = str;
btn.width += str.length*3;
I'm not saying you shouldn't make a button from scratch, but this approach might be easiest and suit your needs.
CodeVisual is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:06 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.