Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resusable Confirmation Dialog 1

Status
Not open for further replies.

digiduck

Programmer
Apr 4, 2003
95
US
I'm trying to create a resusable confirmation dialog like what other languages have that I can use in my flash projects. I'd like to be able to call just like you can in like VisualBasic or C#, Javascript, ect... Like
Code:
on (press) {
   if (confirm("Are you sure?") == true) {
      // Do something
   }
}
Something like that. I just have no idea how to make something like that since I'm still learning flash. But I really need it for my applications.

Thanks
 
You can directly access Javascript dialogs from Flash eg:

getURL("javascript:alert('Error!')");

Confirm works the same way returning 'true' or 'false'...

 
and I don't need to have any embedded HTML pages or anything for that to work right?
 
okay I tried the following with the alert example you gave and it pops the box up in a separate IE page. I need the box to show up over flash. No browser.
Code:
on (release) {
   getURL("javascript:alert('Error')");
}
 
It will if testing this in the application itself, but not through the html in which the Flash movie is embedded.

Am I missing something else?

You can allways have a look at this, but maybe the same thing...


Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Okay, one last problem. Here's the code...
Code:
function btnLoadList_OnClick (pushbutton) {
	if (getURL("javascript:confirm('Delete this entry?')") == true) {
		// Response is true
		getURL("javascript:alert('Deleted')");
	} else {
		// Response is false
		getURL("javascript:alert('Canceled')");
	}
}
Now when run all that it does is show the 'Canceled' alert. How can I get it to do what its supposed to?
 
My guess would be that your first if statement is never true? And what is it supposed to do?

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Its supposed to do as the code reads. Just show the confirm, then after the user answer if true show the first alert, or if false the second. I tried having it test for A. it being true, and for B. "ok", and C. "true" but with the same result each time.
 
You could arrange this a lot of ways. I'm not positive my way is the best way, but...

Have a movie clip that looks like the popup window you want, and keep it hidden. In the object's actions, give it a function you can call when you want to use it. You can pass as parameters the text you want to appear, and maybe the actions that should be taken upon hitting OK or CANCEL. (You can use eval() to perform any statement you pass in a string.) The popup method will then show the movieclip, and set the text and the actions to be taken.
 
A bit too hot to be thinking around here at home, and I've never really played around with this... But seems to me, that the javascript "confirm" function may hold the user's choice, but without passing back it's value to your Flash function, how can your Flash first if statement be ever true?
Maybe it is too hot around here!

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
okay. i've gotten it to show the confirm box and I think I figured out that this just won't work. by calling
Code:
getURL("javascript:confirm('Delete this?')");
After the user has answered it sends the browser to another page with the result, true or false.
 
Where's my favorite instructor and mentor when we need him? [bigcheeks]

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Okay, that was dumb - I posted this as a new thread but here it is again...

Here's a workaround, use Flash to call a custom javaScript function:

Javascript:

<script>
function doConfirm(message){
if(confirm(message)){
alert('OK!');
}
else {
alert('Cancelled!')
}
}
</script>

Flash:

btn.onRelease = function() {
getURL(&quot;javascript:doConfirm('Confirm this?')&quot;);
};

The javascript is currently only throwing up alerts in response to the user's choice but you could add some Javascript/Flash Methods in there directing the movie to a particular frame depending on the choice made etc...
 
ok. you mentioned it could be used to direct flash to a different frame but I need it to be able to call a function in flash. Can it do that?
 
You can set variable values, which you could pass to a function or you can use 'call' which is what used to be used for function er.. functionality before Flash 5 introduced the real thing. One of those should give you the solution I'm sure.

There's a list at:


BTW jut tried the methods for setting frames and it works great.
 
Wonder what I've been saying?

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Impressive! I'm flabbergasted!
A whole hard day on that? Yes, you must be waisted!
Get some rest!

Regards,

cubalibre2.gif

[bigcheeks] I'm Bill Watson's biggest fan!
[bigcheeks]
 
Don't you have to know more than someone in order to condescend to them?

This is getting tiresome Old please cut it out.
 
Hi Bill,

The files you posted do almost exactly what I want to do, however is there an easy way of making the dialog modal? I want to stop users from clicking on stuff in the background while the message is showing.

Ta,
Emma
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top