Jump to content

Some ideas on how to do this


crashgordon

Recommended Posts

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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}

}

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.