Over the past 2 or so months I've been using Flex for all my AS projects. Usually when I need to figure something out, I'll create a new FLA document and throw all my code into the timeline until it's been worked out, then bring it back into the class files. However, I've found this to be a big pain in the butt when creating AIR applications. For some reason it only lets me test AIR applications a few times before the adl file freezes and I need to force quit to get out. Well, seeing that I had never messed around with creating a Flex Project, I decided to give it a whirl and learn to put my code into MXML and go from there. In doing this, I discovered I no longer had the adl freeze issue!
Read the rest of this entry »
A "Find and Replace" method is always handy when trying to avoid repetition in code (especially when replacing variables in XML Strings) and so here's a quick script everyone should know:
public static function replaceWord (searchString:String, find:String, replace:String) : String
{
var wordLength = searchString.length;
var result:String = '';
for (var i = 0; i < wordLength; i++) {
if (searchString.substr (i, find.length) == find) {
result = searchString.substr (0, i) +
replace +
searchString.substr (i + find.length, wordLength);
}
}
if (result == '') result = searchString; // didn't replace anything
return result;
}
I've recently been working on a physics/trigonometry project at home using Processing and memo's amazing MSARemote. In short, I realized I haven't posted anything on Tomorrow Evening in ages, I have a lot of cool things up my sleeve right now, just trying to find time to get all these ideas out. I'll be taking all of Thanksgiving week off to take a break from work and do some fun experiments. If I weren't a web developer I'd turn my internet off for a few weeks, I keep finding such great developers/art online that I start something new every other day and never finish what I was working on the day before! That needs to end soon :P. I know I said I was doing a Processing experiment and this code is in AS3 but I have a good reason why! My wordpress doesn't know how to format processing code and since it's only a few lines, I converted it to AS3.
function findDistance(x1:Number, y1:Number, x2:Number, y2:Number) : Number{
var xd:Number = x1 - x2;
var yd:Number = y1 - y2;
var td:Number = Math.sqrt(xd * xd + yd * yd);
return td;
}
function findAngle(x1:Number, y1:Number, x2:Number, y2:Number) : Number{
var xd:Number = x1 - x2;
var yd:Number = y1 - y2;
var t:Number = Math.atan2(yd,xd);
var a:Number = 180 + (-(180 * t) / Math.PI);
return a;
}
If you haven't noticed where the web is going, everything is all about the now. With Twitter, Facebook, MySpace (anyone still use myspace anymore?), blogging, and others, the web is directing itself more towards small statements to announce what you're doing now. A thing that's nice to display on your website (or you may even need for a client) is to display the weather.
Read the rest of this entry »
Back in the Flash 5 days, before tweening engines and Robert Penner's easing functions, flash developers used a "dirty" way of tweening through code.
Read the rest of this entry »