Archive for the ‘actionscript’ Category

Flash Files, Domains and Security Errors (Oh My)

Tuesday, March 16th, 2010

To provide a better user experience, we often use content delivery solutions at Big Spaceship, like Limelight or Akamai, to host bigger files and reduce load time. (Although this cuts into the user’s time spent watching pretty loaders.)

During a recent project, we ran into a couple of security errors loading external module.swf files from a different domain than main.swf. The idea was to have a basic framework in main that controls IN and OUT animations of the modules and have all additional functionality in the module.swf itself. All loaded swf files extended Big Spaceships StandardInOut Class to be controllable from the main file, so we could easily cast the loaded modules.

(more…)

MathUtils.findPreferredRatio

Friday, August 14th, 2009

Ever had the problem to shrink a picture so that it fits into a Box that has a specific width and height?
Here is a really nice and very useful method that helps finding the needed ratio:

/**
 * The <code>findPreferredRatio</code> method is used to find the correct ratio to fit content in a container using a maximum area.
 *  
 * @param $width		Number
 * @param $height		Number
 * @param $maxWidth		Number
 * @param $maxHeight	Number
 * @return 
 * 
 */
public static function findPreferredRatio($width:Number, $height:Number, $maxWidth:Number, $maxHeight:Number):Number
{
	var dw:Number = $maxWidth/$width;
	var dh:Number = $maxHeight/$height;
	return dw < dh ? dw : dh;
}

Example:

var pic:Bitmap = new Bitmap(new BitmapData(1000, 1000, false, 0));
var ratio:Number = MathUtils.findPreferredRatio(pic.width, pic.height, 280, 180);
pic.width *= ratio;
pic.height *= ratio;
trace(pic.width+'x'+pic.height); //output: 180x180

Just another Flash IDE – Flex/Flash Builder workflow

Tuesday, July 7th, 2009

The usual flash sites that we build at Big Spaceship contain tons of huge graphics, animations, dynamic motion, videos, timeline transitions as well as tons of code, utilizing huge open source libraries like papervision 3d, tweening engines and so on.

We want everyone to be able to use their preferred design/dev environment to ensure a fast way to produce innovative high quality work. That includes using the Flash IDE and still being able to use Flex/Flash Builder as a developer. (more…)

Legal Age Verification with Actionscript

Saturday, February 14th, 2009

Found this useful “Legal Age Verification” – codesnippet on ricardocabello’s blog.

var legalAge : int = 18; // or 21
 
var userDOB : Date = new Date(year,month-1,day);
var today : Date = new Date();
 
var diff : Date = new Date();
diff.setTime( today.getTime() - userDOB.getTime() );
 
var userAge : int = diff.getFullYear() - 1970;
 
if (userAge >= legalAge)
	trace("lets get pissed!");	
else
	trace("go away!");