Flash mouse and mc position

Source: Internet
Author: User

VarLeftest = 50;
VarRightest = 350;
VarStartX =-50;
VarStartY =-3;
VarClick =False;
VarNowTime = 0;
////////////////////////////////
// Load related components //
_ Root. attachMovie("MouseHand", "Hand", 1000 );
Hand._ X = _ Root. _ xmouse;
Hand._ Y = _ Root. _ ymouse;
_ Root. attachMovie("MyPic", "Pic", 11 );
Pic._ X= StartX;
Pic._ Y= StartY;
Pic._ Xscale= Pic._ Yscale= 60;
_ Root. createEmptyMovieClip("Screen", 10 );
With(Screen ){
LineStyle (1, 0x000000, 0 );
BeginFill (0x000000,100 );
MoveTo (leftest, 0 );
LineTo (rightest, 0 );
LineTo (rightest, 200 );
Linto (leftest, 200 );
LineTo (leftest, 0 );
}
Pic.SetMask(Screen );
////////////////////////////////
// Mouse follow //
StartDrag("Hand", True, Leftest, 0, rightest, 200 );
Mouse. hide();
////////////////////////////////
// Image control //
VarOldX =_ Root. _ xmouse;
VarHSpeed = 3;// Image moving speed
VarZSpeed = 1;// Enlarge the image
Mouse. addListener(_ Root);// Define the listener
_ Root. onMouseDown = Function(){
Click =True;
Hand.GotoAndStop("Click");
VarOldWidth = pic._ Xscale;
VarOldHeight = pic._ Yscale;
VarMouseX =_ Root. _ xmouse;
VarMouseY =_ Root. _ ymouse;
VarPicX = pic._ X;
VarPicY = pic._ Y;
VarMoveX, moveY;
Pic.OnEnterFrame = Function(){
If (This. _ xscale<100 | this._ Yscale& Lt; 100 ){
// Enlarge the image
This. _ xscale+ = ZSpeed;
This. _ yscale+ = ZSpeed;
// When the image is zoomed in at the center of the mouse click, the coordinates of the image are moved.
MoveX = (mouseX-picX)/oldWidth *This. _ xscale+ PicX)-mouseX;
MoveY = (mouseY-picY)/oldHeight *This. _ yscale+ PicY)-mouseY;
This. _ x= PicX-moveX;
This. _ y= PicY-moveY;
} Else {
Delete this. onEnterFrame;
}
};
};
_ Root. onMouseUp = Function(){
PublicAS ();
Pic. onEnterFrame =Function(){
// Scale down an image to its initial state.
If(This._ Xscale> 60 | this._ Yscale> 60 ){
This._ Xscale+ = (60-this._ Xscale)/10;
This._ Yscale+ = (60-this._ Yscale)/10;
This. _ x + = (startX-this. _ x)/10;
This. _ y + = (startY-this. _ y)/10;
} Else {
Delete this. onEnterFrame;
}
};
};
////////////////////////////////
// Control the image //
_ Root. onEnterFrame = Function(){
// Mouse highlights //
VarElapse =GetTimer ()-NowTime;
If(Elapse-3000> = 0 &&! Click ){
Elapse = 0;
Click =True;
NowTime =GetTimer ();
Hand.GotoAndPlay (2);
}
// Shift left and right //
VarNowX =_ Root. _ xmouse;
If(OldX-nowX) <0 | nowX> = rightest) & (pic._ X+ Pic._ Width)> 350 ){
// Move the cursor right and the image left
Pic._ X-= HSpeed;
PublicAS ();
}
If(OldX-nowX)> 0 | nowX <= leftest) & pic._ X<50 ){
// Move the cursor left and the image right
Pic._ X+ = HSpeed;
PublicAS ();
}
OldX =_ Root. _ xmouse;
};
// Some common code
FunctionPublicAS (){
Hand.GotoAndStop(1 );
NowTime =GetTimer();
Click =False;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.