Posts Tagged ‘flash’
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 = "name@server.com"; if (email.indexOf("@")!=-1 && email.indexOf(".")!=-1) trace("false"); else trace ("true");
Random Number In ASP for no Flash Caching
This is an example of how to create a random number in Classic ASP in order to append to a swf file so that the browser does not cache the swf file. <% Dim SwfRndNum Randomize SwfRndNum = Rnd %> You can then add it to your swf embed code as follow, bear in mind that I am only showing the snippet around the swf file name and not the…
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…
Set line leading / line spacing in flash actionscript 2
This is how to add text leading using Actionscript 2 for Flash. var txtFormat:TextFormat = new TextFormat(); txtFormat.leading = 5; // change this to whatever you need it to be ttt.setTextFormat(txtFormat); ttt2.setTextFormat(txtFormat);</span> There is also a GUI way of doing this: Select your textfield and and under the paragraph section, set the top/right hand icon (Line Spacing) to whatever you like.
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();</span> The above code gets the current date…
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 =…
Animator vs Animation
An animation done showing the battle between animator and the animation in a Flash environment. Thanks to Alan Becker for this one.
Enable / Disable Cursor Hand in Actioncsript 2
If you have a movieclip that by default has the hand cursor showing on RollOver and you don’t really want this, you can disable it by doing the following: myMC.onRollOver = function() { this.useHandCursor=false; } So the main code here is: this.useHandCursor=false; False disables it and true shows it.
Calling event functions from movieclips in actionscript 2
In a flash movie I usually have a frame of actionscript that controls all elements in the file to keep everything in one place. Sometimes I have an onPress(etc) function that refers to something happening in the scene when something is pressed, but what happens if we want another element to refer to that event for some reason? Here’s an example of that code without anything “flashy”: _root.myMC.onPress = function()…
Security error: securitySandboxError with Flash
You have a flash uploader and you get this error: security error: securitySandboxError This means that the flash is not trusted by the domain and you have to place an xml file in the root of the domain. The file is called “crossdomain.xml” and this is what should be inside it: <?xml version=”1.0″?> <cross-domain-policy> <allow-access-from domain=”*” /> </cross-domain-policy> Solved!
Component Inspector in Flash has ISSUES!
I discovered a very annoying bug in the Flash IDE a little while ago, and it has happened to me quite a few times. Today it happened again and so I write this post.. While in the Flash IDE you select a component on the stage, then you click “Component Inspector”. This opens up into a modal window which is nice and everything BUT…. …..if you then give focus to…