so im trying to make a btn (which i have done before but cant work out what in doing wrong)
i have a text box with text in it
i create a button symbol and name it appropriatly. hit ok and it takes me through to the btn time line but there is nothing on my stage and the keyframe is empty.
how do i get the text box into the btn time line?
i have tried making it a dynamic text box and i have tried creating a btn in a new file with a simple rectangle but the same thing is happening
PLEASE HELP its driving me insane!!
You should be able to copy and paste the textfield into the button's frame(s). You can also just create a new textfield if you are already in the button's timeline.
From what you described, it appears as though you are trying to convert the textfield into a button. To do that, create the textfield, right click it, select Convert to Symbol... and follow thru with creating a button symbol from there.
Draw your button first using the shape and text tools. Once you're happy with it, select it all (shapes and text) and hit Modify->Convert to Symbol (F8) and choose Button. Now you have your text inside your button. Feel free to add a keyframe on the over and down states and change the look of the buttons background or text.
If you do this, please make sure your textfield has the "selectable" property disabled. You just click on your textfield, go to the properties panel and there is a button there you can enable or disable the ability to "select text" in the textfield. That will interfere with the button working so please disable it.
How do you create a button from a symbol using actionscript. I have several created in kind: b1, b2, etc
b2 = new Button();
b2.label = "How To";
b2.height = bH;
b2.width = bW;
I was going to ask how to set the background colour of the button, all I could find was - better to use a symbol. Depennding on the device there will be different numbers of buttons so would like to create them at runtime.
I don't think you can with AS3. A Button component like you're making above differs from a Button symbol. The only real benefit of the button symbol type is it's easy for designers to make off/over/press/hitarea states easily. There's a library of premade button symbols in Window->Common Libraries->Button incase anything in there suits you. If there is, export for actionscript and generate them from the library like you want.
The way you'd programmatically create a button yourself is just make a Sprite, set the buttonMode = true, mouseEnabled = true, useHandCursor = true properties. Then draw the button using the Sprites graphics class along with loading any textures you need inside the button using other standard classes like Loader or embedded bitmaps directly from the library.
Then it's up to you to programmatically handle the MOUSE_OVER, MOUSE_OUT states and all the code necessary to alter the look of the button. You're saying this will be on devices so use the Touch events (check if you're in the begin or ending phase).
You're probably just better off using the IDE to create your button, use 3 or 9 slice so you can resize the button to match the text and instantiate that button via the actionscript link rather than coding it up. It's just fast and easy. Make sure you name all your instances inside the button so you can access them (TextField, the graphics, etc).
Thank you Sinious. All taken on board. Much appreciated. Sometimes I spen days looking for solutions, I have the embeded fonts and text sizes fine so for now I'll go with that - but will study what you have given for the next revision. Thanks