XWidgetSoft Forum https://bbs.xwidget.com/ |
|
The Script is ok? https://bbs.xwidget.com/viewtopic.php?f=8&t=5217 |
Page 1 of 1 |
Author: | Jimking [ November 8th, 2014, 3:05 pm ] |
Post subject: | The Script is ok? |
I would like to create an animation weather widget like this one: viewtopic.php?f=11&t=4931&hilit=minions but this time with only weather icons (I have a number of png for each weather condition, so they will be animpng again). There will be two differences with the "Despicable Me Weather HD ANIMATED" widget: 1) I will use this tag for current weather "${curWeatherIcon}" so they will be 18 animpngs 2)The animations will have "0" loop count so they will play continuously. This is the script by @hamid from the minions weather widget: ---------------------------------- var WeatherNames=[sun,cloudy,fog,rain,lightning,snow,moon,moon_cloudy] function accweathercore1OnUpdate(Sender) { var weathertmp=eval(accweathercore1.get("${curSimpleWeatherIcon}")) if(weathertmp.Visible==false) { for(var i in WeatherNames) { WeatherNames[i].Visible=0 WeatherNames[i].Src="" } var listtmp="" var imgtmp=GetFileList(WidgetPath+"\\"+weathertmp.Name,"png",0).split("|") for(var j=1;j<imgtmp.length;j++) { listtmp+=weathertmp.Name+"\\"+j+".png"+"|" } listtmp+=weathertmp.Name+"\\"+imgtmp.length+".png" weathertmp.Src=listtmp weathertmp.OnClick="StartAnimating" weathertmp.Visible=1 StartAnimating(weathertmp) } } --------------------------------- My question is: I will need to change only the two parts of the script with the red color..? Or I need to change anything else... |
Author: | hamid [ November 11th, 2014, 6:36 am ] |
Post subject: | Re: The Script is ok? |
i have modified the code to be used with only one pnganimate object, so you will only need 1 pnganimate Object that named "WeatherObj" in your widget, i didn't tested it for errors, so you should test it in debug mode to make sure it works correct, and don't forget to add the StartAnimating() function code to the code Code: //Script Author: Hamid
var oldweather; function accweathercore1OnUpdate(Sender) { var weathertmp=accweathercore1.get("${curWeatherIcon}") if(weathertmp!=oldweather) { oldweather=weathertmp WeatherObj.Src="" var listtmp="" var imgtmp=GetFileList(WidgetPath+"\\"+weathertmp,"png",0).split("|") for(var j=1;j<imgtmp.length;j++) { listtmp+=weathertmp+"\\"+j+".png"+"|" } listtmp+=weathertmp+"\\"+imgtmp.length+".png" weathertmp.Src=listtmp StartAnimating(WeatherObj) } } |
Author: | Jimking [ November 11th, 2014, 6:53 am ] |
Post subject: | Re: The Script is ok? |
Ok I will test it as soon as possible.. Thanks mate! ![]() |
Author: | Jimking [ November 11th, 2014, 5:48 pm ] |
Post subject: | Re: The Script is ok? |
Code: //Script Author: Hamid var oldweather; function accweathercore1OnUpdate(Sender) { var weathertmp=accweathercore1.get("${curWeatherIcon}") if(weathertmp!=oldweather) { oldweather=weathertmp WeatherObj.Src="" var listtmp="" var imgtmp=GetFileList(WidgetPath+"\\"+weathertmp,"png",0).split("|") for(var j=1;j<imgtmp.length;j++) { listtmp+=weathertmp+"\\"+j+".png"+"|" } listtmp+=weathertmp+"\\"+imgtmp.length+".png" weathertmp.Src=listtmp StartAnimating(WeatherObj) } } function StartAnimating(Sender) { Sender.Play=0 Sender.FrameIndex=0 Sender.Play=0 } Hamid this is the full script when run on debug nothing appears.. ![]() I remind you that I have 18 folders for each wth condition, this time all the images have the same dimentions and each png it will play continuously (loop "0"). Here is the widget: http://www73.zippyshare.com/v/68107773/file.html |
Author: | hamid [ November 11th, 2014, 7:54 pm ] |
Post subject: | Re: The Script is ok? |
i did 1 mistake and you did 2 ![]() mine was: i forget to change the source to "WeatherObj" yours was: 1. you have changed directory structure without telling me, they're in "Images" directory now, while they're not there in previous widget 2. you have used "Sender.Play=0" at the end ![]() ============== here's the working version: Attachment: Note: as ever i have removed images from it for easier uploading, don't forget to add them again ============== Quote: Important: the folder names are different from the weather names in my reference, i don't know which one is correct, so don't forget to check them: Code: cloudy > clouds lightning > lightening Edit: i have tested it and found my reference was wrong, so no need to change anything |
Author: | Jimking [ November 11th, 2014, 8:12 pm ] |
Post subject: | Re: The Script is ok? |
Ok... because I took the weather names from here: viewtopic.php?f=10&t=4837 I'll reply as soon as possible hamid.. Edit: All seem to work properly now. ![]() Thanks man! |
Author: | Jimking [ November 14th, 2014, 8:03 am ] |
Post subject: | Re: The Script is ok? |
I added city name and temp and edited the animpng properties with "inverse on finish" to give the effect of a continuous movement. ![]() |
Author: | hamid [ November 15th, 2014, 5:34 am ] |
Post subject: | Re: The Script is ok? |
i don't think the "inverse on finish" effect will be good for it, even i'm not sure if the infinite loop would be so good, but i think adding infinite loop as RightClick option will be fine |
Author: | Jimking [ November 15th, 2014, 5:55 am ] |
Post subject: | Re: The Script is ok? |
hamid wrote: i don't think the "inverse on finish" effect will be good for it, even i'm not sure if the infinite loop would be so good, but i think adding infinite loop as RightClick option will be fine If you still have the widget/files that I sent you edit the pnganim properties with Interval(MS) = 70, Loop Count = 0, Inverse onfinish = activated, and check it. I like it because gives the effect of the continuous movement like the real sky. The weird indeed is when we have rain, lightning or snow that the rain will go inverse! So yes the "inverse on finish" maybe is not a good idea, but the "infinite loop" yes and I will keep it like this. Now if you can add a right click to select the loop from 0<->1 is an extra option so why not.. |
Author: | hamid [ November 17th, 2014, 9:41 pm ] |
Post subject: | Re: The Script is ok? |
ok, it's ready: Attachment: =========== Changes: Added: RightClickMenu for Enable/Disable Animation Loop ============== |
Author: | Jimking [ November 18th, 2014, 3:00 am ] |
Post subject: | Re: The Script is ok? |
Thanks man! ![]() The widget is ready now: * Unchecked the "inverse onfinish" * Added city/temp info viewtopic.php?f=11&t=5260&p=10634#p10634 |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |