crashgordon Posted October 27, 2009 Share Posted October 27, 2009 I would like to do a check on a dynamic number to use in an if statement, the check would let me know if the number was getting bigger or smaller at any time, as its dynamic it would need to some how save the last number to check against RD.resizeTo((rb.x-rt.x)+RD.defw,(rb.x-rt.x)+RD.defw) the rb.x - rt.x returns a value to resize RD, I would like to now if its possible to know check for when RD is being scaled up and when it is being scaled down. rb is a draggable object and i think it works in a loop that is called whenever it is dragged many thanks and if my explanation is a bit rubbish i will try and be clearer Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2009 Share Posted October 27, 2009 RD.resizeTo((rb.x-rt.x)+RD.defw,(rb.x-rt.x)+RD.defw) width[] = RD.getWidth(); height[] = RD.getHeight(); ///////////////// if(RD.width > width[arraysize(width)]) has moved up width if(RD.height> height[arraysize(height)]) has moved up height you will need to check the function on php.net to see arraysize maybe it has different name Quote Link to comment Share on other sites More sharing options...
crashgordon Posted October 27, 2009 Author Share Posted October 27, 2009 thanks for such a quick response, it doesn't seem to work at the moment, im using A drag and drop API from walterzorn.com could this be causing the problem also would this method be able to determine a change in direction of scale while the loop is still active? thanks for the help so far Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 27, 2009 Share Posted October 27, 2009 thanks for such a quick response, it doesn't seem to work at the moment, im using A drag and drop API from walterzorn.com could this be causing the problem also would this method be able to determine a change in direction of scale while the loop is still active? thanks for the help so far RD.resizeTo((rb.x-rt.x)+RD.defw,(rb.x-rt.x)+RD.defw) width[] = RD.getWidth(); ///// you need to check how to height[] = RD.getHeight(); ///// push elements into an array in javascript i think this is correct ///////////////// if(RD.width > width[arraysize(width)]) has increased up width else if (RD.width < width[arraysize(width)]) has decreased height if(RD.height > height[arraysize(height)]) has increased height else if(RD.height < height[arraysize(height)]) has decreased height Quote Link to comment Share on other sites More sharing options...
crashgordon Posted October 27, 2009 Author Share Posted October 27, 2009 thanks for you help but im sturggling to get it to work. I understand the if statements but im really very new to java script and an array is something I dont really understand. Dont you have to create a variable before you call the arrray?? I found this example on the internet http://www.hscripts.com/tutorials/javascript/dynamic-array.php and have started to write this; var height = new Array(); height[] = RD.h; if(RD.h> height[arraysize(height)]) has moved up height I dont think i need to call RD.getHeight(); as the API only requires RD.h but it still breaks the code, any ideas where im going wrong??? I forgot to mention that "RD.resizeTo((rb.x-rt.x)+RD.defw,(rb.x-rt.x)+RD.defw)" is part of a funtion, will this cause problems?? once again thanks for the help so far Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Share Posted October 28, 2009 make the array before the loop starts, we need to see much more code, to see whats going on, are you starting from scratch or what ? i have touched on this framework before, so if you just give us the code your working on, the whole bit paste it in here in code tags Quote Link to comment Share on other sites More sharing options...
crashgordon Posted October 28, 2009 Author Share Posted October 28, 2009 ok almost solved this I think.... I created a function that resizes an other object either slightly bigger than RD.w if the image scales up and slightly smaller in width than RD.w if RD is scaling down I should in theory be able create an if statement using the objects width (IA.w) to check against RD.w but from my current experience with java script it never seems to be that simple haha!! anways here's what my little brain came up with, if anyone thinks the code is a bit rough or can be streamlined im very happy for more help and suggestions and once again many thanks for the help, nadeemshafi9 function scaleCheck() { { if (IA.w > RD.w+1) { IA.resizeTo(RD.w+1,4); } else if (IA.w < RD.w-1) { IA.resizeTo(RD.w-1,4); } else {null} } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.