Image control in a Background

Scott Rossi scott at tactilemedia.com
Wed Jun 25 02:59:25 CEST 2014


Vaughn:

I can't tell if you understand the basics of groups/backgrounds, so
apologies if this is redundant for you.

First, try to forget anything Hypercard related and start over.  In fact,
it will probably help you ignore the term "background" and consider groups
only (the terms "group" and "background" are synonymous in most cases).

A group, regardless of what you might associate with the name, can consist
of a single object.  You can group an image for example, and that single
image is now contained within a group object.

The group can exist on one card, or can be placed on multiple cards.  If
the group appears on multiple cards, that same image will appear on all
cards that contain the group.  This implementation is where you can start
using a group as a background object for multiple cards.

LiveCode doesn't have any designated object that automatically sits behind
everything on every card in a stack.  The above mentioned group is how you
create this result.  You create a group, and you *place* that group (as
opposed to paste) on every card where you want the same image to appear.
This is how you display a single image (or any objects) efficiently across
multiple cards.

If you want a different image to appear on every card in your stack, the
most straightforward method is to import or paste an image on every card.
There's no need to use a group.

But using a group can display the images more efficiently, depending on
how you're able to deliver your stack.  If you can include an external
folder of images (JPEGs, for example) along with your stack, you can use
the grouped image option mentioned above and simply change the fileName of
the grouped image to the file path of the external image that is needed
upon opening a card.

The benefit of this method is that only one image is loaded in memory at
any given time, instead of loading all the needed images at once (if they
were all imported into the stack).  The one image still appears on all
cards, but the user only sees one card at a time, and the image is updated
each time the user navigates to a new card.

Last, keep in mind that with groups, "place" is different than "paste".
If you place a group on a card, you are creating an instance of a group
that already exists in the stack.  If you copy and paste a group, you are
creating an entirely new group object with its own id, and you now have
two separate groups in your stack, each with their own contained objects.

Once you get the hang of this, you'll understand that groups are really
useful objects.

Hope this helps.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 6/24/14 3:23 PM, "Vaughn Clement" <vclement at gmail.com> wrote:

>Hi
>
>Your comments:
>
>The "then" is superfluous, so its removal shouldn't affect anything. A
>"then" can only occur at the end of a line that begins with "if". The
>engine must be ignoring the extra "then" because it isn't throwing an
>error. At any rate, you don't need it.
>Question:
>Not new to coding but new to LiveCode scripting, I have a don't ask
>questions approach to code suggestions from other scripters. I've seen a
>lot of odd behavior in scripts within live code. For some a nude live
>code,
>it was nothing like coding I've done before and I go all the way back to
>the first basic on XT computers. It appeared to me that when I removed the
>then from line of script it had an effect on the image control. I am not
>questioning which are telling me, I just found it interesting that it had
>an effect on the way the script ran.
>
>Previously I believe you had the image in a background group with "act
>like
>a background" turned on, which means the same image will appear on every
>card that contains that background. I think you've changed that now by
>turning off "act like a background" or by moving the image out of the
>group. That is why only one card updates now.
> Question:
>I used HyperCard in the old days, and I recognize that live code manages
>backgrounds differently. I have never fully understood the limits about
>background objects and the settings. This is a good example of that where
>a
>group of objects included the image control so that each new card created
>would include the image control. The gray area I have at this point is,
>how
>to manage an image control where it needs to be on each card, but not
>contain the same image when it is edited and replaced on all cards. I
>think
>it's an interesting result that a image control cannot display a different
>image on each new card. I haven't seen this limitation referenced anywhere
>until now in this email. If I read what you're telling me correctly, if I
>include the image control in the group background in acts differently? Is
>it possible to have a image control separate from the group background?
>This would mean I should include a separate image control in its own
>background? And that background settings would be different in that it
>would not act like a background?
>Or, using scripting I would need to address a on closeCard script to
>manage
>what is saved to the image control. These questions may sound naïve, but I
>can imagine that all new users have questions just like this.
>
>The reason you need to leave the card and return in order to see the new
>image content is because you have placed the command in an openCard
>handler, which only triggers when you arrive at the card. Leaving and
>returning to the card will cause an openCard message to be sent, which
>updates the image content.
>Question:
>To be honest, every time I start building a new script to perform a task,
>I
>need to start searching for syntax reference, or examples. Unlike a lot of
>the seasoned developers like my friend John Dixon who can pull scripts out
>of the air, it takes me quite a bit longer to pull together the script
>structure. That being said, that is why I was creating my own app
>dictionary where I could search a word or phrase that would give me script
>structures that could work to perform tasks. I often ponder how seasoned
>developers of liveCode learned liveCode. The answer I get is it just takes
>a long time to learn?
>This doesn't solve the current issue though carrying on a conversation
>about my learning curve.
>So based on your comments in this email, I either need to include in on
>closeCard script, or to change the way the image control works within the
>background.
>Frankly I don't see why standard items like an image control doesn't
>include the ability to save different images in a grouped background. This
>seems to be a logical feature that should be included in the image control
>settings.
>You might be able to tell by my comments that I am clueless as to the next
>step to correct the image control to save different images on each card.
> It appears to me that the reference script data I included in the first
>email is close to what I need to correct the image editing and saving on
>each card? But it would help if you could suggest the next steps I need to
>take to solve the image control issue.
>
>Thank you
>
>Vaughn Clement
>
>Apps by Vaughn Clement (Support)
>*http://www.appsbyvaughnclement.com/tools/home-page/
><http://www.appsbyvaughnclement.com/tools/home-page/>*
>Skype: vaughn.clement
>https://secure.join.me/appsbyvclement
>FaceTime: vclement at gmail.com
>LogMeIn also avaialble
>Call on "ooVoo" at address:  vaughnclement or 9282549062
>Ph. 928-254-9062
>
>
>
>On Tue, Jun 24, 2014 at 2:41 PM, J. Landman Gay <jacque at hyperactivesw.com>
>wrote:
>
>> On 6/24/2014, 10:35 AM, Vaughn Clement wrote:
>>
>>> I am somewhat closer to the solution? I tested the correction that J.
>>> Landman Gay suggested where I remove the "then" at the end of the this
>>> line:  "set the defaultfolder to specialFolderPath ("documents") &
>>> "/photos/" then <--"
>>> This had the effect of not updating the image in any card. When I
>>>added it
>>> back in, the image control will not change all of the cards now, but it
>>> will not update the current image either until I go to a different card
>>> and
>>> return to find the image then updated to the correct image.
>>>
>>
>> The "then" is superfluous, so its removal shouldn't affect anything. A
>> "then" can only occur at the end of a line that begins with "if". The
>> engine must be ignoring the extra "then" because it isn't throwing an
>> error. At any rate, you don't need it.
>>
>> Previously I believe you had the image in a background group with "act
>> like a background" turned on, which means the same image will appear on
>> every card that contains that background. I think you've changed that
>>now
>> by turning off "act like a background" or by moving the image out of the
>> group. That is why only one card updates now.
>>
>> The reason you need to leave the card and return in order to see the new
>> image content is because you have placed the command in an openCard
>> handler, which only triggers when you arrive at the card. Leaving and
>> returning to the card will cause an openCard message to be sent, which
>> updates the image content.
>>
>>
>> --
>> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
>> HyperActive Software           |     http://www.hyperactivesw.com
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at 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 at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list