Ciao ho creato un mapping con un' immagine duplicata, con dimensioni differenti.
sulla piccola si clicca e la grande si sposta in quel punto
volevo applicare allo script il moto elastico.
chi mi aiuta?
come potete vedere ho segnato con grassetto le parti do codice che andrebbero integrate tra di loro.codice://Applico moto elastico controllo.onLoad = function() { arrivo = _x; acc = 2; ine = 3; } controllo.onEnterFrame = function() { dx = (dx+(arrivo-_x)/acc)/ine; _x += dx; if (Math.abs(_x-arrivo)<0.5) { _x = arrivo; } } //costruisco mapping //big è la grossa e small la piccola stop(); //dimensioni della mappa grossa b = new Object(); b.xMin = 30; b.xMax = -809; b.yMin = 27; b.yMax = -210; b.width = b.xMax-b.xMin; b.height = b.Ymax - b.yMin; //stesso per il piccolo s = small.getBounds(_root); s.width = s.xMax - s.XMin; s.height = s.yMax - s.yMin; //codice per il mouse /*_root.onMouseMove = function(){ var percentX = (_root._xmouse - s.xMin)/s.width; var percentY = (_root._ymouse - s.yMin)/s.height; big._x = b.xMin+ (percentX*b.width); big._y = b.yMin+ (percentY*b.height); updateAfterEvent(); }*/ small.onMouseDown = function(){ clicking = true; moveBig(); } small.onMouseUp = function(){ clicking = false; } small.onMouseMove = function(){ if(clicking){ //moveBig(); //updateAfterEvent(); //} //mag._x = _root._xmouse; //mag._y = _root._ymouse; moveBig(); if(big._x<b.xMax){ big._x=b.xMax; } if(big._x>b.xMin){ big._x = b.xMin; } if(big._y<b.yMax){ big._y = b.yMax; } if(big._y>b.yMin){ big._y = b.yMin; } updateAfterEvent(); } } function moveBig(){ var percentX = (_root._xmouse - s.xMin)/s.width; var percentY = (_root._ymouse - s.yMin)/s.height; big._x = b.xMin+ (percentX*b.width); big._y = b.yMin+ (percentY*b.height); }
Io penso che dovrei sostituire big._x con arrivo.