Page 1 of 1
Using x loc, y loc to position a graphic
Posted: Sun Jun 29, 2008 5:23 pm
by bjb007
I want to position a graphic relative to
another object and have tried to use the
x loc, y loc to do this. I've tried all the
permutations I can think of without success.
Any suggestions appreciated.
Posted: Sun Jun 29, 2008 9:05 pm
by malte
You get the location of an object in a comma seperated string. No way to set the xloc or y loc seperately I am aware of.
local tX,tY
put item 1 of control "myControl" into tX
put item 2 of control "myControl" into tY
set the loc of control "myOtherControl" to tX+10,tY+10
Hope that snippet gets you started,
Malte
Using x loc, y loc to position a graphic
Posted: Sun Jun 29, 2008 11:06 pm
by bjb007
Malte
Thanks for that.
Now I'm going to take advantage of
your expertise in all things graphical.
I want to move an image from, say 50, 50 to
100,100 but I want it to go only vertically and
horizontally rather than taking the direct route.
Well, it doesn't have to worry about mpg!
So it has to go to 50,100 then to 100,100.
Is there a neat way to do this?
Posted: Sun Jun 29, 2008 11:34 pm
by gyroscope
Hi bjb007, one relatively straightforward way would be:
Code: Select all
on mouseUp pMouseBtnNo
move image "XYZ" to 50,100 in 20 ticks
wait 5 ticks
move image "XYZ" to 100,100 in 20 ticks
end mouseUp
Hope that's the sort of thing you're after...
PS I'm glad to see you're not grumpy anymore, bjb007!!

Posted: Sun Jun 29, 2008 11:51 pm
by bjb007
gyroscope
The locations will come from the script
and vary for a number of items so I really
need a programmable way to get the result
I want.
I haven't tried to programme it yet as I've spent
half the night trying to sort the array to get the
right graphic going to the right location - see my
post.
Expect after some zzzzz I'll feel able to figure it
out but I get confused by the negative movements.
Way back -- 1974 -- I had the interesting task of
calculating the centre of gravity of some walk-ways
on a North Sea oil production platform. No computers
then, just mechancial calculators.
So the thing which made it much easier was to
set the 0,0 not at the centre of the platform but
some way off out in the North Sea. That way all
distances were positive.
Edit:
So now I'm wondering if it would be possible
to put an object somewhere off-stack and use
relative positions so that they're all positive numbers.
Posted: Mon Jun 30, 2008 12:16 am
by gyroscope
set up globals, put your positions in these, perhaps? i.e.
Code: Select all
global gLocA, gLocB, gLocC, gLocD
---these have values put into them from other handlers, perhaps
on mouseUp
move image "XYZ" to gLocA,gLocB in 20 ticks
wait 5 ticks
move image "XYZ" to gLocC,gLocD in 20 ticks
end mouseUp
I had the interesting task of
calculating the centre of gravity of some walk-ways
on a North Sea oil production platform.
Sheesh, I wouldn't know where to start there...!

Using x loc, y loc to position a graphic
Posted: Mon Jun 30, 2008 2:12 am
by bjb007
Malte, gyroscope and all Revvers.
I've uploaded my test stack to RevOnline
User bjb007.
Stack: Finder v0.1
Re: Using x loc, y loc to position a graphic
Posted: Sun Nov 07, 2010 6:24 am
by LESTROSO
Hy to Everybody, Lestroso Here,
I want just to share a trick that i have done with revolution, now Livecode...about to get the xloc and the yloc , in order to set a location of an object, so how to get the real position of an object in very few line of codes.
Here this example that really works....
Code: Select all
global tX,tY
on mouseUp
put the item 1 of the loc of button id 1006 into tX
put the item 2 of the loc of button id 1006 into tY
put tx &cr& ty into field "risultato"---put the risult into a field called "risultato" to see the numbers variables
end mouseUp
Cheers!!eheheh
Lestroso
http://www.fasasoftware.com
Re: Using x loc, y loc to position a graphic
Posted: Sun Nov 07, 2010 6:40 am
by Dixie
lestroso...
What would be wrong with just... ?
Code: Select all
on mouseUp
put the loc of me
end mouseUp
be well
Dixie
Re: Using x loc, y loc to position a graphic
Posted: Sun Nov 07, 2010 11:26 am
by Mark
Or... to get the same result as Lestroso:
on mouseUp
put replaceText(the loc of the target,comma,cr) into fld "Risultato"
end mouseUp
Best,
Mark
Re: Using x loc, y loc to position a graphic
Posted: Sun Nov 07, 2010 2:51 pm
by Dixie
Mark,
even better... nice one
be well
Dixie