What's wrong with this simple handler?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

What's wrong with this simple handler?

Post by waprothero » Wed Oct 03, 2012 10:44 pm

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???
Bill Prothero

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: What's wrong with this simple handler?

Post by mwieder » Wed Oct 03, 2012 10:50 pm

The "formattedWidth" is for text fields only.

Try "the width".

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What's wrong with this simple handler?

Post by jacque » Wed Oct 03, 2012 10:58 pm

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".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: What's wrong with this simple handler?

Post by mwieder » Wed Oct 03, 2012 11:05 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What's wrong with this simple handler?

Post by jacque » Wed Oct 03, 2012 11:13 pm

Yeah, since you can lock the size to something different.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Re: What's wrong with this simple handler?

Post by waprothero » Thu Oct 04, 2012 1:27 am

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
Bill Prothero

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: What's wrong with this simple handler?

Post by Klaus » Thu Oct 04, 2012 9:17 am

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

waprothero
Posts: 38
Joined: Tue Sep 20, 2011 5:01 pm
Contact:

Re: What's wrong with this simple handler?

Post by waprothero » Thu Oct 04, 2012 4:43 pm

Thanks for the definition. I always considered an image to be a graphic, so it's good to know the livecode distinction.
Bill Prothero

Post Reply