I currently have an over, out and click event for 8 different objects. The over and out events are identical for each (tween expands object and then shrinks it back for the out state).
I have previously asked for an easy way to declare those events, and now I was looking for an easier way to handle them.
Here's my code:
//-----------GARAGE
function growGarage(e:MouseEvent):void{
scaleTweenX = new Tween(map_garage, "scaleX", Elastic.easeOut, 0.648, 1, 0.5, true);
scaleTweenY = new Tween(map_garage, "scaleY", Elastic.easeOut, 0.648, 1, 0.5, true);
}
function shrinkGarage(e:MouseEvent):void{
scaleTweenX = new Tween(map_garage, "scaleX", Elastic.easeOut, 1, 0.648, 0.5, true);
scaleTweenY = new Tween(map_garage, "scaleY", Elastic.easeOut, 1, 0.648, 0.5, true);
}
function garageClick(e:MouseEvent):void{
trace("clicked");
}
//-----------B&B
function growBandb(e:MouseEvent):void{
scaleTweenX = new Tween(map_bandb, "scaleX", Elastic.easeOut, 0.648, 1, 0.5, true);
scaleTweenY = new Tween(map_bandb, "scaleY", Elastic.easeOut, 0.648, 1, 0.5, true);
}
function shrinkBandb(e:MouseEvent):void{
scaleTweenX = new Tween(map_bandb, "scaleX", Elastic.easeOut, 1, 0.648, 0.5, true);
scaleTweenY = new Tween(map_bandb, "scaleY", Elastic.easeOut, 1, 0.648, 0.5, true);
}
function bandbClick(e:MouseEvent):void{
trace("clicked");
}
//-----------FACTORY
function growFactory(e:MouseEvent):void{
scaleTweenX = new Tween(map_factory, "scaleX", Elastic.easeOut, 0.648, 1, 0.5, true);
scaleTweenY = new Tween(map_factory, "scaleY", Elastic.easeOut, 0.648, 1, 0.5, true);
}
function shrinkFactory(e:MouseEvent):void{
scaleTweenX = new Tween(map_factory, "scaleX", Elastic.easeOut, 1, 0.648, 0.5, true);
scaleTweenY = new Tween(map_factory, "scaleY", Elastic.easeOut, 1, 0.648, 0.5, true);
}
function factoryClick(e:MouseEvent):void{
trace("clicked");
}
//-----------SCHOOL
function growSchool(e:MouseEvent):void{
scaleTweenX = new Tween(map_school, "scaleX", Elastic.easeOut, 0.648, 1, 0.5, true);
scaleTweenY = new Tween(map_school, "scaleY", Elastic.easeOut, 0.648, 1, 0.5, true);
}
function shrinkSchool(e:MouseEvent):void{
scaleTweenX = new Tween(map_school, "scaleX", Elastic.easeOut, 1, 0.648, 0.5, true);
scaleTweenY = new Tween(map_school, "scaleY", Elastic.easeOut, 1, 0.648, 0.5, true);
}
function schoolClick(e:MouseEvent):void{
trace("clicked");
}
I've tried using a single function and then using "this" as the object of the tween but that expanded the entire stage.
Is there a way to condense this code?
Cheers,
Dan