Flash CS3

Free tutorials and scripts for all

Sometimes members don't get their activation email.
This happens because it gets deleted by accident, your spam folder gets it ... lots of reasons.
To Resend the account activation code you need to do two things:
1. Go here: Resend your activation email
2. Enter the email address you used when you signed up and click "Email activation codes"
3. When the email arrives in your inbox, be sure to click the link to activate your account.

Captcha for Flash CS3

This is a discussion on Captcha for Flash CS3 within the FlepStudio utilities forums, part of the Tutorials category; FlepStudio has created a simple captcha for Flash CS3 with Actionscript 3.0 . What a CAPTCHA is ? A CAPTCHA is ...


Go Back   Forum Flash CS3 > English Forums > Tutorials > FlepStudio utilities

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  5 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 21-05-08, 04:15
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,321
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
Captcha for Flash CS3

FlepStudio has created a simple captcha for Flash CS3 with Actionscript 3.0.


What a CAPTCHA is ?

A CAPTCHA is a type of challenge-response test used in computing to determine that the response is not generated by a computer. The process involves one computer (a server) asking a user to complete a simple test which the computer is able to generate and grade.

Because other computers are unable to solve the CAPTCHA, any user entering a correct solution is presumed to be human. A common type of CAPTCHA requires that the user type the letters of a distorted image, sometimes with the addition of an obscured sequence of letters or digits that appears on the screen.


FlepStudio has created a Flash captcha that can be used in your guestbook or shoutbox.

It can be used in any application that requires the Flash insertion of comments or messages from users.


It 'a simple class Actionscript 3.0 easily manageable through its checkCaptcha method.


Flash CS3 CAPTCHA






Actionscript 3.0 Captcha.as class


Code:
package org.FlepStudio
{
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.text.*;
	
	public class Captcha extends MovieClip
	{
		private var clip_mc:MovieClip;
		
		private var captcha_array:Array;
		
		private const CAPTCHA_LENGTH:int=8;
		
		private var captcha:String="";
		
		public function Captcha()
		{
			addEventListener(Event.ADDED_TO_STAGE,init);
		}
		
		private function init(evt:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,init);
			
			captcha_array=new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j",
							    					"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9");
			
			createClip();
			createBackground();
			createCaptcha();
			createText();
		}
		
		private function createClip():void
		{
			clip_mc=new MovieClip();
			addChild(clip_mc);
		}
		
		private function createBackground():void
		{
			var fillType:String=GradientType.LINEAR;
			var colors:Array=[Math.random()*0xFFFFFF,Math.random()*0xFFFFFF];
			var alphas:Array=[1,1];
			var ratios:Array=[0x00,0xFF];
			var matr:Matrix=new Matrix();
			matr.createGradientBox(20,20,0,0,0);
			var spreadMethod:String=SpreadMethod.REFLECT;
			clip_mc.graphics.beginGradientFill(fillType,colors,alphas,ratios,matr,spreadMethod);  
			clip_mc.graphics.drawRect(0,0,140,40);
		}
		
		private function createCaptcha():void
		{
			for(var i:int=0;i < CAPTCHA_LENGTH;i++)
			{
				var randomNumber:int=Math.floor(Math.random()*captcha_array.length);
				captcha+=captcha_array[randomNumber];
			}
		}
		
		private function createText():void
		{
			var field_txt:TextField=new TextField();
			field_txt.multiline=false;
			field_txt.selectable=false;
			field_txt.embedFonts=true;
			field_txt.defaultTextFormat=getFormat();
			field_txt.text=captcha;
			field_txt.width=field_txt.textWidth+5;
			field_txt.height=field_txt.textHeight;
			field_txt.x=(clip_mc.width-field_txt.textWidth)/2;
			field_txt.y=(clip_mc.height-field_txt.textHeight)/2;
			clip_mc.addChild(field_txt);
		}
		
		private function getFormat():TextFormat
		{
			var format:TextFormat=new TextFormat();
			format.font="Flubber";
			format.size=24;
			format.color=0xFFFFFF;
			
			return format;
		}
		
		public function checkCaptcha(str:String):Boolean
		{
			if(str===captcha)
				return true;
			else
				return false;
		}
	}
}

How to use Catcha.as class


Code:
import org.FlepStudio.Captcha;

var test:Captcha=new Captcha();
test.x=260;
test.y=160;
addChild(test);

send_btn.addEventListener(MouseEvent.MOUSE_DOWN,setDown);

function setDown(evt:MouseEvent):void
{
	var answer:Boolean=test.checkCaptcha(test_txt.text);
	trace(answer);
}

Methods


checkCaptcha(String):Boolean


Once instantiated the class and attached to the stage ( or into another MovieClip ), just call this method passing the string of user who is inserting in the text field.
You will receive a Boolean return value (true or false) and based on that value decide the actions to do for your application.

Attached Files
File Type: zip Captcha.zip (66.7 KB, 309 views)

__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 21-05-08, 07:29
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,321
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
Re: Captcha for Flash CS3

PS:

is someone thinks it's too hard to catch the letters, just change the font
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 21-05-08, 09:31
Junior Member
 
Join Date: Mar 2008
Posts: 3
Rep Power: 0
flashkiddy is on a distinguished road
Re: Captcha for Flash CS3

nice and clean code dude. But isnt the whole idea about this technology that you keep the code on the server instead of on the client side? Now someone can still write an exploitation script to misuse the fact that the captcha-code is accessible directly from the browser.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 21-05-08, 10:43
Junior Member
 
Join Date: Feb 2008
Posts: 5
Rep Power: 0
Oldarney is on a distinguished road
Re: Captcha for Flash CS3

makes since. captcha's are for security and this isnt very. a small modification to the original web page that this is implanted (greasemonkey or firebug) and this would be useless.

now if, it loaded the image from a server then sent back the user input...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 21-05-08, 10:48
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,321
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
Re: Captcha for Flash CS3

Hi,
do not confuse a server Captcha with a Flash Captcha.
You are inside of a SWF, bots can't get into a SWF.
This captcha is usefull if you have for example a guestbook and you do not want permit the user to write comments fast with no reason.
Or you can use it with a flash email form.

Flash does not need a real server captcha because bots can't work inside SWF.
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 21-05-08, 10:54
Junior Member
 
Join Date: Feb 2008
Posts: 5
Rep Power: 0
Oldarney is on a distinguished road
Re: Captcha for Flash CS3

nope, but cheat engine can. its a nice alternative for the mention reasons though. that is if you don't need the utmost security.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 21-05-08, 10:57
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,321
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
Re: Captcha for Flash CS3

Quote:
Originally Posted by Oldarney View Post
that is if you don't need the utmost security.
yep
agree
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 21-05-08, 13:25
Junior Member
 
Join Date: Jan 2008
Posts: 1
Rep Power: 0
edanlee is on a distinguished road
Re: Captcha for Flash CS3

is it case sensitive?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 21-05-08, 18:25
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,321
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
Re: Captcha for Flash CS3

Yes it is
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 29-07-08, 21:09
Junior Member
 
Join Date: Jan 2008
Posts: 1
Rep Power: 0
Petepool is on a distinguished road
Question Re: Captcha for Flash CS3

Quote:
Originally Posted by Flep View Post
PS:

is someone thinks it's too hard to catch the letters, just change the font
Hi,
I am trying to change the font and must be missing something. I did this change in the Captcha.as file:

private function getFormat():TextFormat
{
var format:TextFormat=new TextFormat();
format.font="Courier New";
//format.font="Flubber";
format.size=24;
format.color=0xFFFFFF;

return format;
}

But when I run the flash, I just get the background and the text in the captcha graphic is not visable.

Thanks for any help.

PS This site is fantastic! What a great find for a newbee!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Tags
antispam, captcha

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Captcha per Flash CS3 Flep Utilità di FlepStudio 8 29-05-08 05:33


All times are GMT. The time now is 18:30.


Powered by vBulletin versione 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap

FlepStudio
by Filippo Lughi
P.IVA 03605860406