Friday, March 24, 2006

Flash has a neat Alert-component (professional version) which easily lets you display messages to the user, with the common (optional) No, Yes and Cancel buttons. However, the component can only attach itself to a UIComponent, and the default component is the main window (_root). One cannot therefore, attach the Alert-box to a MovieClip, because it is not a UIComponent. Since one cannot specify the depth in which the Alert-box pops up, a problem arises when dynamically creating movieclips, loading content into them, and subsequently displaying the Alert-box. First impression is that the call fails silently (common Macromedia exception handling), however, by coincidence I realised that it pops up underneath the dynamically created movieclips. I find this behaviour a bit strange for an Alert-popup, I would expect it to top everything currently on stage, whether created dynamically or not. Anyway, one solution is as follows:

import mx.controls.Alert;

var alertInstance:Alert ="message here");

This will at least put it on top of everything. Another drawback however, is that the modality does not seem to affect dynamically created content.


At 10:43 pm, Anonymous Anonymous said...


At 6:35 pm, Blogger laila said...

You're welcome! :)


Post a Comment

<< Home

En blogg kan være et godt verktøy for en som i litt for stor grad glemmer de små og store tingene som utgjør livet. Dette er min reserve- hukommelse.