English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am working on a small project using Flash 8. I do not think that it would be suitable for people under the age of 13 or so. I am not very experienced at ActionScripting, but I am trying as hard as I can. Basically, I have the animation, but before it I created a scene that contains the age verification on it with 3 frames ( 1 - Inputs, 2 - Failed to pass, 3 - Passed ) But I do not know what to do next. Any help would be very appreciated. I have 3 input boxes ( Month, Day, Year) and a "Enter Button" that will contain most of the ActionScript. If anyone has done this before or knows any tutorials that have to do with this, please do help. Thank you.

2007-04-01 04:40:25 · 1 answers · asked by nikolka1992 3 in Computers & Internet Programming & Design

1 answers

Set up a new actions layer for Frame 1 (since you've broken these into frames). Basically you need a variable determining when 13 years before today was. Then an if statement that checks whether or not today is at least 13 years from then. If so, they are allowed access, if not it's because they are too young.

So first you need today's date assigned to a variable. Let's say the var name is currentDate. We use AS's date function so it should look something like...

currentDate = new Date();

Now you need the month, day and year in their own variables so we get...

currentDay = currentDate.getDate();
currentMonth = currentDate.getMonth();
currentYear = currentDate.getFullYear();

so now we have today's month (mm format), date (dd format) and full year (yyyy format) in their own separate variables... so now we check what the date was 13 years ago (basically currentYear - 13) which will be the minimum year they had to have been born in. The month and day can be the same as currently.

minYear = currentYear - 13;
minDay = currentDay;
minMonth = currentMonth;

Finally we need their input. For this, you will have to use the instance name for your combo boxes. Let's say you named them cbMonth, cbDay, and cbYear.

so...

inputMonth = cbMonth.selectedItem.data;
inputDay = cbDay.selectedItem.data;
inputYear = cbYear.selectedItem.data;

Then do the check for the input against the mininums...

if ((inputYear <= minYear) {
if (inputMonth <= minMonth) {
if(inputDay <= minDay)) {
// they are at least 13 so go to Frame 3
gotoAndPlay (3);
}
}
}
else {
// they are under 13, disallow access go to Frame 2
gotoAndStop(2);
}

this was kind of on the fly, hope it helped. You will probably have to do a couple of adjustments so that it flows with your application, but that should give you a good starting point.

2007-04-01 05:51:57 · answer #1 · answered by Jen 2 · 0 0

fedest.com, questions and answers