View Full Version : Zooming and panning
Chewie
09-07-2006, 09:53 AM
I have my parent movieclip (this)
Into this I load a lot of empty movieclips and store them in an array, called clipArray.
These empty movieclips may or may not have movieclips loaded into them depending on user interaction from the menu which is in the root clip (this)
On my menu I have a set of radio buttons which allow the user to choose a zoom value, ranging from 100 to 300 percent.
When a selection is made the following code is run, grid is just another movieclip which I need scaling but is not part of the clipArray. _global.zoomValue is the value returned from the radio button selection.
for (i=0; i<clipArray.length; i++) {
this.clipArray[i]._xscale = _global.zoomValue;
this.clipArray[i]._yscale = _global.zoomValue;
this.grid._xscale = _global.zoomValue;
this.grid._yscale = _global.zoomValue;
}
The zooming works great. So everything zooms in but my menu stays the same size which is what I want. But I then need to be able to pan around to see what is now zoomed of the edges of my root movie (this). Perhaps with scroll bars.
Any suggestions.
Thanks
MIXPOSURE
09-07-2006, 11:53 AM
Hey Chewie,
ScrollPane might be what you're looking for. Search for it here or check it out in help.
ScrollPane component
The ScrollPane component displays movie clips, JPEG files, and SWF files in a scrollable area. By using a scroll pane, you can limit the amount of screen area occupied by these media types. The scroll pane can display content that is loaded from a local disk or from the Internet. You can set this content while authoring and at runtime by using ActionScript.
GGGGGGGGLGGLGLLGLLGLLLL!
(feeble attempt at Wook-ese)
Chewie
09-07-2006, 02:35 PM
Thanks, having problems with the scrollpane.
I am creating a sort of simple cad package, and I want to use the scrollpane to pan once zoomed in. But there will be more than 1 swf loaded at a time. So I created a holder called vehicle, which will hold the vehicle components. The engine and hull are loading, but not inside the scrollpane.
_root.attachMovie("ScrollPane", "cspPanWindow", 1, {_x:0, _y:0, _width:Stage.width});
_root.createEmptyMovieClip("vehicle", 2);
cspPanWindow.contentPath = vehicle;
vehicle.createEmptyMovieClip("hull", 5);
vehicle.createEmptyMovieClip("engine", 20);
vehicle.hull.loadMovie("hull001.swf");
vehicle.engine.loadMovie("engineCatc9.swf");
Chewie
09-07-2006, 03:36 PM
Is it not possible to load an empty movieclip created dynamically into the scrollpane, because there is no linkage identifier, only an instance name.
Am I right in thinking you can only add an instance of a movieclip from the library to the scrollpane. This does not really help me because I want to add a movieclip, which can then have many other movieclips loaded into it. So that when the parent movieclip is scrolled, it will have the effect of panning across all the child movieclips within it.
Syllogism
09-07-2006, 03:40 PM
You could create a function like mover() or something, with a for statement generating the code for each instance of the target MC you create. Then put a onEnterframe=mover; in the root timeline.
Then you have a little bit of code that changes the _x and _y values of the MC(well probably not the MC but a MC in the MC) depending on how far away from the center the mouse is. that get triggered by a this.onMouseMove
The problem is that flash doesn't position mc's by default with the center in the center rather it puts the registration point on the top left and with dynamically created MC's this is obviously a problem.
Fortunately some clever chap has written a class to get around this nasty feature which allows you to dynamically reassign the registration point to the center of the movie clip.
you can get the class from here:
http://www.darronschall.com/weblog/archives/000054.cfm
this is an example of how you would use it to move the center of a movie called photo2 to the center(haha)
import com.darronschall.*;
DynamicRegistration.initialize(photo2);
var newH = photo2._height / 2;
var newW = photo2._width / 2;
photo2.setRegistration(newH, newW);
All of this is just a theory... but it sounds good in theory : )
Chewie
09-07-2006, 03:46 PM
I had thought of moving all the parts individually, in fact this is something I have already done for grouping of components, but it is much more processor intensive than moving a single parent movieclip, which contains all the childs you want to move.
Thing is also all my components are draggable. being a sort of cad application, so as well as being able to pan across the image, the components need to be able to be moved on the screen individually, so scroll bars would be ideal.
Chewie
09-08-2006, 09:16 AM
Help :confused:
I will try and simplify the question.
Can you create an empty movieclip dynamically and have it loaded into a scroll pane. Then load swf's into the empty movieclip in the scrollpane. ?
Chewie
09-08-2006, 11:35 AM
I have posted about this here
http://www.actionscript.org/forums/showthread.php3?t=116312
but guessed it may be better in the components forum.
Is it at all possible to load an emptymovieclip created dynamically into the scrollpane component.
As far as I can tell you can only load an instance from the library or an external swf or image.
This seems very limiting. Are there any other ways of achieving what I want if this cannot be done with the scrollpane.
sleekdigital
09-08-2006, 06:04 PM
That's true, but once it is loaded, you can dynamically attach whatever you want to that clip. So I usually just use a blank clip from the library to start with, then use the scrollpane.content property to attach dynamic content to that.
http://www.sleekdigital.com/News/11.aspx
http://www.sleekdigital.com/News/5.aspx
Chewie
09-08-2006, 06:17 PM
Thanks sleekdigital I had tried an empty movieclip in the library, then setting the scrollpanes content as this empty movieclip. And then loading my swf's into the empty movieclip in the scrollpane, but it would not work. Guess I got something wrong somewhere.
Just knowing it can be done is a help. I did not want to spend any more time tring if it was not possible.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.