Super Easy Email Validation AS2

I needed a quick and easy way to check for the basics of an email address. Does it contain “@” and “.” symbols. This is by no meals a foolproof method, so don’t use it for anything big, but if you want to just do a quick test then here you go: var email:String = "[email protected]"; if (email.indexOf("@")!=-1 && email.indexOf(".")!=-1) trace("false"); else trace ("true");

August 20, 2010 · 1 min · 64 words · Andrew

1180 Call to a possibly undefined method navigateToURL

1180 Call to a possibly undefined method navigateToURL If you get the above error when trying to run your flash actionscript 3 file, you are obviously trying to use the navigateToURL() function but have not imported the flash.net library code. The following code before everything will correct the problem. import flash.net.*; ..or a more of a direct unbloated method is as follows: import flash.net.navigateToURL;

June 18, 2010 · 1 min · 64 words · Andrew

How to use a Timer in Actionscript 3

It is really easy to create a Timer in Actionscript 3. Instantiate the Timer Class and pass a time in millions of 1000 to it to work in seconds. var myTimer:Timer = new Timer(1000); Setup an event listener to call a function. myTimer.addEventListener("timer", myTimerEventHandler); Start the Timer. myTimer.start(); Start the Timer. function myTimerEventHandler(event:TimerEvent):void { trace(myTimer.currentCount+" seconds have passed."); } So altogether we have this. var myTimer:Timer = new Timer(1000); myTimer.addEventListener("timer", myTimerEventHandler); myTimer....

June 10, 2010 · 1 min · 91 words · Andrew

Actionscript 2 – PHP Data Transfer

In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it. It is a simple way of transferring data between the server and client. Actionscript 2 Code: callRemoteFile = function(ourVariable:String) { var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = function(success:Boolean) { if (success) { if (result_lv.message=="success") trace("done! "+result_lv.returnValue); else trace(result_lv.message); } else { trace("Error connecting to server"); return false; } }; var send_lv:LoadVars = new LoadVars(); send_lv....

May 17, 2010 · 1 min · 95 words · Andrew

Actionscript2: Split string by line length with & without word-wrap

Split string into sentences by max line length. This uses a character array but doesn’t use word-wrapping. var personalMessage: String = "You got this far so we reckon that you could be curious enough to learn a little more, we?ll contact you shortly to answer any questions you may have."; _root.myArray = new Array(); _root.myArray = personalMessage.split(""); _root.mySentences = new Array(); var currentCharCount: Number = 0; var currentCharItem: Number = 0; var currentCharString: String = ""; var maxLength: Number = 65; for (var i = 0; i & lt; _root....

May 5, 2010 · 2 min · 412 words · Andrew

Error 1046: Type was not found or was not a compile-time constant: Event.

Error 1046: Type was not found or was not a compile-time constant: Event. You need to import the Event class! import flash.events.Event

March 29, 2010 · 1 min · 22 words · Andrew

Add a date to a date in Actionscript 2

I needed to work out a date range according to the date 3weeks away from the current date. After a bit of thinking, I found that it’s actually quite easy to achieve. var theDate:Date = new Date(); dateDay = theDate.getDate(); dateMonth = theDate.getMonth(); dateYear = theDate.getFullYear(); var theDate2:Date = new Date(dateYear,dateMonth,dateDay); theDate2.setDate(theDate2.getDate() + 21); dateDay2 = theDate2.getDate(); dateMonth2 = theDate2.getMonth(); dateYear2 = theDate2.getFullYear(); The above code gets the current date and adds 21days/3weeks to it....

March 26, 2010 · 1 min · 116 words · Andrew

Add a month to selectable date range – Date Chooser – Actionscript 2

I have been working on a project where I need to select a date range starting today and ending a month from now, so the user cannot select anything in the past or over a month from now. This is how I did it: There is an instance of DateChooser on the stage with Instance Name “calDate”. var todayDate:Date = new Date(); dateBeginDay = todayDate.getDate(); dateBeginMonth = todayDate.getMonth(); dateBeginYear = todayDate....

March 22, 2010 · 1 min · 108 words · Andrew

hitTest and Actionscript2

if (mc.hitTest(_root._xmouse, _root._ymouse, true))) { trace("hitTest Run"); }

March 19, 2010 · 1 min · 8 words · Andrew

Limited numeric input in flash actionscript 2 textfield

If you want to only show numeric characters in a textfield in flash actionscript you can use the following code: myTextField.restrict = "0-9";

March 16, 2010 · 1 min · 23 words · Andrew