PDA

View Full Version : Alerts show behind ActionScript generated components


Blake1024
05-07-2005, 03:04 PM
When I create an Alert it appears on top of components added through the
IDE (Flash MX 2004 Pro) but it appears behind components I've added via
manual ActionScript code. I want the allert to behave like a message box
but it is no good since I generate most of my components via ActionScript.
How can I make the Alert's always show on top of all the components?

For example, create a SWF and add one TextInput control by fragging it
on the stage with the IDE. Then execute the following code:

import mx.controls.Alert;
import mx.controls.TextInput;

createClassObject(mx.controls.Label, "staticText1", getNextHighestDepth(), {});
staticText1.move(300 , 4 );
staticText1.setSize(94 , 20 );
staticText1.text = "Select Application";

createClassObject(mx.controls.TextInput, "City", getNextHighestDepth(), {});
City.move(48, 111 );
City.setSize(224 , 18 );
City.text = "Miami";

var msg = Alert.show("My message", "Message Window");[/FONT]

See how the Alert appears above the IDE added component but behind the
ActionScript generated controls. You can tell by moving the Alert around on
the screen. How can I fix this?

Thanks a lot.

cxn926
05-07-2005, 03:07 PM
Put It In As Tags Please!!!!!!!!!!!!!!

Blake1024
05-07-2005, 03:40 PM
What is a Tag?

cxn926
05-07-2005, 04:09 PM
do you see the symbol on the message thing that look like a black f on a red circle. click that 1nce then type your code then click it another time. i hope you understand

Blake1024
05-07-2005, 04:14 PM
I thik I got it. Like this:

trace(getNextHighestDepth());

Now, how can I solve my problem?

I tried

msg.setDepthAbove(City);

And it works but requires that I always know what my last added control is. I then
tried:

msg.setDepthTo(getNextHighestDepth()-1);

or

msg.setDepthTo(getNextHighestDepth()-1);

But that just hangs the Alert. ???

Blake1024
05-07-2005, 04:16 PM
The second thing I tried was:

msg.setDepthTo(getNextHighestDepth());

(which hung the Alert).

mmm..pi..3.14..
05-07-2005, 04:59 PM
One line is all it takes...

import mx.controls.Alert;
import mx.controls.TextInput;
createClassObject(mx.controls.Label, "staticText1", getNextHighestDepth(), {});
staticText1.move(300, 4);
staticText1.setSize(94, 20);
staticText1.text = "Select Application";
createClassObject(mx.controls.TextInput, "City", getNextHighestDepth(), {});
City.move(48, 111);
City.setSize(224, 18);
City.text = "Miami";
var msg = Alert.show("My message", "Message Window");

//move the newly placed Alert component to the top level
msg.swapDepths(_root.getNextHighestDepth());

Eric