# need help with xy coordinates

• Student
• Posts: 70

3+ Months Ago

Hey Guys,

This is a really annoying problem and since this is new problems and so I decide to posting new thread....
I have a mc movieclip that can be easing x,y perfectly upon clicking right side button as u can see and testing here..

http://sloppyflashguy.franzacollections ... roblem.swf

This is all working ok,but the problem only starts occured when start zoom in zoom out the mc will easings to unrecognise x,y coordinates..eventhough I do have calculated the new coordinates after zooming but still got no luck...please guys whats wrong with the code...just need to know if anyone can help with this one. Anythoughts would be great.

here's the code I'm currently using ...

Code: [ Select ]
stop();

//import some transition stuff
import mx.transitions.Tween;
import mx.transitions.easing.*;

var coor:Array = new Array([357.6,19.9],[21.7,9.7],[367.9,287.9],[34.2,287.9]);
var len:Number = coor.length;

var orix:Number = mc._x;
var oriy:Number = mc._y;
var oriw:Number = mc._width;
var orih:Number = mc._height;
var orixscale:Number = mc._xscale;
var oriyscale:Number = mc._yscale;
var tw:Number;
var th:Number;

var currX:Number;
var currY:Number;
var currXscale:Number;
var currYscale:Number;
var currW:Number;
var currH:Number;

var onScale:Boolean = false;

var holder:MovieClip = this.createEmptyMovieClip("holder",this.getNextHighestDepth());

for (var j=0; j<len; j++) {
var btn = holder.attachMovie("btn", "btn"+j,holder.getNextHighestDepth());
btn.jvar = j;
btn._x = 450;
btn._y = 50+btn._height*j;
btn.labelbtn.text = j;
btn.onPress = slideMe;
}
}

function slideMe():Void{
if(currX == undefined && currY == undefined){
easing(mc,orix,coor[this.jvar][0],oriy,coor[this.jvar][1]);
}else{
easing(mc,currX ,coor[this.jvar][0],currY,coor[this.jvar][1]);
}
}

function easing(mc:MovieClip, startx:Number, endx:Number, starty:Number, endy:Number):Void {
var time:Number = 35;
var easeType:Function = Strong.easeOut;
var tweenListener:Object = new Object();
trace(onScale);
if (onScale == false){
var xTween:Tween = new Tween(mc, "_x", easeType, startx, endx, time);
var yTween:Tween = new Tween(mc, "_y", easeType, starty, endy, time);
currX = endx;
currY = endy;
} else{
[COLOR="Red"]////////calculate new coordinates after zooming////////////////////
// I try calculate here..still got no luck ....
endx = endx - tw/2;
endy = endy - th/2;

//////////////////////////////////////////////////////////////////[/COLOR]
var xTween:Tween = new Tween(mc, "_x", easeType, startx, endx, time);
var yTween:Tween = new Tween(mc, "_y", easeType, starty, endy, time);
currX = endx;
currY = end
}
}
///////rescale mc thingy stuff

var zoomPercent:Array = ["100","120","140","160","180"];
var zoomlen:Number = zoomPercent.length;
var count:Number = 0;
var clickable:Number = 0;

zoomout.enabled = false;

zoomin.onPress = function(){
clickable++;
onScale = true;
zoomout.enabled = true;
if(count<zoomlen){
count++;
zoomInto(zoomPercent[count]);
if(clickable == 4){
zoomin.enabled = false;
}
}
};

zoomout.onPress = function() {
clickable--;
trace(clickable);
zoomin.enabled = true;
if(count>0){
count--;
zoomInto(zoomPercent[count]);
if(clickable == 0){
zoomout.enabled =false;
onScale = false;
}
}
};

function zoomInto(zoom,duration){
//determine the 100% width & height
var ow = mc._width/(mc._xscale/100);//original width
var oh = mc._height/(mc._yscale/100);//original height
tw = ow*(zoom/100);//target width
th = oh*(zoom/100);//target height
//trace(tw+"||"+th);
var mcwidth:Object = new Tween(mc, "_width", Zoom.easeIn, mc._width, tw, 1, true);
var mcheight:Object = new Tween(mc, "_height", Zoom.easeIn, mc._height, th, 1, true);
}
1. stop();
2. //import some transition stuff
3. import mx.transitions.Tween;
4. import mx.transitions.easing.*;
5. var coor:Array = new Array([357.6,19.9],[21.7,9.7],[367.9,287.9],[34.2,287.9]);
6. var len:Number = coor.length;
7. var orix:Number = mc._x;
8. var oriy:Number = mc._y;
9. var oriw:Number = mc._width;
10. var orih:Number = mc._height;
11. var orixscale:Number = mc._xscale;
12. var oriyscale:Number = mc._yscale;
13. var tw:Number;
14. var th:Number;
15. var currX:Number;
16. var currY:Number;
17. var currXscale:Number;
18. var currYscale:Number;
19. var currW:Number;
20. var currH:Number;
21. var onScale:Boolean = false;
22. var holder:MovieClip = this.createEmptyMovieClip("holder",this.getNextHighestDepth());
24.     for (var j=0; j<len; j++) {
25.         var btn = holder.attachMovie("btn", "btn"+j,holder.getNextHighestDepth());
26.         btn.jvar = j;
27.         btn._x = 450;
28.         btn._y = 50+btn._height*j;
29.         btn.labelbtn.text = j;
30.         btn.onPress = slideMe;
31.     }
32. }
34. function slideMe():Void{
35.     if(currX == undefined && currY == undefined){
36.         easing(mc,orix,coor[this.jvar][0],oriy,coor[this.jvar][1]);
37.     }else{
38.         easing(mc,currX ,coor[this.jvar][0],currY,coor[this.jvar][1]);
39.     }
40. }
41. function easing(mc:MovieClip, startx:Number, endx:Number, starty:Number, endy:Number):Void {
42.     var time:Number = 35;
43.     var easeType:Function = Strong.easeOut;
44.     var tweenListener:Object = new Object();
45.     trace(onScale);
46.     if (onScale == false){
47.         var xTween:Tween = new Tween(mc, "_x", easeType, startx, endx, time);
48.         var yTween:Tween = new Tween(mc, "_y", easeType, starty, endy, time);
49.         currX = endx;
50.         currY = endy;
51.     } else{
52.         [COLOR="Red"]////////calculate new coordinates after zooming////////////////////
53.         // I try calculate here..still got no luck ....
54.         endx = endx - tw/2;
55.                 endy = endy - th/2;
56.         //////////////////////////////////////////////////////////////////[/COLOR]
57.         var xTween:Tween = new Tween(mc, "_x", easeType, startx, endx, time);
58.         var yTween:Tween = new Tween(mc, "_y", easeType, starty, endy, time);
59.         currX = endx;
60.         currY = end
61.     }
62. }
63. ///////rescale mc thingy stuff
64. var zoomPercent:Array = ["100","120","140","160","180"];
65. var zoomlen:Number = zoomPercent.length;
66. var count:Number = 0;
67. var clickable:Number = 0;
68. zoomout.enabled = false;
69. zoomin.onPress = function(){
70.     clickable++;
71.     onScale = true;
72.     zoomout.enabled = true;
73.     if(count<zoomlen){
74.         count++;
75.         zoomInto(zoomPercent[count]);
76.         if(clickable == 4){
77.             zoomin.enabled = false;
78.         }
79.     }
80. };
81. zoomout.onPress = function() {
82. clickable--;
83. trace(clickable);
84. zoomin.enabled = true;
85. if(count>0){
86.      count--;
87.      zoomInto(zoomPercent[count]);
88.      if(clickable == 0){
89.         zoomout.enabled =false;
90.         onScale = false;
91.      }
92. }
93. };
94. function zoomInto(zoom,duration){
95. //determine the 100% width & height
96.     var ow = mc._width/(mc._xscale/100);//original width
97.     var oh = mc._height/(mc._yscale/100);//original height
98.     tw = ow*(zoom/100);//target width
99.     th = oh*(zoom/100);//target height
100.     //trace(tw+"||"+th);
101.     var mcwidth:Object = new Tween(mc, "_width", Zoom.easeIn, mc._width, tw, 1, true);
102.     var mcheight:Object = new Tween(mc, "_height", Zoom.easeIn, mc._height, th, 1, true);
103. }

in case wanna see my fla garb here...

http://sloppyflashguy.franzacollections ... roblem.fla

Any help and concerns are really appreciated as I'm not asking someones to code for me only just to show/point me where exactly my mistakes..and shed some light ...the rest I will work it out...Tq again..guys

## Post Information

• Total Posts in this topic: 1 post
• Users browsing this forum: No registered users and 4 guests
• You cannot post new topics in this forum
• You cannot reply to topics in this forum
• You cannot edit your posts in this forum
• You cannot delete your posts in this forum
• You cannot post attachments in this forum