flash actionscript:
So everyone knows about the capability in Flash to convert a text field into a symbol (more specifically a button). But does anyone know how to do this behavior in action script. It would be very useful for me at the moment. Thanks a whole lot. So this is what I've got: createTextField("testF",1,0,0,500,500) testF.text = "test text" mybutt = new Button mybutt = testF trace(typeof (mybutt)) Doesn't work though...
Typeof will not tell you if your object is a button or textfield. It will only return "object". And you're not actually converting the text field itself into a symbol, it's just creating a symbol and adding that text field inside it. So, in your actionscript you'd have to create an empty movie clip, then create a text field inside that. Then you would define your onPress, onRelease, etc methods on that movieclip: _root.createEmptyMovieClip("mcButton", 1); _root.mcButton.createTextField("testF", 1, 0, 0, 500, 500); _root.mcButton.testF.text = "test text"; _root.mcButton.onPress = function() { trace("mcButton pressed!!"); };
MechaFlasher, You my friend, are freakin' cool. Do you know if there is a way to auto size the textfield to only be as tall and wide as the text itself? krl
No prob. There is a way to resize to fit the text: myTextField._width = myTextField.textWidth; myTextField._height = myTextField.textHeight; or set autoSize before you put text into it: myTextField.autoSize = "left";
MechaFlasher, You have once again shown that you are "freakin' cool". Thanks so much for your help.
Don't see what you're looking for? Try a search.
|