PDA

View Full Version : How to make dynamic buttons?



bluemagica
August 27th, 2008, 12:31 PM
I am trying to make dynamic buttons....for me there are two ways, and i have queston for each.

1) I am creating a simple button, and a dynamic text field, within a movieclip.
Problem: When the cursor comes over the text field, it changes from "hand" to "arrow"...how do i prevent this?

2)I am creating a class for the button by extending movieclip.
Problem: How do i stretch the button to always fit the label within it?

Anil_kumar
August 28th, 2008, 03:05 AM
download the attached source file - dynamicBTNs.zip
or
enter this code in your flash document
-----------------------------------------------
var btnNos:uint = 5;

for (var i:int = 1; i<=btnNos; i++) {
var Btn = new BtnClass();
Btn.TextInBTN.text ="caption "+i;
Btn.name = "Btn_"+i;
Btn.y=(Btn.height+5)*i;
addChild(Btn);

}
-----------------------------------------------
class file BtnClass.as

package {
import flash.display.MovieClip;
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class BtnClass extends MovieClip {
public function BtnClass():void {
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK,ClickHandle r);
this.addEventListener(MouseEvent.MOUSE_OVER,OVERHa ndler);
this.addEventListener(MouseEvent.MOUSE_OUT,OUTHand ler);
this.TextInBTN.mouseEnabled = false;
}
private function ClickHandler(e:MouseEvent) {
trace("you clicked on "+e.target.parent.name);
}
private function OVERHandler(e:MouseEvent) {
e.target.parent.gotoAndPlay(2);
}
private function OUTHandler(e:MouseEvent) {
e.target.parent.gotoAndPlay(6);
}
}
}
-----------------------------------------------

Anil
anilkumarnd@gmail.com
Flash Workshop (http://flash-workshop.blogspot.com/)

bluemagica
August 28th, 2008, 10:41 AM
Thank you anil, but i dont need that code, i can already write that code......i need to know, how can i stretch the button to fit the dynamic text within it?

phaseworks
September 3rd, 2008, 01:33 PM
Thank you anil, but i dont need that code, i can already write that code......i need to know, how can i stretch the button to fit the dynamic text within it?

Hi i just cross your posting and i see you need a logo to be done?? .. well i am a graphic designer mu works can be review at www.mangunkusumo.com , you can contact me directly from there if you still need it to be done.

Thanks