Posts Tagged ‘dev’

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…)

Creating and Managing Apache Aliases

Tuesday, February 17th, 2009

Recently i started to code a lot more php/html/css. So i finally installed xampp/mamp on my local machine and created Aliases that directly point to the current project folder which makes it a lot easier to test.

To create an Alias just add following code into the httpd.conf file:

Alias /myAlias /Users/username/folder/deploy
<Directory "/Users/username/folder/deploy">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

After restarting your apache server the alias should work right away. In our example it would be http://localhost/myAlias.

Instead of just adding those lines to the httpd.conf file you can also easily manage your aliases in external files. Save the above code in a new textfile (e.g. myAlias.conf) and include your alias-folder-path in the httpd.conf file by adding following code to it.

<IfModule mod_alias.c>
	Include /Applications/MAMP/conf/apache/alias
</IfModule>

Make sure that your folder path is set right. From now on you can just add aliases to that folder. nice and handy.

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!");