If it is in the help file, then that is a feature ... if it is NOT in the help, it is a bug.
Text Rotation
TextField -> InteractiveObject -> DisplayObject -> EventDispatcher -> ObjectSo, I set the rotation and the text disappeared.
txt.rotation = -90; // This causes the text to disappear |
Let me be specific,
TextArea Component
I tried using the htmlText property and enclosing the text in pre tags ... same thing. (Actually, most html tags are ignored - *b* (bold) works, *p* (paragraph) fails, and so forth. There is no definition of which tags are supported, and some in the examples are not ... pretty lame.)
The following code fixes this problem by using a regular expression.
function FileRead_Done(s:String):void { var myPattern:RegExp = /\r\n/g; s = s.replace(myPattern, "\n"); TextDisplay_UITextArea.text = s; // without the *replace* command, this screws up crlf } |
And what does font="_sans" mean? Sometimes this is shown, other times it reports what I set it to. Either way, there is no obvious way to control the fonts.
TextDisplay_UITextArea.textField.defaultTextFormat.font = Default_Font_UIText.defaultTextFormat.font; // "Courier New" TextDisplay_UITextArea.textField.embedFonts = true; // The following also fails TextDisplay_UITextArea.textField.defaultTextFormat.font = "Courier New"; |
import fl.controls.*;
import flash.display.*; // This works import fl.controls.*; // This fails |
1172: Definition fl.controls could not be found. |
The solution is to manually add the controls you want to your form (via Windows / Components...) ... which automatically adds them to the library. Then, specific import's will work. You can still use the asterisk notation, but only those controls in the library will be found.
Once a control is in the library, then you can delete the control from the form (because the pieces will stay in the library).
This information is NOT in the help files.
Note that the help for Slider contains the following in the examples
import fl.controls.*; import fl.controls.Label; import fl.controls.Slider; import fl.events.SliderEvent; |
To make this even harder to debug - if ANY fl-control is placed on your form, then, sometimes, no error will be shown when you try to use a different control AND nothing will be displayed.
In a separate test case, there was an error when other controls were in the library. That's correct, I have 2 test cases - one shows an error and the other does not.
Don't get me wrong - this IS a reasonable design. However, the error message and the help file should be VERY explicit on this constraint.
For what it is worth - this took me over 6 hours to research and document. (It only took about half an hour to realize that this is a Adobe Flash design problem.)
Log10
x = Math.log(n) * Math.LOG10E; |
const inv_ln10 = 1/Math.log(10); x = Math.log(n) * inv_ln10; |
Method | Value | Comment |
---|---|---|
Math.LOG10E | 0.4342944819032518 | AS3 built-in constant |
1/Math.log(10) | 0.43429448190325176 | AS3 - This is what caused the problem |
1/log(10) | 0.43429448190325182765112891891661 | Microsoft calculator (high precision) |
1/ln(10) | 0.434294482 | (Google) |
Math.log(100)*Math.LOG10E | 2 | AS3 - multiply by provided constant |
Math.log(100)/Math.log(10) | 2 | AS3 - division sometimes uses more precision |
Math.log(100) * (1/Math.log(10)) | 1.9999999999999998 | This is the function I was using, except that |
ln(100)/ln(10) | 2 | (Google) |
Comment - I was taught that
At any rate, I needed the base-10 log to plot some data. C, Java, and Pascal (but not Flash) provide log10(x) for this purpose. Solution ... write my own. I stored 1/ln(10) as a constant that could be reused because multiplication is usually faster than division. I did not discover (or expect) the problem until my code failed. That is also when I discovered that AS3 provides a constant for this purpose.
Bottom line - it appears that AS3 has a design problem when computing 1/x.
Graphs & Sprite Sizes
If you want a drawing area to be 40x50, create it 39x49 with a border of one. However, only draw in the area 38x48 ... otherwise the drawing area will automatically increase (the values returned by width and height will increase).
Basically, subtract 2 from both the reported width and height to determine the size of the drawing area. Both moveTo and lineTo will change the size and scaling of the canvas (graphics property) if they exceed those values.
This is totally insane ... it only took 4 months to finally figure it out.
Stack Overflow
VerifyError: Error #1023: Stack overflow occurred. |
One *solution* was to add a trace() command to the routine. It does not matter which variable is traced ... even tracing a constant string (as shown below) "fixes" the overflow problem.
The following code produces this error
public function FormatYear(d: Date, style: String="4"):String{ var value : Number; // no error if this is omitted var s : String; s="help" ; // s="help" + " "; // no error if previous line replaced with this // trace(""); // no error when enabled return s ; } |
A similar problem is confirmed by Adobe - it was reported 11-16-2007.
Author: Robert Clemenzi - clemenzi@cpcug.org