-
Map Help - Fullscreen + scroll movement
Hey guys,
Nice to be here - really amazing site :-) Theres tons of resources, im not sure why I haven't found this place previously!!!
So Im abit of noob, you'll have to bear with my stupidity... I've only tinkered with animation before and I'm trying to get stuck in with AS.
I'm trying to do a map, which toggles between full screen, and can be moved with a holding down the left mouse button.
Ive managed to get the image to move with the mouse, but its constant - not with the click of a button... and when I gg full screen the scroll goes wrong (right and bottom don't stop at image edge)
I've been trying for quite some time and am at a bit of a lose :-( any help would be much appreciated!
This is the full screen code:
//Don't scale the movie when the stage size changes
Stage.scaleMode="noScale";
//Align the stage to the top left
Stage.align = "TL";
//Function to toggle between fullscreen and normal size
//the toggle fullscreen button calls this function when pressed
function toggleFullScreen(){
//if normal size, go to fullscreen, else go to normal size
if(Stage["displayState"]=="normal"){
Stage["displayState"]="fullScreen";
}else{
Stage["displayState"]="normal";
}
}
//Create a listener for each time the Stage is resized
var resizeListener:Object = new Object();
//Called each time the stage is resized
resizeListener.onResize = function () {
//Move the button to the center of the screen
toggleFullScreenButton._x=Stage.width/2;
toggleFullScreenButton._y=Stage.height/2;
}
//Add the listener to Stage
Stage.addListener(resizeListener);
This works well on its own...
And this is the mouse movement code, clearly not for left mouse click :-(
onClipEvent (load) {
this.swidth = Stage.width;
this.sheight = Stage.height;
this.speed = 10;
this.acceleration = this.speed/this.swidth;
this.acceleration = this.speed/this.sheight;
}
onClipEvent (enterFrame) {
_root._position = -_root._xmouse*((this._width-this.swidth)/this.swidth);
this.distance = Math.abs(_root._position-_x);
this.theX = _x;
if (this.distance>1) {
if (_root._position>theX) {
_x = this.theX+(this.distance*this.acceleration);
} else {
_x = this.theX-(this.distance*this.acceleration);
}
}
}
onClipEvent (enterFrame) {
_root._position = -_root._ymouse*((this._height-this.sheight)/this.sheight);
this.distance = Math.abs(_root._position-_y);
this.theY = _y;
if (this.distance>1) {
if (_root._position>theY) {
_y = this.theY+(this.distance*this.acceleration);
} else {
_y = this.theY-(this.distance*this.acceleration);
}
}
}
-
OK, so after looking into the code alot more, I've realised just how dumb I am :-(
All I needed to drag the stage was:
on (press) {
this.startDrag();
}
on (release) {
stopDrag();
}
However - can someone tell me how to make it stop at the end of a movieclip? (rather than infinitely scrolling!)
-
Prid - Outing
can someone tell me how to make it stop at the end of a movieclip?
You can restrict the startDrag's drag area:
startDrag(this, false, LEFT, UP, RIGHT, DOWN);
this refers to the object to be dragged, and false to if it should center to cursor when being dragged. The rest of the 4 parameters are a Number value, together making a Rectangular area for the dragging
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
That makes perfect sense... lets see if I can get this right :-)
Thanks so much for the reply Nig13
-
Sorry to be a pain, but that still lets the movie clip become dragable outside the flash stage! And it only seems to work down and left, as well as it not being able to be dragged back to its start position!
My word flash hurts my head...
-
Prid - Outing
Could you elaborate a bit more ?
Don't 100% get your problem
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Hi, sorry I havent explained it right...
here is a link to the web page, swf and fla:
http://www.outofnowhereuk.co.uk/daniel/map2.html
http://www.outofnowhereuk.co.uk/daniel/map2.swf
http://www.outofnowhereuk.co.uk/daniel/map2.fla
Basically - there is a zoom function, left mouse scroll function and a full screen function, however when you get to the end of the map you can still move the map out of the flash pane view!
I really need to get the map to stop at the edge of the flash window!!!
Thanks again for looking at this - im start to pull my hair out!
-
-
Prid - Outing
Tried a lot of approaches, both complicated and simple ones, but the answer was so straight-forward when I finally achieved it, that I felt kinda dumb for not thinking of it earlier
Just swap your code with this on your map movieclip:
Actionscript Code:
on(press){ startDrag(this, false, 0, 0, Stage.width-this._width, Stage.height-this._height); }
on(release, releaseOutside){ stopDrag(); }
Hope this works
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Nig YOUR AN ABSOLUTE SUPERSTAR!!!! How can I buy you a pint? thats absolutely perfect... Its amazing when you try so many approaches and it actually turns out to be something simple!!! I'd ended up trying some stupidly long code, and a flash designer friend of mine couldnt even get it to work perfectly...
Please let me buy you a pint? I know your 16 - but I think you deserve one...
-
Prid - Outing
Good to hear that it works
I dunno what a pint is, but thanks for the offer, but no thanks
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Originally Posted by Nig 13
Tried a lot of approaches, both complicated and simple ones, but the answer was so straight-forward when I finally achieved it, that I felt kinda dumb for not thinking of it earlier
Just swap your code with this on your map movieclip:
Actionscript Code:
on(press){ startDrag(this, false, 0, 0, Stage.width-this._width, Stage.height-this._height); }
on(release, releaseOutside){ stopDrag(); }
Hope this works
I was interested in doing something similar to this, although I had a question about the code. What is the "0, 0" for? Is that the coordinates it starts off at?
Just wondering
-
Prid - Outing
as already mentioned in Post #3, the last 4 parameters specify the square bounds in where the registration point of the movieclip can be moved inside. The registration point (or the plus sign in the center of a movieclip) can only move as far to LEFT as the X coordinate, 0, and as far TOP as the Y coordinate 0, which in this case is at the Top-Left of the Main Stage, it cannot move any further than that.
Just for experimenting, make a small square, convert it to a movieclip (with the registration point set to Top-Left, or to manually do this, enter the movieclip, select everything open Properties Panel [CTRL+F3], and set X and Y coordinate to 0), give it an instance name of, mc, and type this code on your Frame in Main Stage:
Actionscript Code:
mc.onPress = function(){ startDrag(this, false, 0, 0, Stage.width, Stage.height); }
This means that the registration point can only move within the square, the last 4 parameters make up; LEFT, TOP, RIGHT, BOTTOM - 0, 0, Stage's width, Stage's height
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|