Set background image of stack

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
shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Set background image of stack

Post by shawnblc » Thu Jun 12, 2014 3:25 am

I'm trying to do this of which neither work. Obviously, I'm not doing it quite right ;) Any help is very much appreciated. Just more practicing.

Code: Select all

set the backgroundImage of this stack to "http://domain.com/image.jpg"
Also tried this:

Code: Select all

put url "http://domain.com/image.jpg" into tImage
set the backgroundImage of this stack to tImage

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10053
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Set background image of stack

Post by FourthWorld » Thu Jun 12, 2014 4:01 am

Searching the Dictionary for "backgroundImage" turned up empty, but along the way I found "backgroundPattern" which may be what you're looking for.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: Set background image of stack

Post by shawnblc » Thu Jun 12, 2014 4:28 am

Found this that helped.
http://lessons.runrev.com/m/4603/l/44144-using-images

Not exactly how I wanted to do it, but it'll work.

Richard, thanks for the post, but I couldn't get it to work.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Set background image of stack

Post by sefrojones » Thu Jun 12, 2014 4:37 am

Are you familiar with a groups ability to "Behave like a background"?

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: Set background image of stack

Post by shawnblc » Thu Jun 12, 2014 4:50 am

sefrojonesGAda40 wrote:Are you familiar with a groups ability to "Behave like a background"?
I've read about it in the paste, but haven't yet made a stack to try it out. Any advice or tips appreciated.

In my spare time I try and learn as much as I can. Wish I could spend more time with LC though.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Set background image of stack

Post by sefrojones » Thu Jun 12, 2014 5:20 am

So I made this example of background groups. First, I made all the controls and grouped them. I then opened the property inspector for that group and checked "Behave like a background" Then I put the script at the stack level. The stack starts with only 1 card, but as you add new cards you can see that the controls in the group that is behaving like a background are available on every new card. I also put a button to change the image, the command is in the stack script. It doesn't handle any re-sizing or anything, but as you change the background image, it will be changed on every card. Sorry if this isn't the clearest explanation, but hopefully this helps. From your original post it seems like you wanted to load a background image from URL, I think this example might do that.....

--Sefro

edit: I just re-uploaded the stack with a useless line removed....
Attachments
BackgroundGroup.zip
(1.15 KiB) Downloaded 264 times
Last edited by sefrojones on Thu Jun 12, 2014 5:23 am, edited 2 times in total.

shawnblc
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 342
Joined: Fri Jun 01, 2012 11:11 pm

Re: Set background image of stack

Post by shawnblc » Thu Jun 12, 2014 5:22 am

Thanks I'll check it out.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Set background image of stack

Post by bn » Thu Jun 12, 2014 5:27 am

Hi Shawn,

to use a BackgroundPattern do like this:

try this in a new stack with one image (just drag an image object onto the card), hide the image, and one button with this script

Code: Select all

on mouseUp
   put "http://runrev.com/wp-content/uploads/2013/04/Gracemount-Girls-LiveCoding-slim.jpg" into tPath
   put url (tPath) into tImage
   put tImage into image 1
   set the backgroundPattern of this card to the short id of image 1
end mouseUp
It should give you a backgroundPattern with this image.
Now that image is rather large and you will only the topLeft part of the image, enlarge the stack to see more of the image.

You will notice that the image will repeat itself since it is a "pattern" So if you want to fill the background of your card you will have to either enlarge the image in case it is to small or adapt the size of your stack to the image. Or choose an image that fits your card etc.

Kind regards
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Set background image of stack

Post by [-hh] » Thu Jun 12, 2014 1:43 pm

..........
shiftLock happens

Post Reply