Solved

HOW DO I ADD DRAGGABILITY TO THIS CURRENT CODE

Posted on 2003-11-30
3
210 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 500 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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

691 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