Monday, December 11, 2006

Bug with V2 Alert component?

A collegue was telling me that he was having troubles with displaying alerts using the V2 Alert component. The alert message was getting truncated at some point or other. I set out to investigate the problem, and saw that this only happens when the alert displays an icon in it. A simple alert (with no icon) didn't seem to exhibit this problem.
Try this out:

Alert.show("Hello world, this is a test implementation", "Alert", Alert.OK, this, alertHandler, "alertIcon", Alert.OK);

"alertIcon" is the linkage ID of a 25 * 35 px movieclip in library.
Do a test movie, and the alert displays "Hello world, this is a test implement". As you see, the last word is partially truncated.
After a few minutes of fiddling around with the mx.controls.alertClasses.AlertForm class, I figured out that editing the following statement(lin no 213) in getSize method helps
before:
width = Math.min(extent.width + 4 + 8, 2 * bWidth);
after:
width = Math.max(extent.width + 4 + 8, 2 * bWidth);
Please note that when you do this change, And when your alert message is really small ( like "hello world") you'll still see that the alert box is a lil too wider. But in a practical sense, most messages that you alert users are atleast 3 -4 words long, so this wouldn't be as much as a problem as losing out some data!

I googled for this issue a bit, and since I didn't find much info on that, thought I'd post it up here.
Post a Comment