Troubleshooting

     

Why are my trig functions going crazy?

graphics/troubleshooting_icon.jpg

When trig functions give wildly unexpected results, one common reason is that you forgot to convert degree measurements into radians. Although Flash measures _rotation in degrees, all the Flash trigonometry functions require angles to be measured in radians.


Measuring angles in radians and degrees is discussed in the sidebar "Radians and Degrees," earlier in this chapter, page 584 .


Why am I losing formatting when I load new text into a text field?

Say you've created a text field named myText , set the text attribute, and applied a format named myTextFormat . It works fine. When you change the text by assigning a new value to the text attribute, the text field reverts to its original configuration from the Properties Panel.

You need to use setNewTextFormat() in addition to setTextFormat() . This sets the format for new incoming text. You need to set it only once.

The following example shows the way to set the format. The problem, when the formatting reverts, is that you don't have a line like line 7.

 1: _root.createTextField ("myText",2,100,100,200,20); 2: myTextFormat = new TextFormat() 3: myTextFormat.Color = 0xFF0000; 4: myTextFormat.font="verdana"; 5: myText.text = "Original text"; 6: myText.setTextFormat(myTextFormat); 7: myText.setNewTextFormat(myTextFormat); 8: myText.text="Here's some new text." ; 



Using Macromedia Studio MX 2004
Special Edition Using Macromedia Studio MX 2004
ISBN: 0789730421
EAN: 2147483647
Year: N/A
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net