Page 1 of 1

What's wrong with this simple handler?

Posted: Wed Oct 03, 2012 10:44 pm
by waprothero
I have a map graphic on a card. I named it "worldMap".
In the card script, I have:

on mouseUp
initMap
end mouseUp

In the stack script, I have. (note that I get the same error whether the script is in the stack or the map graphic script)
on initMap
put the formattedWidth of "worldmap" into mapWidth
put the formattedWidth of "worldmap" into mapHeight
end initMap

I get an error message at the "put the formattedWidth of ...."
error message: image "worldmap": execution error at line n/a (Chunk: error in object expression) near "worldmap", char 1

What the heck? This is just like one of the lessons???

Re: What's wrong with this simple handler?

Posted: Wed Oct 03, 2012 10:50 pm
by mwieder
The "formattedWidth" is for text fields only.

Try "the width".

Re: What's wrong with this simple handler?

Posted: Wed Oct 03, 2012 10:58 pm
by jacque
The engine needs to know what "worldmap" is, so supply an object type: the formattedwidth of image "worldmap"

Unless it really is a graphic object, in which case use "graphic" instead of "image".

Re: What's wrong with this simple handler?

Posted: Wed Oct 03, 2012 11:05 pm
by mwieder
Q: You can get the formattedWidth of an image?
A: Yes you can. I just looked it up. Learned something new.

http://docs.runrev.com/Property/formattedWidth

Re: What's wrong with this simple handler?

Posted: Wed Oct 03, 2012 11:13 pm
by jacque
Yeah, since you can lock the size to something different.

Re: What's wrong with this simple handler?

Posted: Thu Oct 04, 2012 1:27 am
by waprothero
I got it working with
Put the formatted width of image "worl map" into x

The tutorial had, as an example
Put the formattedwidth of pImageID into x

So, I just put the image I'd number in for pImagdeID, but now I wonder if I put that number in quotes. I'll,have to try it without quotes before I blame the tutorial.

By the way, what's the difference between an image and a graphic?

Thanks for the answers,
Bill

Re: What's wrong with this simple handler?

Posted: Thu Oct 04, 2012 9:17 am
by Klaus
Hi Bill,
waprothero wrote:I got it working with
Put the formatted width of image "worl map" into x

The tutorial had, as an example
Put the formattedwidth of pImageID into x
where pImageID is a variable which will probably hold the "long ID" or the "long NAME" of the image!
Lookup "long ID" etc. in the dictionary.
waprothero wrote:So, I just put the image Id number in for pImagdeID, but now I wonder if I put that number in quotes. I'll,have to try it without quotes before I blame the tutorial.
No quotes!
...
put the formattedwidth of img ID 1003 into x
...
waprothero wrote:By the way, what's the difference between an image and a graphic?
image = pixel image
graphic = vector graphic =resolution independent

Scale anm image and a graphic and you will see the difference :D


Best

Klaus

Re: What's wrong with this simple handler?

Posted: Thu Oct 04, 2012 4:43 pm
by waprothero
Thanks for the definition. I always considered an image to be a graphic, so it's good to know the livecode distinction.