garage_horizon_btn.addEventListener(MouseEvent.CLICK,garage)
function garage(event:MouseEvent):void
{
images_mc.garage_horizon_mc.visible=true;
images_mc.garage_horizon_mc.stop();
images_mc.garage_moss_mc.visible=false;
images_mc.garage_ocean_mc.visible=false;
}
garage_moss_btn.addEventListener(MouseEvent.CLICK,garage1)
function garage1(event:MouseEvent):void
{
images_mc.garage_moss_mc.visible=true;
images_mc.garage_moss_mc.stop();
images_mc.garage_horizon_mc.visible=false;
images_mc.garage_ocean_mc.visible=false;
}
images_mc.main_mc.stop();
rot(images_mc.main_mc);
rot(images_mc.garage_horizon_mc);
rot(images_mc.garage_moss_mc);
function rot(rotater:MovieClip):void
{
var offsetFrame:int = rotater.currentFrame;
var offsetX:Number = 0;
var percent:Number = 0;
rotater.addEventListener(MouseEvent.MOUSE_DOWN,startDragging);
rotater.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
function startDragging(e:MouseEvent):void
{
rotater.addEventListener(MouseEvent.MOUSE_MOVE,drag);
offsetX = e.target.mouseX;
}
function stopDragging(e:MouseEvent):void
{
rotater.removeEventListener(MouseEvent.MOUSE_MOVE,drag);
offsetFrame = rotater.currentFrame;
}
function drag(e:MouseEvent):void
{
percent = (e.target.mouseX - offsetX)/rotater.width;
var frame:int = Math.round(percent*rotater.totalFrames) + offsetFrame +1;
while (frame>rotater.totalFrames)
{
frame -= rotater.totalFrames;
}
while (frame<=0)
{
frame += rotater.totalFrames;
}
rotater.gotoAndStop(frame);
}
}
use:
var mcA:Array = [garage_horizon_mc,garage_moss_mc,garage_ocean_mc,gutter_ocean_mc,gutter_horizon_mc,gutter_moss_mc,main_mc];
for(var i:int=0;i<mcA.length;i++){
mcA.addEventListener(MouseEvent.CLICK,garageF);
}
function garageF(e:MouseEvent):void{
for(var i:int=0;i<mcA.length;i++){
mcA.visible = false;
}
var mc:MovieClip = MovieClip(e.currentTarget);
mc.gotoAndStop(rotationframe);
mc.visible = true;
whateverF(mc);
}
function whateverF(rotater_gah:MovieClip):void{
rotater_gah.offsetFrame_gah = rotater_gah.currentFrame;
rotater_gah.offsetX_gah = 0;
rotater_gah.percent_gah = 0;
rotater_gah.addEventListener(MouseEvent.MOUSE_DOWN,startDragging_gah);
rotater_gah.addEventListener(MouseEvent.MOUSE_UP,stopDragging_gah);
}
function startDragging_gah(e:MouseEvent):void {
e.currentTarget.addEventListener(MouseEvent.MOUSE_MOVE,drag_gah);
e.currentTarget.offsetX_gah = e.target.mouseX;
}
function stopDragging_gah(e:MouseEvent):void {
e.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE,drag_gah);
e.currentTarget.offsetFrame_gah = rotater_gah.currentFrame;
}
function drag_gah(e:MouseEvent):void {
e.currentTarget.percent_gah = (e.target.mouseX - e.currentTarget.offsetX_gah)/e.currentTarget.width;
var frame_gah:int = Math.round(e.currentTarget.percent_gah*e.currentTarget.totalFrames) + e.currentTarget.offsetFrame_gah +1;
while (frame_gah>e.currentTarget.totalFrames) {
frame_gah -= e.currentTarget.totalFrames;
}
while (frame_gah<=0) {
frame_gah += e.currentTarget.totalFrames;
}
e.currentTarget.gotoAndStop(frame_gah);
}