I have done a lot of VB in yesteryear, but moved now to Xojo.
The pdf book gives this instruction
“Add a property to the window: mypic as picture”
Add it? Sure - where? How?
Currently I have a button with this code
dim f as folderitem
dim d as opendialog
dim mypic as picture
d = new opendialog
f = d.showmodal()
if f <> nil then
mypic = picture.open(f)
canvas1.invalidate
end if
I also have canvas1 with this code
if mypic <> nil then
g.drawpicture(mypic,10,10)
end if
But I get an error … for “mypic” as “This item does not exist”
I am presuming that my lack of “Add a property to the window: mypic as picture” is the problem. Where do I put that code? Talk me through it, please!
I am making a game for some very young Chinese children … I will have many pictures and I’ll need the frame to size to the picture … all the pictures being different sizes. Is this the way to go?
bear in mind you need to be aware of the SCOPE of things (this was required in VB as well)
you DIM “myPic” in your BUTTON… therefore the scope is that of “the button”
so Canvas1 has no clue what “myPic” is
therefore myPic needs to be Dim’d in a scope higher than either button or canvas… Window might be the correct place…
although if myPic is to be used on an even more global scope, then in a Module would be better
You add a property, set its type (integer, string, structure, picture, etc.). It could be a window property, an app property, a session property (in a web app), a container control property… it all depends on where in your app you want to be able to use the property. (@Dave S gave you a way to add a property to a window, in a prior post in the thread.)
Once you have the property, you initialize it by assigning an appropriate value to it.
Hey! we all started one day. Soon, you will be answering questions too!
I would recommend highly that you read the tutorials in your Documentation folder (look under Xojo in your start menu). These documents and the Quickstart documents contain a lot of nice little tips that will make your life easier.