Friday, October 21, 2011
ActionScript Hero
Wednesday, October 12, 2011
Code Story: Three Blind Mice
For today's geeky story time I present the tale of THREE BLIND MICE (as told in AS3). But first, here's the original tale (tail!) as a recap:
And now dramatically interpreted in code:
Here's what it looks like in Flash (if that's easier for you to read):
And here it is with some explanations:
Three blind mice, three blind mice
see how they run, see how they run
they all ran after the farmer's wife
who cut off their tails with a carving knife.
Did you ever see such a thing in your life
as three blind mice?
And now dramatically interpreted in code:
import com.characters.FieldMouse;
import com.characters.FarmersWife;
var mice:Array = new Array();
var farmersWife_mc:FarmersWife = new FarmersWife();
addChild(farmersWife_mc);
FarmersWife.run = function():void
{
//trace("running");
}
FieldMouse.run = function()
{
trace("running");
}
for(var i:int=0; i < 3; i++)
{
var theMouse:FieldMouse = new FieldMouse();
var tail:MovieClip = new MovieClip();
theMouse.addChild(tail);
theMouse.vision = false;
mice.push(theMouse);
}
function cut(event:MouseEvent)
{
while(var j:int=0 < mice.length)
{
carvingKnife(mice[j]);
j++;
}
farmersWife_mc.removeEventListener(MouseEvent.MOUSE_OVER);
}
function carvingKnife(mouse:MovieClip)
{
mouse.removeChild(tail_mc);
}
farmersWife_mc.addEventListener(MouseEvent.MOUSE_OVER, cut);
farmersWife_mc.run();
while(var k:int=0 < mice.length)
{
Mice[j].run();
k++;
}
import com.characters.FarmersWife;
var mice:Array = new Array();
var farmersWife_mc:FarmersWife = new FarmersWife();
addChild(farmersWife_mc);
FarmersWife.run = function():void
{
//trace("running");
}
FieldMouse.run = function()
{
trace("running");
}
for(var i:int=0; i < 3; i++)
{
var theMouse:FieldMouse = new FieldMouse();
var tail:MovieClip = new MovieClip();
theMouse.addChild(tail);
theMouse.vision = false;
mice.push(theMouse);
}
function cut(event:MouseEvent)
{
while(var j:int=0 < mice.length)
{
carvingKnife(mice[j]);
j++;
}
farmersWife_mc.removeEventListener(MouseEvent.MOUSE_OVER);
}
function carvingKnife(mouse:MovieClip)
{
mouse.removeChild(tail_mc);
}
farmersWife_mc.addEventListener(MouseEvent.MOUSE_OVER, cut);
farmersWife_mc.run();
while(var k:int=0 < mice.length)
{
Mice[j].run();
k++;
}
Here's what it looks like in Flash (if that's easier for you to read):
And here it is with some explanations:
Labels: actionscript3, code story, flash, three blind mice