all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

Basic Alert not working, please help!


Basic Alert not working, please help! Aureus_Videre
1/13/2005 7:37:54 PM
flash actionscript:
I'm trying to get a very basic alert to come appear when a user clicks on a
link that leaves our site (all of our pages are in flash). I've followed every
instruction on the matter I can dig up, and everything I've tried results in
either a syntax error or nothing happening. Strangely the import command I've
seen everywhere (import mx.controls.Alert) results in a syntax error, while
import.mx.controls.Alert does not. I've placed both of these (at various
iterations of my attempting to make this work) just about everywhere in my
flash file that makes sense. I have placed the alert in my library, and I have
also tried using the full mx.controls.Alert.show(), all to no effect. Any idea
what is wrong? Here's my code on the button/link:

on (release) {
mx.controls.Alert.show("This link will take you away from our website.");
getURL("http://www.etfconnect.com", "_blank");
}

The URL comes up, but no alert. Please help me.

~AV
Re: Basic Alert not working, please help! abeall
1/13/2005 9:43:56 PM
I am on MX so can't really help you, but I can say: 1) the reason import.mx.
works is likely because incorrect object referencing via dot syntax does not
produce an error. so in other words, Flash thinks you are referencing the MC
import, not trying to import something. so nothing is being imported. 2)
Making you own Alert() object would not be hard, I suggest doing it. 3) note
that the alert would show for only a split second, then the page would load, so
theres not much of a point to it. don't know how alert() works, but I would
think you want more a confirmation
Re: Basic Alert not working, please help! Aureus_Videre
1/13/2005 9:50:32 PM
Hmm, I see... I am also on MX; I even grabbed the update this morning, so we
are working in the same program. There is no confirm window that I am aware
of, all such objects are handled through the Alert component from what I have
seen. I'm rather new at flash, my company didn't want to use our consultant
for the site anymore, so now all editing and updates are my responsibility...
translating into a crash course in Flash and Dreamweaver for me. Is there any
way to keep the alert from disappearing in the case that you described? Also,
as we are both working in MX, do you know why the import command is generaing a
syntax error?

Thanks,
AV
Re: Basic Alert not working, please help! NSurveyor
1/13/2005 10:05:01 PM
Aureus, are you using MX (v6) or MX 2004. Because, you can't use the Alert
component in MX, only in MX 2004. Also, I just tested the code you had, and it
worked fine for me (but I'm using MX 2004). All you need to do, is have the
Alert component in your libarary, by dragging onto the stage, and then deleting
it off the stage.
Re: Basic Alert not working, please help! abeall
1/13/2005 10:44:03 PM
Here's a simple method: _global.alert = function(content,callback){
alertCount++;//multiple alerts
_root.attachMovie('alert','alert'+alertCount,alertCount);
_root['alert'+alertCount].txt = content;//apply content
_root['alert'+alertCount].ok = callback;//optional callback function to
execute when user hits OK } Now make an MC that looks like an alert
box(simpler the better), give it a dynamic and for its 'variable' field put
'txt', and out an OK button, on which you put: on(release){ ok() ;
this.removeMovieClip() }; then delete the MC from the stage(so its only in the
library), select it in you library(F11), right-click, linkage, select export
for actionscrip, give it a indentifier name of 'alert', and your set To make
it more of a confirmation, just add another button which doesnt have 'ok()'
onRelease sample usage: function alertFunc(){ getURL('url'); } alert('You are
not leaveing our site',alertFunc ) HTH
AddThis Social Bookmark Button