PDA

View Full Version : getting Alert component to open?


myBad.script
07-02-2004, 05:06 PM
I want a message to pop up on the screen when the user clicks the 'Submit' button on a simple email form. I copied the code right out of the mm help file, and converted it to work on click instead of focus out. I get the trace message, but no alert.

function messageNull(){
if (tf_message.length<1) {
Alert(_root, "Error", "You must enter something in the message field", mxModal | mxOK);
trace("message function called");
}
}
bt_submit.addEventListener("click",messageNull);

Same result (trace, but no Alert) when I attach the function directly to the button:
on(release){
messageNull.call();
}

(The website I'm working on is coming along fine - client is pleased, almost all functions are working properly....thanks for all your help. I may get good() at this yet.)

(Originally posted in the F/MX forum, but as this is component related it was suggested I try posting in this forum)

prospero
07-02-2004, 07:34 PM
Use Alert.show(...)!

myBad.script
07-02-2004, 08:02 PM
prospero, I noticed that in some other examples and tutorials I found (never mind that I'm working with mm's own tutorial!). I changed the code as follows, but still no joy:

/*function messageNull(){
if (tf_message.length<1) {
_root.Alert.show("Please make an entry in the message area", "Error", Alert.OK | Alert.CANCEL);
trace("message function called");
}
}
bt_submit.addEventListener("click",messageNull);

I get the trace, but no alert

myBad.script
07-03-2004, 02:45 PM
The answer: forget the component. It was faster and easier to build my own. (Files were smaller, too.)

lloyd13
07-23-2004, 05:36 PM
if you ever do want to use the Alert.show( ... ) I think you have to include

import mx.controls.Alert;

at the top of the code file.

BadDude
07-26-2004, 12:32 PM
and you should have an Alert component in your library too. :o