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 = Alert.show("message here");
alertInstance.swapDepths(_root.getNextHighestDepth());
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.
Sukk. Så fin utsikt fra balkongen da vi flyttet inn. En knapp måned bare, før den var innkapslet i stillas og vi våknet til synet av albanere som klatrer forbi og ikke minst til lyden av iherdig borring i mur, metallklumper som slippes ned fra hundre meter og deiser i lastebilplanet, jernkuler som klunker seg gjennom en metallabyrint etter mønsteret rulle-rulle-rulle-KLUNK-rulle-rulle-KLUNK-rulle-rulle-osv, lyder som trenger seg gjennom og blander seg inn i ellers søte drømmer og bølgesus. Urettferdig.
The function removeMovieClip in Flash is (in theory) supposed to be the opposite of attachMovie - it lets you remove a movieclip from the stage. There are only two catches. It will not work when:
1. The movieclip is placed manually on stage (so not using attachMovie)
2. If you happen to attach the movieclip to getNextHighestDepth()
So you can either hardcode the depth into which you want to load the movieclip, or you can create a colourful algorithm for finding an appropriate depth, or you can use swapDepths() to put the movieclip in an accepted depth before removing it. You can also use the DepthManager (which, according to its documentation, you need not use unless you are an advanced Flash developer), but this can only be used if you have a component on stage or in library, which makes sense in the Macromedia-world, because it is when using components that getNextHighestDepth() makes removeMovieClip() fail silently. One can only wonder what getNextHighestDepth() uses to determine the next highest depth, and why it does not use DepthManager when required. But hey, who needs working functions when there are so many workarounds to choose between?
It's all
documented without shame in the LiveDocs. Losers who use the help content following Flash however, will have to figure it out by themselves.
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.