?
Solved

How to show a confirm box from in Flash?

Posted on 2009-12-16
9
Medium Priority
?
529 Views
Last Modified: 2013-11-11
Hi, I have a Flash file created in Macromedia Flash MX. In the file there is an image and if you click on the image, you will be directed to another page. Please see the action script below. How do I modify the code so that the user will be give a confirmation dialog box like the confirm box from Javascript? For example, "Are you sure you want to proceed?". If the user presses the "Yes"  button, execute the "getURL" method, if the user presses the "No" button, do nothing.

Is this even possible in Flash?

Thanks.
on (press)
{
	getURL("bookings/booking_confirmation.jsp");
}

Open in new window

0
Comment
Question by:killdurst
  • 3
  • 3
  • 3
9 Comments
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 26069316
Here's a sample fla for you:

http://vulturous.110mb.com/eefiles/ConfirmBox.zip

Here's the code within it:

<code>

Good luck!

-V
myButton.onRelease = function() {
	var confirmBox:MovieClip = this._parent.attachMovie("ConfirmBox","ConfirmBox",this._parent.getNextHighestDepth(),{_x:Stage.width/2-150,_y:Stage.height/2-50});
	confirmBox.btnConfirm.onRelease = function() {
		getURL("http://www.google.com","_blank");
	}
	confirmBox.btnCancel.onRelease = function() {
		removeMovieClip(this._parent);
	}
}

Open in new window

0
 
LVL 12

Expert Comment

by:sajayj2009
ID: 26069362
Working example
alert-component1.fla
0
 
LVL 1

Author Comment

by:killdurst
ID: 26069544
Will try these soon and update you guys!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:killdurst
ID: 26069631
Can't seem to open the files.

Vulturous, when I tried to open ConfirmBox.fla, I got an error. See screenshot1.jpg.

sajayj2009, when I tried to open alert-component1.fla I got an error too. See screenshot2.jpg.
screenshot1.jpg
screenshot2.jpg
0
 
LVL 12

Expert Comment

by:sajayj2009
ID: 26069637
Which version of flash r u using?
0
 
LVL 12

Assisted Solution

by:sajayj2009
sajayj2009 earned 668 total points
ID: 26069644
In your flash document, drag a alert component.

And add below code;

"newbtn" replace with your button name.
import mx.controls.Alert;
newbtn.onRelease = function() {
	Alert.show("Are you sure you want to proceed?","Confirmation", Alert.YES | Alert.NO , this, aClickListner);
}
	
var aClickListner:Function = function(btnClicked:Object) {
	switch (btnClicked.detail) {
		case Alert.YES:
			getURL("bookings/booking_confirmation.jsp");
			break;
		case Alert.NO:
			break;
	}
}

Open in new window

0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 26073642
He's using Flash MX, aka Flash 6.

Let me try to redo it with Flash 5... which I have somewhere around here.

-V
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 1332 total points
ID: 26074047
Here's the same code but for Flash MX (6).

http://vulturous.110mb.com/eefiles/ConfirmBox_Flash6.zip

Good luck!

-V
0
 
LVL 1

Author Comment

by:killdurst
ID: 26077340
Vulturous, your sample code works well... Let me try to implement it on my code and get back to you soon...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question