setting backgound image (as a decoration)

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: setting backgound image (as a decoration)

Post by dunbarx » Fri Nov 08, 2013 10:05 pm

Chris.

I am going to be 63 soon. I do not get exhausted teaching LC. I will dance on your grave.

If you have a card with a group that has its backgroundBehavior set to "true", and you create a new card, that group will appear on the new card.

If you "place" such a group on a card somewhere in the stack, and this could be anywhere, that group appears on that card. You can place that group on a card in the middle of the deck, so to speak. Or on all cards.

Those two scenarios can be used together or not, but they act exactly as individually described, and are merely tools in that toolbox I spoke about.

And I guess I must apologize again. I spoke recently about you being a bit ahead of yourself. You are becoming proficient in certain ways, but still do not know how to drive. It never occurred to me that you would try to find "superPlace" in the dictionary. That is a custom command I made up. I should have named it "superDuperHyperPlace", and then you would have known that I was being flip, if not humorous, but still only trying to demonstrate a point.

Now reread my post. A magic "superPlace" command really cannot easily exist the way you indicated it ought to. The real point was that the toolbox can do anything, but prepackaged mental gadgets may not be implementable. This is actually a good thing. You can build your own tools.

You will be fine. You have the fire.

Craig
Last edited by dunbarx on Fri Nov 08, 2013 11:35 pm, edited 1 time in total.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: setting backgound image (as a decoration)

Post by Dixie » Fri Nov 08, 2013 10:17 pm

Jacque...

You are quite right in what you say... I just wonder sometimes how much you throw at someone who is going through the 'learning period'... the accumulation of graphics crossed my mind but I was really just interested in getting what Chris in Cork wanted to get working rather than worrying about bloat at that moment... too much all at once is usually a bad thing... Well, that's what I tell myself after a night in the 'local' pub... :D

Dixie

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: setting backgound image (as a decoration)

Post by chris25 » Fri Nov 08, 2013 10:27 pm

I am going to be 63 soon. I do not get exhausted teaching LC. I will dance on your grave. "Can you swim? I want to be buried at sea....." :D

If you have a card with a group that has its backgroundBehavior set to "true", and you create a new card, that group will appear on the new card.

If you "place" such a group on a card somewhere in the stack, and this could be anywhere, that group appears on that card. You can place that group on a card in the middle of the deck, so to speak. Or on all cards.
Hi craig, I realize all this - really I do, and I have been messing around with that place command since yesterday and reading everything about shared groups and background behaviours. I even watched a stack presentation from a conference in 2005 called backgrounds and groups, I have groupies coming out of my ears and I'm drinking coded coffee all day long. BUT...yes I am sorry, BUT not even in that stack tutorial, which is VERY good, was one mention made of placing a group on a card and having it treated as a shared group throughout all the other cards AFTER you had already created so many cards. I have TWO methods by which I have succeeded in accomplishing this - 1. Object drop down menu and place group and then 2. copy paste via Dixies method and hide the button afterwards. But to do it via a place command written into a specific card I can not do. Nothing I have tried makes my after the fact group appear on every card. Simple.
Kindest regards
chris

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

Re: setting backgound image (as a decoration)

Post by Klaus » Fri Nov 08, 2013 10:43 pm

Hi Chris,

COPYING groups to other cards may is not very effective since:
1. it will bloat the filesize unneccessarily
2. If you want to change something e.g use another image, you will need to change ALL copies of the group!
So PLACE-ing is the way to go!

Add this to any button in your stack where you want to play your group,
Please replace "background image" in the script with the name of YOUR group! 8)

Code: Select all

on mouseUp
   
   ## Loop through all cards in the stack, NO other way/syntax possible!
   repeat with i = 1 to the num of cds
      
      ## Trying to place an already placed group onto a card 
      ## will cause an ERROR, so we check before we place!
      if there is a grp "background image" of cd i then
         next repeat
      end if
      
      ## Now place background
      place bg "background image" onto cd i
   end repeat
   
   ## Optional :-)
   answer "Done!" & CR & "Don't forget to save the stack!"
end mouseUp
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: setting backgound image (as a decoration)

Post by dunbarx » Fri Nov 08, 2013 11:07 pm

Klaus.

I am old and exhausted.

I never knew til just now that "num" was a synonym for "number". Wait til I tell Chris.

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: setting backgound image (as a decoration)

Post by chris25 » Fri Nov 08, 2013 11:47 pm

Hi Klaus, as you can see it works and yet it does not. I actually had this same problem earlier. I tried placing the background onto multiple cards at once through your code as well but does not do it. I had these same error messages earlier and tried fixing them but my knowledge is far too limited at the moment. Basically I have to keep changing the syntax manually and cycle through the card numbers by typing in each successive number. this is fine I suppose, but it keeps dishing up the error, I know it is because every time the group is placed it then thinks, AH a group, it is already here, yet it just placed it on the card. a milliseciond before.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: setting backgound image (as a decoration)

Post by dunbarx » Sat Nov 09, 2013 12:25 am

Chris.

Klaus' script runs fine. There is something in your setup.

Make a new stack. Make a few new cards. Go back to cd 1.

Make a button, name it "Place", and put Klaus' handler into its script. Make another button, group it and name it "background image".

Click the button "place". The group will appear on all cards. Can you find the difference in your test?

Craig

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: setting backgound image (as a decoration)

Post by chris25 » Sat Nov 09, 2013 10:14 am

Well then my setup is right up the creek, though I fiddled with various little setups, the errors keep rolling in and the cards keep staying empty. No need to respond - I'm a bit fed up with this ridiculous nonsense after two days where everybody elses' code seems to work except mine. It only tells me that there are other things going on that have nothing to do with the script and what ever it is is well hidden. Soething that others take for granted as being obvious but for a beginner is unknown.

I'm going back to coding my switch controls and random maths and collisions where the environment responds to logical sequential thinking! :roll:

Klaus, I will save your script and maybe in a year I might comeback to it and it might be an ahhhhhh moment. thankyou for posting your examples.

Until then it is
on mouseUp
dixie
end mouseUp

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

Re: setting backgound image (as a decoration)

Post by Klaus » Sat Nov 09, 2013 12:28 pm

Hi Chris,

you need to be more careful with your scripts, to say the least, and read them up again when an error pops up! 8)

In the last but one script you wrote this in the repeat loop:
...
place bg "img" onto cd 3 ## THREE!
...
But should of course read:
...
place bg "img" onto cd i
...

In the last script you forgot to change my example group name "background image" to YOUR group name "img",
so the IF clause reported FALSE of course, since there IS NO GROUP "background image" AT ALL in your stack!


Best

Klaus

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: setting backgound image (as a decoration)

Post by chris25 » Sat Nov 09, 2013 2:48 pm

ok TWO things: Firstly it works now. Secondly, I had changed the scripts so many times and changed so much that the last script I copied I should not have posted because that was the last thing I did of 20 things I changed.

Thirdly, I found the original problem and this is where I screamed: It was the project Browser's fault. Yes let me say that again the project browser. When I employed Dixies technique, the project browser window changed on the fly - its arrows turned downwards and revealed all the new images. When I added your code - the original code again, and started completely afresh, I then accessed all the arrows and was numbed to see that everything had worked. Sometimes the project browser updates on the fly, and sometimes it does not, sometimes when I change a card window name the project browser does not update the name unless I click a few things randomly and then come back - this happens only seldom. So all this time the original code was working and I was missing it. Although I pointed all the arrows DOWN before I clicked on the button to add all background stuff they did not reveal anything until I clicked up and then back down again and then all the images appeared. This does not always happen - this is not a constant problem, but on this occasion for some reason that did happen, it was only by chance that I clicked up and then down again and good job I did. I told you the problem was hidden.... :)

Yes that was three things I know - it's called stress.

Kindest regards
chris

I should really add a positive note - that I have actually learned a few extra things as a result of all this, so the cunundrum has not been a wasted time at all.

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

Re: setting backgound image (as a decoration)

Post by Klaus » Sat Nov 09, 2013 2:57 pm

Hi Chris,

a mean project browser, up or down buttons, stress, whatever,
you had some blatant oversights in the scripts you posted here
and I just wanted to allude you to them 8)


Best

Klaus

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

Re: setting backgound image (as a decoration)

Post by Klaus » Sat Nov 09, 2013 3:48 pm

Chris,

maybe you are trying to think too "computerish" and do not see the logics behind all this!
Try to explain a similar "real world" problem to a guy with no brain, but a good memory :D

After that you can almost translate the logics 1:1 to Livecode, see my example below,
which is an analogy to the background problem, besides the fact that we cannot have
the SAME vase of flowers in every room like we can do with bgs in Livecode :D

Task:
In your house with X rooms (stack, num of cards) put a vase of fresh flowers onto
every table in every room, UNLESS there is not already a vase with fresh flowers in that room.

Neccessary steps:
1. Go into every room, start with room 1

Code: Select all

repeat with i = 1 to the num of cds
2. Check if there is already a vase with fresh flowers on the table of the current room
If there already IS ONE, THEN go to the next room

Code: Select all

if there is a grp "img" then
  next repeat
end if
3. NO vase yet, put one onto table

Code: Select all

place bg "img" onto this cd
4. Finished after last room

Code: Select all

end repeat
That's it! :D


Best

Klaus

chris25
Posts: 354
Joined: Tue Oct 08, 2013 9:32 pm

Re: setting backgound image (as a decoration)

Post by chris25 » Sat Nov 09, 2013 8:13 pm

I accept the critique Klaus with a slap on the wrist. You are right, a bit of screen tiredness played on me this time (not making excuses) well maybe a little excuse, but seriously Thankyou and I shall keep a watchful eye on 'nauwkeurigheid' (is it the same in German)?
regards
chris

Post Reply