ActionScript 3 Class, Age Validator can be called before any type of interaction that you feel needs age verification.

The preview currently checks for 18 y/o, this can be change to any age.

The Age validator works for all years including leap years

What can I use it on:

  • Grant Access to a site
  • Access to a certain section of your portfolio
  • Before playing a video rated “R”
  • Grant Access to a video game trailer rated “M”
  • etc.

Fields can be customized and re-design to match your style easy from the Flash IDE .

Code:

//Age Validator
    public function validateAge(age:Number):void
    {
        //Create a new instance of AgeValidator
        newAgeVal = new AgeValidator(age);

        //AddListeners for a valid return
        newAgeVal.addEventListener(AgeValidator.ON_VALIDATE, on_validate_handler);

        //Center Validator on screen
        newAgeVal.x = stage.stageWidth / 2;
        newAgeVal.y = (stage.stageHeight / 2);

        //Add validator to stage
        addChild(newAgeVal);
    }

    //Age Validator Handler
    private function on_validate_handler(e:Event):void
    {
        //If age is valid grant access else access denied
        if (e.target.getValidated)
        {
            trace("Validated. Grant Access");
            grant_access();

        }else {
            trace("You can not watch this video.");
            access_denied.visible = true;
            removeChild(newAgeVal);
        }

    }

by
by
by
by
by
by