XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
Constant Cycling between two text layers https://www.bbs.xwidget.com/viewtopic.php?f=7&t=4401 |
Page 1 of 1 |
Author: | Dr_Xadium [ April 19th, 2014, 8:07 am ] |
Post subject: | Constant Cycling between two text layers |
Let's say I have one text area, and I want to show Weather in it, then have the weather vanish and an RSS feed show up instead. And I want it to loop between these two things. Right now I'm trying this code: Code: talklayer.Visible=true; //is the text area supposed to be visible? function hideInfo() // hides both the weather info and RSS info layers { Weather_Info.Visible = false; RSSText1.Visible = false; } function exchanger() // called at widget load { while (talklayer.Visible==true) //is the text area visible to the user { hideInfo(); // empty the text area RSSText1.Visible = true; //show me the RSS feed text sleep(1500); //leave it up for a while hideInfo(); // hide all text Weather_Info.Visible = true; //Show me the Weather text now hideInfo(); //hide all the text sleep(1500); //wait, repeat on loop } } My problem is using this code both layers show up simultaneously and they won't turn off. Am I doing something wrong? Is there a better way to rotate between text layers? |
Author: | qiancang [ April 19th, 2014, 9:04 am ] |
Post subject: | Re: Constant Cycling between two text layers |
1. it's better to use while(talklayer.visible) than while(talklayer.visible==true) 2. I think that it's dangerous to combine while and sleep especially when you call them at widget load. 3. my solution: use a timercore whose interval is 1500 ms to exchange weather and rss. Code: function timercore1OnUpdate(Sender)
{ if(talklayer.Visible) { Weather_Info.Visible = !Weather_Info.Visible; RSSText1.Visible = !RSSText1.Visible; } } |
Author: | Jimking [ April 19th, 2014, 9:24 am ] |
Post subject: | Re: Constant Cycling between two text layers |
This is the "magic" with the script: you can do the same thing with only two lines of coding!!! ![]() |
Author: | Dr_Xadium [ April 19th, 2014, 12:13 pm ] |
Post subject: | Re: Constant Cycling between two text layers |
Thanks for all the help! ![]() |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |