Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HOW DO I ADD DRAGGABILITY TO THIS CURRENT CODE

Posted on 2003-11-30
3
Medium Priority
?
212 Views
Last Modified: 2010-04-03
How do I add draggability to the code below.  I have a small thumbnail and a small magnifying glass that designates the zoom area.  The zoom of the thumbnail appears in another box.  Right now if you click on the thumbnail, the magnifying glass will move to the position you clicked.  How do I change the code so that you can both click the thumbnail to move to that position and be able to drag the magnifying glass around as well?  Here's the code on the magnifying glass.


onClipEvent (load) {
      // Initialize variables
      danX = _root.screen._x-(_root.screen._width/2);
      danY = _root.screen._y-(_root.screen._height/2);
      //
      //
      // negative one creates opposite direction to corrospond to the moviement of the viewfinder
      ratio = (_root.screen2._width/_root.screen._width)*(-1);
      //
      //
      // Change this number to speed up (less than 5) or slow down (greater than 5)
      speedRatio = 10;
      //
      //
      // Define function to do all the work
      function myClick (myX, myY) {
            xDis = ((myX-this._x)/speedRatio);
            yDis = ((myY-this._y)/speedRatio);
            //
            //
            // Make blur effect
            _root.screen2.blur._alpha = ((Math.abs(xDis)+Math.abs(yDis))*5);
            //
            //
            // Give Viewfinder elasticity
            _root.viewFinder._x = _root.viewFinder._x+xDis;
            _root.viewFinder._y = _root.viewFinder._y+yDis;
            _root.screen2._x = ((_root.viewFinder._x-_root.screen._x)*ratio)+(_root.window._x);
            _root.screen2._y = ((_root.viewFinder._y-_root.screen._y)*ratio)+(_root.window._y);
      }
}
onClipEvent (mouseUp) {
      // Set parameters for your function
      if (_root.screen.hitTest(_root._xmouse, _root._ymouse, true)) {
            danX = _root._xmouse;
            danY = _root._ymouse;
      }
}
onClipEvent (enterFrame) {
      // Call function
      myClick(danX, danY);
}

Any help would greatly be appreciated
0
Comment
Question by:madasczik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Expert Comment

by:negatyve
ID: 9848822
I do not understand. THIS movieclip should be draggable?
0
 

Author Comment

by:madasczik
ID: 9851422
It sort of drags but it looks like its sticking to the start position and the click points for some reason.   Take a look:

http://dev.fusionapps.com/matt/thumbnail_zoom.html
http://dev.fusionapps.com/matt/thumbnail_zoom.swf
http://dev.fusionapps.com/matt/thumbnail_zoom.fla
0
 
LVL 27

Accepted Solution

by:
negatyve earned 2000 total points
ID: 9851713
Modify the viewFinder button script this way:

on (press) {
      tellTarget ("../zoom") {
            gotoAndPlay(1);
      }
      call("reset");
      this.draggin = true;
      gotoAndPlay("start");
}
on (release) {
      tellTarget ("../zoom") {
            gotoAndStop("over");
      }
      call("reset");
      this.draggin = false;
      gotoAndPlay(1);
}
on (releaseOutside) {
      this.draggin = false;
      gotoAndPlay(1);
}
on (rollOver) {
      tellTarget ("../zoom") {
            gotoAndStop("over");
      }
      call("reset");
}
on (rollOut) {
      tellTarget ("../zoom") {
            gotoAndPlay(1);
      }
      call("reset");
}


then modify viewFinder script this way:


onClipEvent (load) {
      danX = _root.screen._x-(_root.screen._width/2);
      danY = _root.screen._y-(_root.screen._height/2);
      // negative one creates opposite direction to corrospond to the moviement of the viewfinder
      ratio = (_root.screen2._width/_root.screen._width)*(-1);
      // Change this number to speed up (less than 5) or slow down (greater than 5)
      speedRatio = 10;
      // Define function to do all the work
      function myClick (myX, myY) {
            xDis = ((myX-this._x)/speedRatio);
            yDis = ((myY-this._y)/speedRatio);
            // Make blur effect
            _root.screen2.blur._alpha = ((Math.abs(xDis)+Math.abs(yDis))*5);
            // Give Viewfinder elasticity
            _root.viewFinder._x += xDis;
            _root.viewFinder._y += yDis;
            _root.screen2._x = ((_root.viewFinder._x-_root.screen._x)*ratio)+(_root.window._x);
            _root.screen2._y = ((_root.viewFinder._y-_root.screen._y)*ratio)+(_root.window._y);
      }
}
onClipEvent (enterFrame) {
      // Call function
      myClick(danX, danY);
}
onClipEvent(mouseMove){
      if(this.draggin){
            if (_root.screen.hitTest(_root._xmouse, _root._ymouse, true)) {
                  danX = _root._xmouse;
                  danY = _root._ymouse;
            }
      }
}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question