|
|
|
The following page was printed from RemoteCentral.com:
Prontoscript: cannot copy image
| |
|
Topic: | Prontoscript: cannot copy image This thread has 10 replies. Displaying all posts. |
|
Post 1 made on Sunday December 12, 2010 at 05:47 |
rudy111 Long Time Member |
Joined: Posts: | January 2010 22 |
|
|
Hello;
I want to copy an image , I have: a blind page called 'Parameters" with a image called 'Tag1' another page with a panel called 'Pan1' and a button with this script:
var v,w; w = GUI.widget("Pan1");
v = widget("Tag1","Parameters"); w.label="OK"; w.setImage(v.getImage());
Text 'OK' appears, but no image. What is going wrong? And what is the difference between a 'Widget' and a 'GUI.widget'?
Greetz, Rudy
|
|
Post 2 made on Sunday December 12, 2010 at 09:21 |
2Many Long Time Member |
Joined: Posts: | September 2009 106 |
|
|
Try this:
var v,w; w = GUI.widget("Pan1");
v = CF.widget("Tag1","Parameters"); w.label="OK"; w.setImage(v.getImage());
|
"Home" is where my Pronto is. |
|
Post 3 made on Sunday December 12, 2010 at 09:41 |
MCFH Long Time Member |
Joined: Posts: | December 2009 35 |
|
|
Both getImage and setImage also take a parameter for the image index so you can track the various image states - see section 3.2.5 in the current manual
Regards Mark
|
|
Post 4 made on Sunday December 12, 2010 at 11:05 |
BluPhenix Long Time Member |
Joined: Posts: | December 2008 371 |
|
|
There are some things missing:
var v,w; w = GUI.widget("Pan1");
v = CF.widget("Tag1","Parameters","activity_name"); w.label="OK"; w.setImage(v.getImage(0), 0);
If w is a button you will also need:
w.setImage(v.getImage(1), 1);
|
|
Post 5 made on Sunday December 12, 2010 at 11:13 |
Lowpro Select Member |
Joined: Posts: | March 2004 2,081 |
|
|
w.setImage(v.getImage(0),0); // Released state. w.setImage(v.getImage(1),1); // Pressed state.
If your button doesn't contain an image for its pressed state for whatever reason there is no need to include, "w.setImage(v.getImage(1),1);" obviously.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
Post 6 made on Monday December 13, 2010 at 13:58 |
BluPhenix Long Time Member |
Joined: Posts: | December 2008 371 |
|
|
This si true.
But i always tend to write the whole code, in case I later decide I want a press state image. It makes it easyer if the code is there, but the graphic is not, than vice-versa.
|
|
OP | Post 7 made on Saturday December 18, 2010 at 09:25 |
rudy111 Long Time Member |
Joined: Posts: | January 2010 22 |
|
|
Hello again;
Tried all your advices, copied the exact code from the manual, tried some things on my own: no succes.
Have made a whole new test-set, so now a have: - Activity = "Test" with 2 pages: - (hidden) Page "RESOURCES" with 2 panels: - panel "Tag1" containing a image1 - panel "Tag2" containing a image2 - Page "HomeTest" with 1 panel "Pan1"
Plain, simple, straight on, just following the manual. So, now I put the next script in 'HomeTest'-Page Script:
var w, v; w = widget("Pan1"); v = widget("Tag1", "RESOURCES","HomeTest"); w.setImage(v.getImage()); widget("w").stretchImage = true;
With this statement: w.setImage(v.getImage(0),0); or: w.setImage(v.getImage(1),1); or: w.setImage(v.getImage()); or: v = widget("Tag1", "RESOURCES"); or: v = widget("Tag1", "RESOURCES",HomeTest,"Test");
the debug-page says: TypeError: V has no properties
Well. I'm lost...., gr., Rudy
|
|
Post 8 made on Saturday December 18, 2010 at 09:47 |
BluPhenix Long Time Member |
Joined: Posts: | December 2008 371 |
|
|
There are some inconsistencies between your specs and code: var w, v; w = widget("Pan1"); <- are you on the page with this widget, as you make a direct call? v = widget("Tag1", "RESOURCES", "HomeTest"); <- Tag 1 is on the page RESOURCES of the activity "Test", not HomeTest. The error TypeError: V has no properties means that it can not find whe widget. The right code is: var w, v; w = widget("Pan1"); v = CF.widget("Tag1", "RESOURCES", "Test"); w.setImage(v.getImage(0), 0); w.stretchImage = true; If the resource widget is a panel an thus has only one image the call v.getImage(1) is not valid. To make it more clear next time you can write some more structured code: var widget1 = widget("Pan1"), // if the widget Pan1 is on the page you're writing the code for resource_page = CF.page("RESOURCES", "Test"), resource_widget = resource_page.widget("Tag1");
widget1.setImage(resource_page.widget("Tag1").getImage(0),0): widget1.stretchImage = true;
|
|
Post 9 made on Saturday December 18, 2010 at 09:49 |
johnmack Long Time Member |
Joined: Posts: | October 2005 42 |
|
|
Try the following;
- Activity; label = "Test" and tag = "TEST" with 2 pages: - Page 1; label = "resources", tag = "RESOURCES" with 1 panel: - panel; label = "Tag1" and tag = "TAG1" containing a image to be copied - Page 2; label = "HomeTest" and tag = "HOMETEST" with 1 panel; - panel; label = "Pan1" and tag = "PAN1" containing a image
Script in 'HomeTest'-Page Script:
var w = GUI.widget("PAN1"); var v = CF.widget("TAG1", "RESOURCES"); w.setImage(v.getImage()); w.stretchImage = true;
|
|
Post 10 made on Saturday December 18, 2010 at 13:04 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
Note that 'label' refers to text that shows up on button or panel (or in the tree-view if a page or activity). tag refers to the ProntoScript name you assign on the Advanced Tab of the Properties dialog.
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
OP | Post 11 made on Sunday December 19, 2010 at 04:21 |
rudy111 Long Time Member |
Joined: Posts: | January 2010 22 |
|
|
O heavenly joy: it works. The problem was that you must put 'CF' in assinging the widget :var v = CF.widget("TAG1", "RESOURCES") since the command 'Widget' is a member of the class 'CF' (or the class 'GUI').
And looking in the manual, indeed it is mentioned (page 87, A.2.2.3. CF.widget() ), but why not a proper example in chapter 3.1.6. 'Changing the image'??
Thanks all, have a nice Chrismas, gr, Rudy (not the rednosed one).
|
|
|
Before you can reply to a message... |
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now. |
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.
|
|