Image control in a Background

classic Classic list List threaded Threaded
36 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Image control in a Background

Vaughn Clement
Hi All

I asked this question recently and I did not get any responses.

I have a substack with a background group where there is an Image Control
is being populated using the

mobilePickPhoto "library"

The image is added to the control correctly and displays, but if I leave
the card and return the image is gone.

To solve this the image is stored in the folder on in the app as per this
script:


*on* mouseUp

   /* the image from mobilePickPhoto uses the template image construct

   set it off screen so we don't see ift flash */

   *set* the loc of the templateImage to -10000,-10000

   /*choose a photo*/

   mobilePickPhoto "library"

   *lock* screen

   *if* the result <> "cancel" *then*

      /* make the filepath to save the chosen image*/

      *put* specialFolderPath("documents") & "/photos/" & the short ID of
this card into thePath

      /* put the image into a file in the photos folder */

      *put* the text of the last image of this card into URL("binfile:" &
thePath)

      /*set the loc of image 1 to the loc of group "picgroup' so it will
align*/

      *--set the loc of  image "imageField1" to the loc of group "picgroup"*

      /* show the image on the card */

      *set* the filename of image "ImageField1" of this card to thePath

      /* destroy the image imported from the library */

      *delete* the last image of this card

   *end* *if*

*end* mouseUp

The image control is supposed load when the card opens and the last photo
is to be displayed?


*on* openCard

   *set* the defaultfolder to specialFolderPath ("documents") & "/photos/"

   *--answer the files*

   *if* the number of this card >1 *then*

      *set* the defaultfolder to specialFolderPath ("documents") &
"/photos/" *then*

         *if* there is a file the short id of this card *then*

            *put* specialFolderPath ("documents") & "/photos/" & the short
ID of this card into thePath

            *set* the filename of image "imegeField1" of this card to
thepath

         *end* *if*

      *end* *if*

*end* openCard

Several different changes were tried and the image still will not load into
the card as scripted above.


Can anyone reference the information or see what might cause this 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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

J. Landman Gay
On 6/20/2014, 10:23 AM, Vaughn Clement wrote:

> The image control is supposed load when the card opens and the last photo
> is to be displayed?
 >

> *on*  openCard
>
>     *set*  the defaultfolder to specialFolderPath ("documents") & "/photos/"
>
>     *--answer the files*
>
>     *if*  the number of this card >1*then*
>
>        *set*  the defaultfolder to specialFolderPath ("documents") &
> "/photos/"*then*
>
>           *if*  there is a file the short id of this card*then*
>
>              *put*  specialFolderPath ("documents") & "/photos/" & the short
> ID of this card into thePath
>
>              *set*  the filename of image "imegeField1" of this card to
> thepath
>
>           *end*  *if*
>
>        *end*  *if*
>
> *end*  openCard


Is this a direct copy/paste? This line is malformed:

  set the defaultfolder to specialFolderPath ("documents") & "/photos/"
then <--

Remove the trailing "then". Also, the image name is misspelled as
"imegeField1" ("e" rather than "a") which is more likely the reason for
the problem.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Simon
In reply to this post by Vaughn Clement
Hi Vaughn,
Aside from a spelling mistake just add parentheses around all the folder paths
e.g.
 put (specialFolderPath("documents") & "/photos/" & the short ID of this card) into thePath

and then delete the current filename
on mouseUp
   --/ the image from mobilePickPhoto uses the template image construct
   --set it off screen so we don't see ift flash /
   set the loc of the templateImage to -10000,-10000
    set the filename of image "imageField1" of this card to  ""

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi

Thanks for the help, my dyslectic eyes are subject to misspelling and not
even able to see the error. Great for scripting right! I've lived with it
all my life?

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Fri, Jun 20, 2014 at 12:16 PM, Simon <[hidden email]> wrote:

> Hi Vaughn,
> Aside from a spelling mistake just add parentheses around all the folder
> paths
> e.g.
>  put (specialFolderPath("documents") & "/photos/" & the short ID of this
> card) into thePath
>
> and then delete the current filename
> on mouseUp
>    --/ the image from mobilePickPhoto uses the template image construct
>    --set it off screen so we don't see ift flash /
>    set the loc of the templateImage to -10000,-10000
>     set the filename of image "imageField1" of this card to  ""
>
> Simon
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680559.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
In reply to this post by Simon
Hi Simon

I found the following in the dictionary:

iOS Note: iOS imposes strict controls over what you can and cannot access.
Each application in iOS is stored in its own 'sandbox' folder (referred to
as the home folder). An application is free to *read* and *write* files
within this folder and its descendants, but it is not allowed to access
anything outside of the 'sandbox'.


*Examples: *

specialFolderPath("Preferences")


set the defaultFolder to specialFolderPath("desktop")


put specialFolderPath("asup") into appSupportFolder


put url ("file:" & specialFolderPath("engine") & slash & "foo.txt") into
tFileContents


set the folder to specialFolderPath("engine") & slash & "myimages"

put the files into tMyImages



Use the *specialFolderPath* function to place preferences in the
Preferences folder, save files to the Documents folder, find out which
files are installed in the System or Fonts folders, and so on.

*Parameters:*

folderIdentifier - One of the items below.


******** When I edit the script to add the " EXAMPLE; put url ("file:" &
specialFolderPath("engine") & slash & "foo.txt") into tFileContents

 the script gives and error.

*************
J. Landman Gay
I edited the spelling error, and the image is now retained in the group
image control for the card it was added too. The problem is all of the
cards now have the same image that was added on the first card? The image
on each card background needs to retain the one that was added on that
card. Is the a setting or a script 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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Fri, Jun 20, 2014 at 12:16 PM, Simon <[hidden email]> wrote:

> Hi Vaughn,
> Aside from a spelling mistake just add parentheses around all the folder
> paths
> e.g.
>  put (specialFolderPath("documents") & "/photos/" & the short ID of this
> card) into thePath
>
> and then delete the current filename
> on mouseUp
>    --/ the image from mobilePickPhoto uses the template image construct
>    --set it off screen so we don't see ift flash /
>    set the loc of the templateImage to -10000,-10000
>     set the filename of image "imageField1" of this card to  ""
>
> Simon
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680559.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi

I am trying to understand the usage of a image control when it is used in a
group background:

The issue: when I add a image from the IOS library to the BG image control
in the background it replaces the current card image and all other images
in all card backgrounds in the stack that uses that image control.

So, here is my question; when I set the special folder path and the card id
and put the last image in the control of that card ID on openCard, why
would it replace all of the images in all of the cards?
- Is there a special way to Set the image from the Photos folder in the
script?
- Can the image control be used in a group background?
- It was suggested to use a custom property to set the image for the image
control. But, I cannot find any examples of where to script the custom
control for this purpose.
- I read about the custom control, searched the dictionary, viewed all of
the RunRev lessons on using the image control, and the User Guide, the IOS
reference document. I still have not found the answer to the issue I need
to solve.

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Sat, Jun 21, 2014 at 5:41 PM, Vaughn Clement <[hidden email]> wrote:

> Hi Simon
>
> I found the following in the dictionary:
>
> iOS Note: iOS imposes strict controls over what you can and cannot
> access. Each application in iOS is stored in its own 'sandbox' folder
> (referred to as the home folder). An application is free to *read* and
> *write* files within this folder and its descendants, but it is not
> allowed to access anything outside of the 'sandbox'.
>
>
> *Examples: *
>
> specialFolderPath("Preferences")
>
>
> set the defaultFolder to specialFolderPath("desktop")
>
>
> put specialFolderPath("asup") into appSupportFolder
>
>
> put url ("file:" & specialFolderPath("engine") & slash & "foo.txt") into
> tFileContents
>
>
> set the folder to specialFolderPath("engine") & slash & "myimages"
>
> put the files into tMyImages
>
>
>
> Use the *specialFolderPath* function to place preferences in the
> Preferences folder, save files to the Documents folder, find out which
> files are installed in the System or Fonts folders, and so on.
>
> *Parameters:*
>
> folderIdentifier - One of the items below.
>
>
> ******** When I edit the script to add the " EXAMPLE; put url ("file:" &
> specialFolderPath("engine") & slash & "foo.txt") into tFileContents
>
>  the script gives and error.
>
> *************
> J. Landman Gay
> I edited the spelling error, and the image is now retained in the group
> image control for the card it was added too. The problem is all of the
> cards now have the same image that was added on the first card? The image
> on each card background needs to retain the one that was added on that
> card. Is the a setting or a script 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: [hidden email]
> LogMeIn also avaialble
> Call on "ooVoo" at address:  vaughnclement or 9282549062
> Ph. 928-254-9062
>
>
>
> On Fri, Jun 20, 2014 at 12:16 PM, Simon <[hidden email]> wrote:
>
>> Hi Vaughn,
>> Aside from a spelling mistake just add parentheses around all the folder
>> paths
>> e.g.
>>  put (specialFolderPath("documents") & "/photos/" & the short ID of this
>> card) into thePath
>>
>> and then delete the current filename
>> on mouseUp
>>    --/ the image from mobilePickPhoto uses the template image construct
>>    --set it off screen so we don't see ift flash /
>>    set the loc of the templateImage to -10000,-10000
>>     set the filename of image "imageField1" of this card to  ""
>>
>> Simon
>>
>>
>>
>> --
>> View this message in context:
>> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680559.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Simon
Hi Vaughn,
Did you get this sorted out?
> ******** When I edit the script to add the " EXAMPLE; put url ("file:" &
> specialFolderPath("engine") & slash & "foo.txt") into tFileContents
foo.txt has to be in the Copy Files of the standalone settings. (We're talking mobile right?)

"...why would it replace all of the images in all of the cards?"
if it's in a group who's "behave like background" it true then that's what happens to all the cards that group was placed on.

"- Can the image control be used in a group background?"
Yes, if it's the lowest layer control. Since you create a new image from the templateImage it's the top control.  
Not sure on how you have things set up but I think you should be saving the last image to the documents folder and set the filename of the image already in the group to that name then "delete last image". Ah wait.. since it's a standalone the last image wont be saved anyways so no need to delete.

"- Is there a special way to Set the image from the Photos folder in the script?"
You'll have to copy the image over to specialFolderPath("documents") and read it from there.

Maybe I'm misunderstanding all this.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
In reply to this post by J. Landman Gay
Hi

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 script now
does not change all of the cards, it just does not update while the image
control is being edited. As I found out the update only occurs after I
return to the edited card. It seems that the script is not making the image
control update at the time of the edit. Can you suggest a correction?

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Fri, Jun 20, 2014 at 12:13 PM, J. Landman Gay <[hidden email]>
wrote:

> On 6/20/2014, 10:23 AM, Vaughn Clement wrote:
>
>  The image control is supposed load when the card opens and the last photo
>> is to be displayed?
>>
> >
>
>> *on*  openCard
>>
>>     *set*  the defaultfolder to specialFolderPath ("documents") &
>> "/photos/"
>>
>>     *--answer the files*
>>
>>     *if*  the number of this card >1*then*
>>
>>        *set*  the defaultfolder to specialFolderPath ("documents") &
>> "/photos/"*then*
>>
>>           *if*  there is a file the short id of this card*then*
>>
>>              *put*  specialFolderPath ("documents") & "/photos/" & the
>> short
>>
>> ID of this card into thePath
>>
>>              *set*  the filename of image "imegeField1" of this card to
>> thepath
>>
>>           *end*  *if*
>>
>>        *end*  *if*
>>
>> *end*  openCard
>>
>
>
> Is this a direct copy/paste? This line is malformed:
>
>  set the defaultfolder to specialFolderPath ("documents") & "/photos/"
> then <--
>
> Remove the trailing "then". Also, the image name is misspelled as
> "imegeField1" ("e" rather than "a") which is more likely the reason for the
> problem.
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

J. Landman Gay
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         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
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: [hidden email]
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 <[hidden email]>
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         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

ScottR
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" <[hidden email]> 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: [hidden email]
>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 <[hidden email]>
>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         |     [hidden email]
>> HyperActive Software           |     http://www.hyperactivesw.com
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>_______________________________________________
>use-livecode mailing list
>[hidden email]
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Simon
In reply to this post by Vaughn Clement
Hi Vaughn,
First off
"The answer I get is it just takes a long time to learn?"
No, but I understand that if you have been a programmer using another language then it is more difficult.  Lots of times I just think of a word to describe what I want to do and there it is in the dictionary.
This plugin helps things even further;
http://bjoernke.com/?target=bvgdocu

Now to the problem at hand.
To make things clear when you say "...group background..." you mean a group who's "background behavior is set to true" and in that case if the image control is in that group it will be the same on all pages with that group.

Now you could continue doing it the way you have it setup in your openCard script and in the mouseUp, just make sure to;
 set the filename of image "imageField1" of this card to  ""  ("" is shorthand for empty)
Where I mention it in the above post.
Trust me I had your script running with only removing the "then" correcting the spelling and that line.

Now I'm not sure what impact on performance of using it when all the images get updated but it probably doesn't matter as I think the things like that are only set when the card opens.
If it does then yes, you have to break the image out of the group.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi Simon

Very interesting link you included.
The stack is another great reference material that is undocumented. It only
took me about three minutes to understand what he was trying to accomplish
here. I did a version similar to this in FileMaker while back so that I
could do quick searches by a word or phrase to  find answers to my
scripting tasks. I offered it to of the developers not knowing that this
stack was available.
This is the kind of thing that needs to be developed and updated by LC for
all developers. I have an issue with LC in that they want to sell
instruction at pretty high cost when it should be included in the product
documentation. I understand they're trying to use this to raise capital to
keep the business running, but it also doesn't help to retain new users who
struggle to learn live code and to afford the expensive instructional
content offered by LC. The latest example was a summer school. I'm not
saying that this is not good for people that have in less money to spend.
Most new developers simply can't afford to spend hundreds if not thousands
of dollars a year to learn LC.  For example; Apple just released a new
programming language for Xcode swift, and they supplied a 600 page PDF
document defining how to use swift to design ISO apps. In addition to that
they have an online help system that has heaps of technical assistance
available to all users. One caveat about the help is that it does include
developer support for general questions at no cost. They also include many
PDFs and instructional videos. Obviously the user base is a lot larger than
live code, but if you're going to provide a product like live code at a
minimum you need to provide adequate instructional media. Looking at the
how-to forum is clear that there are endless questions by developers but
cannot find the proper instructional media.
Enough preaching most new developers understand by now the shortfall in
instructional media.

I just answered Scott Rossi's email that describes the issue, and some
questions and comments. Please refer to that in this how-to email.

Your comment:
Now you could continue doing it the way you have it setup in your openCard
script and in the mouseUp, just make sure to;
 set the filename of image "imageField1" of this card to  ""  ("" is
shorthand for empty)
Where I mention it in the above post.
Trust me I had your script running with only removing the "then" correcting
the spelling and that line.

 Please clarify why this line is used: set the filename of image
"imageField1" of this card to  ""  ("" is
shorthand for empty)

 Where in the script are you using this to empty the image control. And why
would you empty the image control? Sorry for the novice question, but not
to ask the question doesn't help to get the answer.

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Tue, Jun 24, 2014 at 6:03 PM, Simon <[hidden email]> wrote:

> Hi Vaughn,
> First off
> "The answer I get is it just takes a long time to learn?"
> No, but I understand that if you have been a programmer using another
> language then it is more difficult.  Lots of times I just think of a word
> to
> describe what I want to do and there it is in the dictionary.
> This plugin helps things even further;
> http://bjoernke.com/?target=bvgdocu
>
> Now to the problem at hand.
> To make things clear when you say "...group background..." you mean a group
> who's "background behavior is set to true" and in that case if the image
> control is in that group it will be the same on all pages with that group.
>
> Now you could continue doing it the way you have it setup in your openCard
> script and in the mouseUp, just make sure to;
>  set the filename of image "imageField1" of this card to  ""  ("" is
> shorthand for empty)
> Where I mention it in the above post.
> Trust me I had your script running with only removing the "then" correcting
> the spelling and that line.
>
> Now I'm not sure what impact on performance of using it when all the images
> get updated but it probably doesn't matter as I think the things like that
> are only set when the card opens.
> If it does then yes, you have to break the image out of the group.
>
> Simon
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680627.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Simon
Here:
"on mouseUp
   --/ the image from mobilePickPhoto uses the template image construct
   --set it off screen so we don't see ift flash /
   set the loc of the templateImage to -10000,-10000
    set the filename of image "imageField1" of this card to  "" "

Now as to why that works I didn't test if it was a screen refresh problem which is what it appears to be.  The test would have been to throw in a "wait 1 (or can it be 0?) milliseconds with messages" into that script.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi Simon

If you read the reply to Scott you will see the full description of the
solution I am trying to come up with.

On Wednesday, June 25, 2014, Simon <[hidden email]> wrote:

> Here:
> "on mouseUp
>    --/ the image from mobilePickPhoto uses the template image construct
>    --set it off screen so we don't see ift flash /
>    set the loc of the templateImage to -10000,-10000
>     set the filename of image "imageField1" of this card to  "" "
>
> Now as to why that works I didn't test if it was a screen refresh problem
> which is what it appears to be.  The test would have been to throw in a
> "wait 1 (or can it be 0?) milliseconds with messages" into that script.
>
> Simon
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680632.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email] <javascript:;>
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

J. Landman Gay
In reply to this post by Vaughn Clement
On 6/25/2014, 9:56 AM, Vaughn Clement wrote:

> Very interesting link you included.
> The stack is another great reference material that is undocumented.

The User Guide is often overlooked. A pretty good explanation of groups
and backgrounds, and their differences and behavior, begins on page 107
of the guide. The User Guide can be accessed from either the Help menu
or from the Resources icon in the toolbar.

>   Please clarify why this line is used: set the filename of image
> "imageField1" of this card to  ""  ("" is
> shorthand for empty)
>
>   Where in the script are you using this to empty the image control. And why
> would you empty the image control?

This may be superstitious behavior based on an occasional delay when
loading multimedia into player objects. In a player, it is sometimes
necessary to set the filename to empty before resetting it to a
different video. But for image objects it isn't needed, and you can omit
that instruction.

I have a stack that does exactly what you're doing; it loads a different
image into a grouped image object every time the card changes. It works
fine by just replacing the content with a new image.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Simon
Hi Jacque,
"But for image objects it isn't needed, and you can omit that instruction."
Actually it was the only way to get the script to work on mobile when I actually put it on my device.
You are correct in that aside from the small errors the code should run perfectly.  I figured it had something to do with coming out of the photo library.

The first time you add/change the photo it works as it should but if you decide that you don't like that photo and try to change it then it gets all frumpy and throws all it's toys out of the cradle -set the filename of image "imageField1" of this card to  ""- does the trick.

One other improvement I found
set the loc of the templateImage to -10000,-10000
Makes it very slow in coming out of the photo library
set the vis of the templateImage to false
Is much much faster. Both of these things are mobile related only.

Or... it's just me.

Simon
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi

So many great suggestions, I am pleased to see the variety of solutions.
Scott pointed out that LC has many ways to be coded and it is the designers
choice. Now I need to finish testing to see if I can get the desired result.

I have a lot to consider and to try each suggestion to see what works best.

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Wed, Jun 25, 2014 at 2:51 PM, Simon <[hidden email]> wrote:

> Hi Jacque,
> "But for image objects it isn't needed, and you can omit that instruction."
> Actually it was the only way to get the script to work on mobile when I
> actually put it on my device.
> You are correct in that aside from the small errors the code should run
> perfectly.  I figured it had something to do with coming out of the photo
> library.
>
> The first time you add/change the photo it works as it should but if you
> decide that you don't like that photo and try to change it then it gets all
> frumpy and throws all it's toys out of the cradle -set the filename of
> image
> "imageField1" of this card to  ""- does the trick.
>
> One other improvement I found
> set the loc of the templateImage to -10000,-10000
> Makes it very slow in coming out of the photo library
> set the vis of the templateImage to false
> Is much much faster. Both of these things are mobile related only.
>
> Or... it's just me.
>
> Simon
>
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Image-control-in-a-Background-tp4680553p4680640.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

J. Landman Gay
In reply to this post by Simon
That's good to know.  My app is desktop only and it must be different there.  Thanks for the heads up.

On June 25, 2014 4:51:44 PM CDT, Simon <[hidden email]> wrote:
>Hi Jacque,
>"But for image objects it isn't needed, and you can omit that
>instruction."
>Actually it was the only way to get the script to work on mobile when I
>actually put it on my device.
--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Image control in a Background

Vaughn Clement
Hi

This morning I did some testing to address the image updating in the
current card in the image control and did not come up with a solution that
worked.

I have the On OpenCard script that is working to add the image to the image
control, and as before the on OpenCard script cannot update the image field
in the open card because the script has already triggered.

I tried to use a button on the card to refresh the image field to display
the last edited image, but everything I tried had no effect?
I tried to have the image assigned to the card id to reload using this in
the button:

*on mouseUp*

*if* the number of this card >1 *then*

      *set* the defaultfolder to specialFolderPath ("documents") &
"/photos/"

         *if* there is a file the short id of this card *then*

            *put* specialFolderPath ("documents") & "/photos/" & the short
ID of this card into thePath

            *set* the filename of image "imageField1" of this card to
thepath

         *end* *if*

      *end* *if*

*end mouseUp*

I am I totally off base trying to use this approach?

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: [hidden email]
LogMeIn also avaialble
Call on "ooVoo" at address:  vaughnclement or 9282549062
Ph. 928-254-9062



On Wed, Jun 25, 2014 at 5:34 PM, J. Landman Gay <[hidden email]>
wrote:

> That's good to know.  My app is desktop only and it must be different
> there.  Thanks for the heads up.
>
> On June 25, 2014 4:51:44 PM CDT, Simon <[hidden email]> wrote:
> >Hi Jacque,
> >"But for image objects it isn't needed, and you can omit that
> >instruction."
> >Actually it was the only way to get the script to work on mobile when I
> >actually put it on my device.
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
12