RSS
email

Actionscript Buttons



Step1: draw a rectangle using rectangle tool

step2: convert to button (select the rectangle and press F8) or Modify-->Convert to symbol

step3: Register point in center (optional)

step4: duplicate to five or more buttons by copy and paste

step5: name the buttons as num_mc1,num_mc2...num_mc4,num_mc5

step6: paste the code below in first frame


import mx.transitions.Tween;
import mx.transitions.easing.*;
var current_val:Number;
var old_val:Number;
for (i=1; i<=5; i++) {//change the number(5)--> to max buttons in stage
_root["num_mc"+i].num = i;
}
for (k=1; k<=5; k++) {//change the number(5)--> to max buttons in stage
_root["num_mc"+k].onRollOver = function() {
current_val = this.num;
if (current_val != old_val) {
var text_tween:Tween = new Tween(this, "_xscale", Normal.easeOut, 100, 150, .1, true);
var text_tween:Tween = new Tween(this, "_yscale", Normal.easeOut, 100, 150, .1, true);
}
};
_root["num_mc"+k].onRollOut = function() {
if (current_val != old_val) {
var text_tween:Tween = new Tween(this, "_xscale", Normal.easeOut, 150, 100, .1, true);
var text_tween:Tween = new Tween(this, "_yscale", Normal.easeOut, 150, 100, .1, true);
}
};
_root["num_mc"+k].onPress = function() {
_root.current_val = Number(this.num);
if (_root.current_val != _root.old_val) {
trace("you have selected button--"+_root.current_val);
var text_tween:Tween = new Tween(_root["num_mc"+old_val], "_xscale", Normal.easeOut, 150, 100, .1, true);
var text_tween2:Tween = new Tween(_root["num_mc"+old_val], "_yscale", Normal.easeOut, 150, 100, .1, true);
var scale_val:Number = _root["num_mc"+current_val]._xscale;
var text_tween3:Tween = new Tween(_root["num_mc"+current_val], "_xscale", Normal.easeOut, scale_val, 150, .1, true);
var text_tween4:Tween = new Tween(_root["num_mc"+current_val], "_yscale", Normal.easeOut, scale_val, 150, .1, true);
}
_root.old_val = Number(this.num);
};
//end on press
}


step7: press ctrl+enter

Bookmark and Share

0 comments:

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.