| View previous topic :: View next topic |
| Author |
Message |
computergeek67 Administrator


Joined: 31 Jul 2007 Posts: 144
Tokens: 147 Location: US
|
Posted: Sun Oct 21, 2007 10:32 pm Post subject: Scripted Camera |
|
|
A scripted camera is just a camera created in Actionscript that follows the mouse wherever it goes. It can be confusing at first, so I put in comments to explain some of the code.
Paste this code on the timeline:
| Code: | createEmptyMovieClip("boxCam", 1000);
//creates a Movie Clip called "boxCam" with a depth of 1000
with (boxCam) {
onLoad = function () {
CamX = _x;
CamY = _y;
//the x and y values of the MC "boxCam"
};
onEnterFrame = function () {
//this tells Flash to constantly continue the actions
_x = _root._xmouse-10;
_y = _root._ymouse-10;
//the x and y values of the mouse
CamX = CamX+(_x-CamX)/50;
//CamX is being toldc to add itself to its x - causing it to stay in place
//50 is telling how fast or slow the camera sould go. The larger the number, the slower it goes.
_root._x = Stage.width/2-CamX;
//tells the main stage x to split in half, and take away from the CamX variable that was defined to "stay still", making it follow the _xmouse.
CamY = CamY+(_y-CamY)/50;
_root._y = Stage.height/2-CamY;
};
} |
Make sure that you draw something on the screen so that you can see the camera's movement. _________________
Come to me if you have any questions  |
|
| Back to top |
|
 |
revneil Newbie

Joined: 16 Jul 2008 Posts: 1
Tokens: 1
|
Posted: Wed Jul 16, 2008 11:00 pm Post subject: |
|
|
| Sorry to bring up old posts, but I tried this and I'm having one problem with it. The camera is following the mouse, but it doesn't know when to stop. So the image continues to move on and I see the background. How can I make it stop and add a border? |
|
| Back to top |
|
 |
|