Flash/XML
- Started
- Last post
- 9 Responses
- ian
Hey there, quick q about xml in flash. Ive built XML menus before that have been very simple, boxed off vertical menus but working on a project now and they want something more varied, text with a background colour that only expands to the width of text so each menu item will be a different length, so normal duplicate MC wont work. Any help would be greatly appreciated!
- blaw0
you can still use duplicateMovie. set the autoSize property of the dynamic text box within the MC to 'true', then use that to determine the width of the background box.
- dijitaq0
use the TextField class.
set the background width of your button using the textWidth property of the text field when you build your menu
- rson0
well you have the length of the array so just base the box count on that num
- st33d0
The TextFormat object also gives you measurements on possible text before you've even instantiated a TextField:
- ian0
Hi there, thanks for the tips I'll try em out!
- fugged0
Rather than using duplicateMc, why not create movieclips on the fly with createEmptyMovieClip ?
You can then create the textfields, set their text and then get the width of the rendered text to create a background MC.
var menuItem:MovieClip = someMovieClip.createEmptyMovieCl... depth);
menuItemLabel = menuItem.createTextField("menuIt...
menuItem.menuItemLabel.autoSize = "left";
menuItem.menuItemLabel.text = "This is a menu item";Obviously you'll need to enter the correct arguments to the creation methods, but I think you'll understand.
You can then create another movieclip whose depth is less than the textfield and use the drawing API to create a box around the type, or you could even just set the background color of the textfield via it's backgroundColor property.
- Rand0
this shit should all be available as customizable components. Why should you have reinvent the wheel every time?
- UndoUndo0
its the opportunity to reinvent the wheel as a square or oblong that is good, pointless if it is round everytime. at least there is the opportunity