Hi I would like to apply a zoom feature where the user can scroll the mouse wheel to zoom in and out on a movieclip. I currently have zoom implemented as buttons. How would I go about implementing the wheel action?
button zoom code:
[AS]
small.onPress = function(){
ROOT.onEnterFra me = function(){
zoom._xscale*=0 .9;
zoom._yscale*=0 .9;
checkBounds(0,0 ,0,0);
}
}
small.onRelease = function() {
delete ROOT.onEnterFra me;
}
small.onRelease Outside = function() {
delete ROOT.onEnterFra me;
}
big.onPress = function(){
ROOT.onEnterFra me = function(){
zoom._xscale*=1 .1;
zoom._yscale*=1 .1;
checkBounds(0,0 ,0,0);
}
}
big.onRelease = function() {
delete ROOT.onEnterFra me;
}
big.onReleaseOu tside = function() {
delete ROOT.onEnterFra me;
}
[/AS]
4 15386
Ok I figured out the mouse zoom in out thing, but I cannot get the zoom to stop when I use the mouse wheel, with one slight movement of the mouse wheel in either direction, the mc begins to zoom without end...any ideas? Here is the code I have for the mousewheel...
[AS]
mouseWheelListe ner = new Object();
mouseWheelListe ner.onMouseWhee l = function(delta) {
if(delta > 0){
ROOT.onEnterFra me = function(){
zoom._xscale*=0 .9;
zoom._yscale*=0 .9;
checkBounds(0,0 ,0,0);
}
}else{
ROOT.onEnterFra me = function(){
zoom._xscale*=1 .1;
zoom._yscale*=1 .1;
checkBounds(0,0 ,0,0);
}
}
}
Mouse.addListen er(mouseWheelLi stener);
[/AS]
Ok I figured out the mouse zoom in out thing, but I cannot get the zoom to stop when I use the mouse wheel, with one slight movement of the mouse wheel in either direction, the mc begins to zoom without end...any ideas? Here is the code I have for the mousewheel...
[AS]
mouseWheelListe ner = new Object();
mouseWheelListe ner.onMouseWhee l = function(delta) {
if(delta > 0){
ROOT.onEnterFra me = function(){
zoom._xscale*=0 .9;
zoom._yscale*=0 .9;
checkBounds(0,0 ,0,0);
}
}else{
ROOT.onEnterFra me = function(){
zoom._xscale*=1 .1;
zoom._yscale*=1 .1;
checkBounds(0,0 ,0,0);
}
}
}
Mouse.addListen er(mouseWheelLi stener);
[/AS]
You have a checkBounds function so if you getBounds in the checkBounds and then switch a Boolean to false to stop the enlargement.
Example; - mouseWheelListener = new Object();
-
var scale:Boolean = true;
-
mouseWheelListener.onMouseWheel = function(delta) {
-
if(delta > 0){
-
ROOT.onEnterFrame = function(){
-
if(scale){
-
zoom._xscale*=0.9;
-
zoom._yscale*=0.9;
-
}
-
scale = checkBounds(0,0,0,0, _root.[scrollTarget]); //scrollTarget is the mc name in string form so find a way to convert it to an mc
-
}
-
-
var maxBounds:Array = new Array({yMax:2000, yMin:-50, xMax:300, xMin:-500})
-
function checkBounds(0,0,0,0, mc:MovieClip):Boolean{
-
var bounds_obj:Object = mc.getBounds(this);
-
for (var i in bounds_obj) {
-
trace(i+" --> "+bounds_obj[i]);//for debugging
-
switch(i){
-
case yMax:
-
if(bounds_obj[i]>maxBounds[0].yMax) return false;
-
break;
-
case yMin:
-
if(bounds_obj[i]<maxBounds[0].yMin) return false;
-
break;
-
case xMax:
-
if(bounds_obj[i]>maxBounds[0].xMax) return false;
-
break;
-
case xMin:
-
if(bounds_obj[i]<maxBounds[0].xMin) return false;
-
break;
-
}
-
}
-
-
//add your code here....
-
-
return true;
-
}
-
This is untested!
working mousewheel zoom code:
[AS]
//--------------------------------- code MouseWheel zoom feature -----------------------\
var mouseListener:O bject = new Object();
mouseListener.o nMouseWheel = function(delta)
{
if(delta > 0)
{
zoom._xscale *= 1.1;
zoom._yscale *= 1.1;
}
else
{
if(mc_scale < zoom._xscale)
{
zoom._xscale*=0 .9;
zoom._yscale*=0 .9;
}
if(mc_scale >= zoom._xscale)
{
_global.contain er._x = mc_X;
_global.contain er._y = mc_Y;
}
}
}
Mouse.addListen er(mouseListene r);
//--------------------------------- end MouseWheel zoom code -----------------------\
[/AS]
working mousewheel zoom code:
[AS]
//--------------------------------- code MouseWheel zoom feature -----------------------\
var mouseListener:O bject = new Object();
mouseListener.o nMouseWheel = function(delta)
{
if(delta > 0)
{
zoom._xscale *= 1.1;
zoom._yscale *= 1.1;
}
else
{
if(mc_scale < zoom._xscale)
{
zoom._xscale*=0 .9;
zoom._yscale*=0 .9;
}
if(mc_scale >= zoom._xscale)
{
_global.contain er._x = mc_X;
_global.contain er._y = mc_Y;
}
}
}
Mouse.addListen er(mouseListene r);
//--------------------------------- end MouseWheel zoom code -----------------------\
[/AS]
Well done for getting it working. I can see you weren't impressed by my suggestion of checking the mc size against a limit.
Opting for a scale limit instead.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: AccessWhiz |
last post by:
I have been trying desperately for the past few days to figure out why
the MouseWheel solution that I retrieved from the Lebans website won't
work. The access database included with the solution responds to the
the wheel regardless of the button. In my application I get an error
message when I try to set the class. I'm hoping that I can get some
help (cause I feel really stupid right now).
Before we go too much further, I am using a...
|
by: jv |
last post by:
I have quite a few of continuous form and subform where I do allow
scroll bars. I run into problems with the mouse wheel whenever the
data on the form does not take up the whole page. In this instance,
whenever a user uses the mouse wheel to scroll down, the first record
disappears off the screen and they can't get it back unless they click
on the Refresh button or Page Up. The mouse wheel never scroll back up
to the first record. ...
|
by: Susan Bricker |
last post by:
Hi. Does anyone have a clue why my mouse wheel stopped working while I
was working on the VB behind a form in MS/Access? I would swear that
the mouse wheel was working a short time ago. I've checked that it
isn't a malfunction of the mouse by going to other applications and
trying the wheel. It works just fine.
This is very frustrating. It's bad enough that I have a logic problem,
but now my mouse is not working while trying to...
|
by: tommaso.gastaldi |
last post by:
This is a curious question. I'd like to know your opinion.
I am attaching a drawing resize to a mouse wheel event.
Frankly, to me was most natural that, if I mouse wheel UP, the shape
gets bigger, while it gets smaller when mouse wheel DOWN.
I just noticed that Photoshop does the opposite.
Any though about the most natural way (or perhaps are both "natural") ?
|
by: Martijn Mulder |
last post by:
When the mouse is over a picture, the user can grow or shrink it by rolling
the central mouse wheel. What behavior is typical when the user rolls the
wheel away. Will the picture grow or shrink then?
| |
by: killbill123 |
last post by:
Hi,
I want to count the mouse wheel rotations in javascript.
I searched on google and only found that how to track delta -1 and +1 base on the up mouse wheel and down mouse wheel. I want how can i correctly count the wheel rotation in one mouse wheel or how to count wheel rotation.
Need help please urgently.........??
|
by: Andrus |
last post by:
I need to save font selected by user by Ctrl+MouseWheel in Winforms
RichTextBox.
I tried override below but this does not remember font: in this method
Font.Size property
seems to be always *initial* Font size when RichTextBox is created, *not*
the font size set by ctrl+mouse wheel.
How to find the font size set by Ctrl+Mouse wheel ?
|
by: alarock |
last post by:
how can i do Zooming of a particular area using OnMouseWheel (that is zooming a mouse wheel point that should come into view with zoom ) using C#
Regards,
ALGATES
|
by: sandeepshetty |
last post by:
hi all..
Can anybody help me out on how zooming can be done on images in web applications but only by using mouse wheel and scroll bars.. thank u..
sandeep.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |