PDA

View Full Version : need help with zoom tool ala Senocular (slidezoom)



lunatic
January 13th, 2004, 05:16 PM
Well my other thread got buried and it was getting full anyway so I hope no one (read: Moderators) don't get mad that i'm startig a new thread . . . :scream:


I've gotten pretty far with my file. I have successfully been able to load higher resolution tiles when a user either draws a box of an appropriate size (area 50-100% of total loads low quality tiles, 25-50% of total loads medium tiles, 0-25% loads high quality tiles). The tiles also load correctly when the slider on the zoom tool is pushed up and down.

Here is my problem:

1) I can't figure out how to call the SetScale function (defined on the slider MC) so that when the user draws a box on the main map it zooms into that scale (see the functions half way down the AS layer on the main timeline where the calcArea is calculated).

Not only should the map zoom in but the scale text updates and the slider jumps on the range bar - all to reflect what zoom level the map is at.

I used the calcArea function to create a variable called boxscale (see fla to see what I'm talking about). I tried setting _root.scale = to boxscale and this does update the little scale text box but it screws up the drawing function for some reason.

Can anyone help on this? :bu:
Thanks so much!!

The zipped file is too big to post so I have uploaded it to my server. It can be downloaded by clicking here (home.comcast.net/~mkatzmoye/main.zip)

lunatic
January 13th, 2004, 07:05 PM
I also forgot to mention that when you draw a box on the main map, and the red box appears in the inset - you can drag the box in the inset around. However, when you click on it the box jumps, like the mouse can't grab hold of it. This isn't apparent when the box is big but try drawing a teensy little box and then dragging it and you'll see what I mean.

Thanks again for any suggestions on these two problems!

:P

lunatic
January 14th, 2004, 10:40 AM
:ear:


:s:


:beer:

senocular
January 14th, 2004, 10:45 AM
what you said doesn't make much sense which is probably why no one has said anything :D. Ill look at the file and see if I can't tell whats going on.

lunatic
January 14th, 2004, 10:57 AM
:( Yeah, it's one of those things that is so far along in it's process I can't really figure out how to explain it without someone looking at it. I could list a whole lot of code that is on the different movie clips but I'm not sure if that would confuse even more.

It's also hard to describe something that you've been looking at for so long - you wonder "how could someone NOT understand what I'm saying?" but you are right - it all sounds like garbledy gook.

Thanks for any insight you can give Sen! :pleased:

senocular
January 14th, 2004, 11:36 AM
at the same time you're providing a fla with a whole lot of code in it. Thats not often easy to root through and understand any better. considering it has my name written all over it, looks like Im the best man for the job ;)

lunatic
January 14th, 2004, 11:59 AM
:love: you ARE the best man for the job considering the slide zoom that I am using (and not for the first time) is your creation. :thumb:

But I see so many threads that say "Senocular look at this!" or "Lost in Beta I need help!" or "Voetsjoeba come rescue/rewrite my file!" that I would hate to beg for your attention more than I already do . . .

:beam:

Thanks again Sen - are you still teaching or are you done? Where are you moving on to after umbc? I hope it is to a job that will pay you $$$$$$$$$ x 100000 to create flash sites so that you will continue to help us poor noobs for free lol!

senocular
January 14th, 2004, 12:07 PM
Im looking at the file now :) its not as bad as I thought. ;) (Ill get to it in a minute)

As for UMBC, Im done teaching there. I decided to stop after last semester. The job I have now (and where Ive been for the last year and a half in at least some degree) is suiting me just fine. Its a low profile small company which has a lot of leniency and provides a low-stress, fun environment. I'll stick here as long as I can despite whatever they decide to pay me :D

lunatic
January 14th, 2004, 12:27 PM
Sweet (hear the huge sound of relief escaping me). Glad you like your job. Hope your boss realizes what he/she has got sitting in the office (you).

Your new site looks great by the way! Gonna have to change my bookmark when I get home from work today! :thumb:

senocular
January 14th, 2004, 12:33 PM
so are you zooming and panning? Basically, what you're getting into is just some math where you need to determine the selection box's scale in respect to the current map zoom (is it 1/2 the size? 1/4th?) and tack that on to the curent scale. If you're panning too, you would need to figure the center-point of the scale box and set that to the center of the view. The thing is, with the slider, you have setScale basing the scale off of its own _y position. So, really, in order to scale with setScale, you'd need to adjust the _y of that slider... which may or maynot be a route to take. Instead you might want to just base it off a zoom variable and then set the _y based on that. So you'll probably need to rework the zooming method or at least tweak the current one to facilitate alternate means of applying zoom (via selection)

lunatic
January 14th, 2004, 01:02 PM
Whoa there Johnny! Whew! The only reason my file looks as good as it does is because I had so many people help me with the code! Although I understand it (96% of it anyway . . .) there is no way I could have written most of it.

So let me think out loud - yes I am panning and zooming - zooming two ways actually: 1) with the slider and 2) with the draw box feature (that's the goal anyway).

The inset map is 1/4 the size of the main map. But the drawing box scale is totally dependent on what the user draws (obviously) so how could I relate the scale to a zooming variable? :h: I have written a function to calculate the area of the box that is drawn. If I divide that by the total area of the map then I have a percentage of the total (that's the 'boxscale' variable in the main AS). So I know for any given box drawn what percentage of the whole map is in view (in the box - is that confusing enough? :P ). I just don't know how to pass that variable to the function that sets the scale of the map. I believe that function is on the slider since when you move the slider up and down it scales the map.

I'm not sure what you mean about adjusting the _y of the slider to reflect the zoom variable. :ne: Could I use the boxscale variable?

The panning already seems to work pretty good based on the code you wrote for the slidezoom. I think if i can get the zooming to work then the pannign will only require a little tweaking.

Thanks Sen for taking the time to look at my file!

senocular
January 14th, 2004, 01:26 PM
lol. Ill be honest, I got through the first paragraph ok but after that my mind went numb. I tell you what, I'll make an easier version for you to understand and use. Are you ok with Classes and custom objects in Flash?

lunatic
January 14th, 2004, 01:35 PM
I've taken C++ so I understand what classes are. I think if I read over something enough I eventually get it but I don't know how to write them myself. I'll try to find some tutes right now to read up on.

Are you saying that my whole project could be highly simplified by using classes? :thumb: simplify = good

Not sure about custom objects - is that like a prototype? Or OOP? I'm okay with those though again, I shy away from using them because I don't know how to write them.

You are the best Sen! :P

jimhere
January 14th, 2004, 06:17 PM
senocular: "Are you ok with Classes and custom objects in Flash?"

Does Kirupa have a glossary of flash terms somewhere, sort of like Flash's Actionscript Dictionary, but easy for the likes of me to understand? Sometimes those definitions are a bit esoteric for a Photoshop guy like me (who ISgetting better at AS)...

Actionscript.org's tutorial on simple Variables was readable, but it'd be nice if there was an organized list of the AS Dictionary with readable examples of all the Flash bits and peices. I guess I'm sort of making one by copy/pasting sentences from around here. We'll see.

Anyway, the zoom/pan thing is great and I admire lunatic for getting this far. Those Macromedia guys created a lot of possibilities, but still, what's a Class?

senocular
January 14th, 2004, 06:26 PM
not many people are in the habit of re-writing the entire AS dictionary on their own - Kirupa is no exception. Most people do ok with Macromedia's version. AS.com, however, started such a task. Its an on-going documentation of Flash AS terms/actions/properties whathaveyou, but it's in their words and there are places for user comments - some which go up and above the call of duty in their descriptions. You can find that here:

http://www.actionscript.com/reference/

lunatic
January 14th, 2004, 06:42 PM
Thanks jimhere! Really most of my code is bits and pieces collected from other flas or from reading tons and tons of posts here on Kirupa. Not to mention begging for help in 500 some odd posts of my own!

I am slowly making my way right now through Sen's Object Oriented Programming (OOP) tutorial for AS1 (there is also one for AS2 if you have MX2004). It covers classes too.

A lot of it is over my head but if I read something through several times I eventually get it. He uses a lot of very clear examples too so I highly suggest reading it!

:bu:

jimhere
January 14th, 2004, 07:04 PM
Thanks for the as.org tip.
Where's Stumptown USA?

lunatic
January 14th, 2004, 07:09 PM
Portland, Oregon - that was literally it's nickname in the early 1900s due to the massive forest clearcutting that was going on back that (and continues today). Now there is a great local coffee roaster with that name. Yum yum.

By the way - did I mention that the OOP tutorial by Sen is on Kirupa?

jimhere
January 14th, 2004, 07:54 PM
Yeah, I've seen it. I copied it to gaze at every once in a while. Objects...
It's actually fairly understandable (he even made the detailed illustrations). I'll get it eventually. Until then I'll do things like take yor Slide and Zoom apart lke an archeologist, and put it back together like a mechanic and understanding will creep in. Thank god for Kirupa-like place where we can all work these thingies out.

...I've seen nav-palette type .swfs before, but none with the scale slider combined with the draggable area in the thumbnail (as opposed to the image itself dragging).

lunatic
January 14th, 2004, 10:35 PM
On Senocular's site is the original fla you can download and dissect - much easier than digging through my file which doesn't even work at this point. The file on Sen's site I think is the first listed. If you click my own "website" button you'll see the slide zoom in action and working - just with less functionality than what I want to achieve currently.

Good luck digging! :D

senocular
January 15th, 2004, 09:33 AM
that file is actually a little messy. Im making a new one... might be a little while though - I was sick yesterday and I'll only have time today after work to get more done on it...

lunatic
January 15th, 2004, 10:57 AM
Hey Sen I hope you feel better soon! :thumb:

senocular
January 15th, 2004, 06:45 PM
ok... well heres something. Im not happy with it, but it can be built upon. There are some structure issues... I wasn't sure how to organize it. I think one thing one day and another the next so it may be a little uneven but maybe it can help ... or not. But its a new file with a slider and selection zooming and panning.

lunatic
January 15th, 2004, 06:58 PM
Wow Sen that is very impressive for a quick throw together! Thanks for passing it along! I am probably going to mess it up trying to get the whole map to inset thing worked out, because my boss really needs to have that kind of navigation functionality. So you may be hearing from me some more in the future (sorry! :puzzled: ).

You are the man! :cheers: :beam:

jimhere
January 15th, 2004, 09:47 PM
A masterpiece. Useable, workable, flexible.
I place a satellite map of where I grew up (western Pennsylvania), and groovy!
It'll be even more flexible with a vector map -- no file size to deal with and plenty of room on the sides for zooming back out. (too big to post -- 316k swf).
Is the text box type-in-able? I tried typing 200 to zoom back out, but it ignored me.

lunatic
January 16th, 2004, 10:40 AM
I believe the text box is for display purposes only. I am going to start working on tweaking this today to try to fit the class objects into my current design. I will keep you all posted on how it goes - as I'm sure I will get stuck in a few places! :sigh:

Thanks again Sen! :love:

lunatic
January 16th, 2004, 12:11 PM
Okay Senocular, I have read through all the AS and am trying desparately to digest it all. I have a few things I am hoping you can clarify for me:

1) On the SelectionBox.prototype.onMouseUp function, on the variable select - why is 'this.left' (or right or top or bottom) subtracted from the Min value? I guess you are subtracting the bounds variable but why do left and right BOTH subtract the left bound and the top and bottom BOTH subtract the top bound?

2) Why is the onSelection function defined OUTSIDE of the object (it is defined only for the object instance? :h: ) but the variables are defined INSIDE?


3) this is going to seem silly but I am trying to learn proper syntax

On the SelectionBox.prototype.onMouseDown - the last line is

this.onMouseMove = this.drawSelection;

Since drawSelection is a function why are there no brackets?
as in drawSelection();

And last question - can I use these same objects/prototype to create the map to inset functionality that I was originally going for? Or will I have to create new classes/prototypes?

Thanks for any help you can give! :s:

senocular
January 16th, 2004, 06:31 PM
1) because its getting the relation of those values in respects to the boundries specified by left, top, right & bottom. Subtracting the left edge of a bounding box gives the value of the selection from that edge.

so if the bounds left is at 100px and your selection left is at 300px, but you want the selection in respect to the bounding right, you would want the value 200 (since its 200 from the left edge) ... 300 - 100 = 200.

2) onSelection is like an onEnterFrame or an onPress. MovieClips or buttons don't automatically have onEnterFrame or onPress actions. You give them to ... them. Thats the idea in using onSelection.

3) this.drawSelection has no () parenthesis because its not being called. Whats going on there is the onMouseMove function is being assigned the value of the drawSelection variable which has a function value. This makes onMouseMove equal to the function that drawSelection is equal to which is defined as the prototype

and yes.