flash actionscript:
I've tried a variety of things such as: _root.stepDescription.multiline = true; _root.stepDescription.autoSize = true; _root.stepDescription.textarea.wordWrap = true; to no avail. how do I get an instance (or all of them) of a label component (here the instance is named stepDescription)from the UI componenents to word wrap. The text property of the stepDescription of the label is dynamically populated by XML. Please help. It's much appreciated. I'll be able to stop wondering why these Flash components don't work like VB components! Bj
I am pretty sure that this was covered in an earlier post. I think she posted under the name "B". Anyway this is basically what she found. The label's properties are being set in the class definition of the label. If you look in the folder: Flash UI Components:Component Skins:Global Skins You will see a component named FLabel. If you edit this component and look at the code defining this class you will see two functions: setLabel and setSize. I would try and set the autoSize, multiLine and wordWrap properties in one of these 2 function definitions. Probably setLabel would be the best. This should take care of the multiline and wordwrapping issues you are experiencing. HTH. Tim
Tim, Thanks for your post and alerting me to B's post. I had not assumed that radio button labels and check box labels were the same as the just lable UI component. Following "B" 's instructions had no effect on my labels. The text runs off the side of the screen. Perhaps this is the desired effect, but not for me. What I expect from a component called a label is that it will automatically word wrap. I guess I need to write some script that counts the number or chars in the XML field that's populating the the label and then figure out how to force line feeds. Does anyone know how to force linefeeds? thanks, Bj
I'm making some progress with my insert linefeeds script but when I run it in Flash, "A script in this movie is causing Flash to run slowly. If it continues to run you computer may become unresponsive. Do you want to abort the script?" //take care of linefeeds for stepDescription.text field rawText = newSlideNode.firstChild.nodeValue; rawTextLength = rawText.length; breakpoint = 58; if (rawTextLength > breakpoint) { while(charat(breakpoint) != " "){ breakpoint--; } substring1 = rawText.slice(0,breakpoint); substring2 = rawText.slice(breakpoint++); stepDescription.text = substring1 + newline + substring2; } else { stepDescription.text = rawText } works fine if else is triggered instead of true condition for if statement. I'm no good with this actionscript stuff. If its something obvious to those of you who can see a missing semi colon from a mile away, please let me know. Thanks, Bj
I have attached a FLA that has the modifications to the FLabel component that I was talking about. If you set the width of the check box and then do a Test Movie you will see the label auto wrap to the second line. The auto wrap does not appear in the authoring mode. If I figure out how to get it to do that I will send you another post. Tim
ah ha! Great answer Tim, but my question was the problem. I have flash MX 2004 pro and was using the label ui component, which doesn't exist by itself in plain old flash mx. I didn't know it was new. the label by itself behaves differentlly than the label attached to a radio or checkbox as in the example tim posted. I haven't managed to make it word wrap, but I do see that the labels attached to radio buttons and check boxes do wordwrap, which is very helpful and information I will use later. in the attached file both .fla and .swf compiled for the Flash player 7 shows that the label stand alone component doesn't word wrap even when the beside a checkbox that does word wrap. (the fsLabel was modified to make the checkbox label word wrap) There's a horizontal yellow line showing the end of the plain jane label object. If autoflow is set to true, it runs over the yellow line but never wraps. So now I have learned that to get the functionality I want, I need to use a textarea component. I've been able to get the XML to populate the textarea which uses the construct mytextarea.content as opposed to what a new user might logically expect based on the use of other components: mytextarea.text. Also setting the background color on the textarea must be done with "color" in the syntax as "Color" in the syntax won't work, which is counter intuitive to us Windows users. so setting the style for my labels looks like this: myLabel.setStyle("fontSize", 14); myLabel.setStyle("fontFamily", "_sans"); myLabel.setStyle("fontWeight", "bold"); myLabel.setStyle("color", "0xFFFFFF"); but setting style on the textarea looks a little different: myTextArea.setStyle("fontSize", 14); myTextArea.setStyle("fontFamily", "_sans"); myTextArea.setStyle("fontWeight", "bold"); _global.styles.TextArea.setStyle("backgroundColor", undefined); myTextArea.setStyle("borderStyle","none"); _global.styles.TextArea.setStyle("color", 0xFFFFFF); note the two globals. I could not get backgroundColor or color (font color) to set on the instance the code was simply ignored. The only way to get the textarea background and font color to be the same as the label was to apply a global style to those 2 parameters myTextArea.setStyle("color", 0xFFFFFF); myTextArea.setStyle("backgroundColor", undefined); these two lines of code were ignored, so I had to go with the global setting from above. But once you get past the differences between the class constructs for textarea vs label, the textarea component is more powerful. It will automatically wordwrap and if the content overflows the bounding box it will automatically add a scroll bar. (This was a nice feature as in VB if I anticipate that a scroll bar might be needed, then I have to attach it programmatically to the textarea. In Flash, no extra code was needed to convince the text area to add a scroll bar if needed.) Bj
oh and one last thing, for those of you that didn't catch my code error for the character count insert newline function which I didn't end up using because it turns out the textarea component meets my needs.... while(charat(breakpoint) != " "){ should be while(rawText.charAt(breakpoint) != " "){ doh!
Don't see what you're looking for? Try a search.
|