That's worth saving in my Livecode Keepers! Someday I am going to make a stack of this stuff!
Bob On Apr 1, 2011, at 10:09 AM, J. Landman Gay wrote: > On 4/1/11 11:14 AM, J. Landman Gay wrote: >> >> Since you are taking snapshots of other cards and the "preopen" is for >> the control, I'm not sure you need to wait for the control to load. I >> think the issue is the ID of the icon. >> > > I just tried the handler you posted and there's more wrong than just the icon > ID. > > on preOpenControl > import snapshot from the rect of card "Example" > set the icon of me to it > end preOpenControl > > It might be a typo, but the first line will error without the "rect" keyword: > import snapshot from rect (the rect of cd "example"). Also, snapshots use > the 0,0 point of the monitor (not the stack) for coordinates when dealing > with cards, so the rect of a card will result in the snapshot containing the > top left portion of whatever's on the monitor at that position. You'll need > to translate the coordinates from global to local coords. You can either do > that using the globalloc function or you can just use the rect of the stack > instead of the rect of the card. The second method won't always work if you > have a menubar on a Mac (which makes the stack shorter than the card.) > > After either an import or an export, the "it" variable is not given a value, > so it becomes the string literal "it". You can't set an icon to a string > literal, you need an ID number. > > While you can take snapshots of objects that aren't open, you can't take them > of cards that aren't open. Cards are not objects. I was unable to get a > snapshot of another card unless I went there first. This did work: > > on test > get the rect of this cd > put globalloc(item 1 to 2 of it) into tRect > put globalLoc(item 3 to 4 of it) into item 3 to 4 of tRect > go cd 2 > import snapshot from rect tRect > go back > set the icon of me to the short id of last img of cd 2 > end test > > The "export snapshot" offers more options. You can export a snapshot to a > variable and then put that variable into an image object. However, I was > still unable to get a snapshot without going to the card. This works: > > on test2 > lock screen > go cd 2 > export snapshot from cd 2 to tVar as JPEG > go back > unlock screen > create img "iconImg" > set the text of img "iconImg" to tVar > set the icon of me to the short id of img "iconImg" > end test2 > > -- > Jacqueline Landman Gay | jac...@hyperactivesw.com > HyperActive Software | http://www.hyperactivesw.com > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode