Topic: Help with Widget
I have what I believe to be a simple widget created in Flex 4.6. What it does is gets the data from a url, parses it and sets an image link presented. then it displays that image. Refreshes every minute, shows date\time, and allows to pause refresh and go to previous image.
This works locally on my laptop, also on the chumby.com preview but when loaded on my chumby it is just a blank black screen. Can anyone please help me with this? The code is below
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="800" minHeight="600"
initialize="application1_initializeHandler(event)"
click="application1_clickHandler(event)"
width="800" height="600" enterFrame="application1_enterFrameHandler(event)"
>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.filters.BaseFilter;
private var u:URLLoader = new URLLoader();
private var timer:Timer;
[Bindable]
private var pause:Boolean = false;
private var lastURL:String;
[Bindable]
public var overlay:Boolean = true;
[Bindable]
public var currUrl:String;
protected function application1_initializeHandler(event:FlexEvent):void
{
timer = new Timer(60000,0);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
loadImage();
}
protected function application1_enterFrameHandler(event:Event):void
{
var now:Date = new Date();
var hour:Number = (now.hours < 12 ? now.hours : now.hours - 12);
var ampm:String = (now.hours < 12 ? "AM" : "PM");
date.text = (now.month+1) + "/" + now.date + " " + hour + ":" + now.minutes + ":" + now.seconds + " " + ampm;
}
protected function timerHandler(event:Event):void
{
if (!pause)
loadImage();
}
protected function loadImage():void
{
var ur:URLRequest = new URLRequest("http://splakow.com/random.php");
u.load(ur);
u.addEventListener(Event.COMPLETE, urlComplete);
}
protected function urlComplete(event:Event):void
{
var s:String = u.data;
var a:Array = s.split("\"");
var url:String = a[7];
lastURL = currUrl;
currUrl = url;
imageName.text = url;
}
protected function application1_clickHandler(event:MouseEvent):void
{
var x:int = event.localX;
var y:int = event.localY;
if (y < 300)
{
overlay = !overlay;
}
else
{
if (x < 400)
{
pause = true;
currUrl = lastURL;
}
else
{
pause = !pause;
}
}
}
]]>
</fx:Script>
<s:Image id="image" source="{currUrl}" width="100%" height="100%"/>
<s:Label top="20" left="20" fontSize="15" id="date" visible="{overlay}">
<s:filters>
<s:DropShadowFilter color="#FFFFFF" distance="0" strength="200" alpha="0.7"/>
</s:filters>
</s:Label>
<s:Label id="imageName" bottom="20" left="20" visible="{overlay}">
<s:filters>
<s:DropShadowFilter color="#FFFFFF" distance="0" strength="200" alpha="0.2"/>
</s:filters>
</s:Label>
<s:Label visible="{pause}" text="Paused" right="20" bottom="20" fontSize="15">
<s:filters>
<s:DropShadowFilter color="#FFFFFF" distance="0" strength="200" alpha="0.7"/>
</s:filters>
</s:Label>
</s:Application>
I should mention that I am building this app because I am using Gallery3 and none of the Photo widgets quite do what I am looking for.