FORUMS: list search recent posts

Age verification

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jessica Chapman
Age verification
on May 3, 2011 at 12:56:00 pm

I am complete n00b at flash. :(

I am using a actionscript 3 class for an age verfication that I followed from here:

http://active.tutsplus.com/tutorials/actionscript/develop-an-age-verificati...

I have turned the age verification into a movieclip and have linked the age verification class to it.


On my main timeline:
Frame 1 has a pre-loader.
Frame 2 is the age verifcation movieclip.
Frame 3 is the main movie clip with all the content inside.


What I have been trying to do, is find a way so that once the 'enter' button of the age verifcation movieclip is clicked, it will proceed to frame 3 on the main timeline, which will play that movieclip.

Any help would be so very much appreciated! :'(


Return to posts index

sri kanth
Re: Age verification
on May 3, 2011 at 1:08:32 pm

just call the nextFrame() or play(), but if you can post your code, it will be easy to analyse and guide you the best


Return to posts index

Jessica Chapman
Re: Age verification
on May 3, 2011 at 1:20:54 pm

Here is the code I'm using for the validator:

package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import fl.transitions.Tween;
import fl.transitions.easing.Strong;
import fl.transitions.easing.Back;
import flash.net.URLRequest;

public class Main extends Sprite
{
private var tween:Tween;

private var minimumAge:int = 18;
private var tooOldAge:int = 130;
private var months:Array = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
private var currentDate:Date = new Date();
private var userBirth:Date;
private var userAge:Number;

public function Main():void
{
tween = new Tween(panel,"y",Strong.easeOut, - panel.height,stage.stageHeight / 2,0.5,true);
panel.enterButton.addEventListener(MouseEvent.MOUSE_UP, verifyAge);


}

private function monthToNumber(month:String):int
{
var monthNumber:int;

for (var i:int = 0; i < months.length; i++)
{
if (panel.monthField.text == months[i])
{
monthNumber = i;
}
}

return monthNumber;
}

private function verifyAge(e:MouseEvent):void
{
userBirth = new Date(int(panel.yearField.text),monthToNumber(panel.monthField.text),int(panel.dayField.text));

userAge = Math.floor((Number(currentDate) - Number(userBirth)) / (1000*60*60*24) / 365);

if (userAge > tooOldAge)
{
panel.messages.textColor = 0xAA0000;
panel.messages.text = "You can't be " + userAge + " years";
}
else if (userAge >= minimumAge)
{
panel.messages.textColor = 0xF2DC57;
panel.messages.text = "WELCOME";
tween = new Tween(panel,"x",Back.easeIn,panel.x,stage.stageWidth + panel.width / 2 + 10,0.3,true);
loadContent();
}
else if (userBirth.getFullYear() > currentDate.getFullYear())
{
panel.messages.textColor = 0xAA0000;
panel.messages.text = "Are you from the future?";
}
else
{
panel.messages.textColor = 0xAA0000;
panel.messages.text = "You must be " + minimumAge + " or over";
redirect();
}
}

private function loadContent():void
{

}

private function redirect():void
{
//navigateToURL(new URLRequest("http://www.tutsplus.com"));
}
}
}



On frame 1 of the timeline I just have a preloader script which works fine.

On frame 2 I have stop(); so that once the preloader has loaded it stops at the validator movieclip on frame 2.

On frame 3 I have stop(); with the main movieclip.

Hope that makes sense. I would really appreciate where to exactly place the coding, I'm pretty dumb at this sorry ><


Return to posts index


sri kanth
Re: Age verification
on May 3, 2011 at 4:46:11 pm

you should put the code - "nextFrame()" or "play()" in the second condition of the function "verifyAge()". Since it is calling "loadContent()" you can place the code inside loadContent();

To finalize or rather decrease the complexity explained above, just put play() inside loadContent()


Return to posts index

Jessica Chapman
Re: Age verification
on May 3, 2011 at 8:25:24 pm

Sorry for being a complete n00b but...

would I place "play()" here...

private function loadContent():void
{
play()
}

private function redirect():void
{


or place it at the first loadContent reference?


else if (userAge >= minimumAge)
{
panel.messages.textColor = 0xF2DC57;
panel.messages.text = "WELCOME";
tween = new Tween(panel,"x",Back.easeIn,panel.x,stage.stageWidth + panel.width / 2 + 10,0.3,true);
loadContent(play());



I'm guessing I'm completely wrong as neither of these work... :S


Return to posts index

sri kanth
Re: Age verification
on May 4, 2011 at 5:17:19 am

I have uploaded the source files (needs flash cs5, however it will work if you replace the main.as though). Password for the uploaded files is "srikanth".

2302_ageverification.zip


Return to posts index


Jessica Chapman
Re: Age verification
on May 4, 2011 at 8:48:37 am

Wow thank you very much! :D Just wondering, if I wanted to add some more frames to the timeline, how would I adjust it so that it doesn't stop at just the next frame, but plays through?

I'm guessing I would have to change (parent as MovieClip).nextFrame(); to something else?


Return to posts index

sri kanth
Re: Age verification
on May 4, 2011 at 9:29:04 am

yes! just change it to
(parent as MovieClip).play();
if specific frame then use - (parent as MovieClip).gotoAndPlay();
any queries mail me srikanth[dot]mx[at]gmail[dot]com or post at my "forum.websibblings.com"


Return to posts index

Jessica Chapman
Re: Age verification
on May 4, 2011 at 11:15:51 am

Awesome!! Thank you sooo much for helping me out!!! ^____^


Return to posts index


sri kanth
Re: Age verification
on May 4, 2011 at 11:41:34 am

welcome

srikanth
--------

http://www.websibblings.com


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]