How can I prevent children from shrinking to infinitesimal values on MouseEvents?
Hi.
I have the following code:
////////////////////////////////////////////////////////////////////////////////////
//http://forums.adobe.com/message/3450898#3450898
//square_mc.y property edited by kglad AND NedMurphy both
// but kglad introduced the yGap variable, allowing for
// user defined space between movie clips. This solved my
// problem of evenly distributed spacing between movie clips
// all of the other code I generated from either my own previous
// files or by thinking about the solution and plugging away
// at it.
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
var nextY:Number = 0;
var yGap:int = 2;
var container:MovieClip=new MovieClip();
var containerBig:MovieClip=new MovieClip();
containerBig.x=50;
containerBig.y=50;
containerBig.scaleX=1;
containerBig.scaleY=1;
addChild(container);
addChild(containerBig);
stage.addEventListener(Event.ENTER_FRAME, myFunc);
/*var imageHolder_mc:MovieClip=new MovieClip();
imageHolder_mc.graphics.beginFill(0x888888);
imageHolder_mc.graphics.lineTo(300,0);
imageHolder_mc.graphics.lineTo(300,200);
imageHolder_mc.graphics.lineTo(0,200);
imageHolder_mc.graphics.lineTo(0,0);
*/
var myFrames:Array=new Array();
for (var i:int=0; i<12; i++){
myFrames.push("my_"+i+"_mc");
trace(myFrames+" myFrames");
var square_mc:MovieClip=new MovieClip();
square_mc.graphics.beginFill(0xFF0000);
square_mc.graphics.lineTo(200,0);
square_mc.graphics.lineTo(200,200);
square_mc.graphics.lineTo(0,200);
square_mc.graphics.lineTo(0,0);
container.addChild(square_mc);
square_mc.name="my_"+i+"_mc";
trace(square_mc.name);
square_mc.addEventListener(MouseEvent.MOUSE_OVER, myFunc2);
square_mc.addEventListener(MouseEvent.MOUSE_OUT, myFunc3);
//square_mc.scaleX=.25+(.13*Math.sin(i/Math.PI))*mouseY*.005;
square_mc.scaleX=.25;
square_mc.scaleY=square_mc.scaleX;
square_mc.alpha=i*.1+.3;
square_mc.y=nextY+mouseY*(-1);
nextY+=square_mc.height+yGap;
}
function myFunc(e:Event):void{
container.y=-1*mouseY+stage.height;
trace(container.y+" containerY");
}
function myFunc2(e:MouseEvent):void{
e.target.scaleX*=1.2;
trace(stage.height+" stageHeight");
e.target.addEventListener(MouseEvent.MOUSE_DOWN, myFunc4);
e.target.mouseChildren=false;
}
function myFunc3(e:MouseEvent):void{
e.target.scaleX/=1.2;
e.target.removeEventListener(MouseEvent.MOUSE_OVER, myFunc2);
}
//add ImageHolder_mc MovieClip from Library and go to frame
// coinciding with Array value in for loop . . .
var imageHolder_mc:ImageHolder_mc=new ImageHolder_mc();
function myFunc4(e:MouseEvent):void{
containerBig.addChild(imageHolder_mc);
for(var j:int=0; j<12; j++){
if(e.target.name=="my_"+j+"_mc"){
imageHolder_mc.gotoAndStop(j);
}
}
trace(e.target.y+" e.target.y");
}
////////////////////////////////////////////////////////////////////////////////////
you can troubleshoot the issue by adding a 12 frame MovieClip to your Library when you test this code and give it the names I referenced above in Bold.
That is, whomever will have time to help me out.
The problem I'm facing is not with loading the content of the Movie Clip, (though I might experience issues with that later when I try to load dynamic swfs) because as for now I just have placeholders on frames.
What I want to know is why my red squares on the left navigation keep getting smaller as I repeat the MouseOver and MouseOut events. It doesn't seem that these squares follow the logic of the code the way I have written it. Some of the code was generated from a previous post with the help of contributors.
Now I have again hit a slight snag with coding the math properly. Initially when I tested the code it worked fine without any "shrinking" going on. However, now with more code added the red navigation squares don't bounce back to their original states, they just keep getting smaller.
Can anyone help me with this?
Kindly thanking in advance,
-markerline