Topic: Problems creating astronomy widget

So I'm trying to make my own astronomy picture of the day widget for the chumby (since I don't like the 2 that exist).  The way I'm doing it is with a PHP file that goes to the astronomy picture of the day page, which has a regular expression that splits out the image url, which is the printed to the page.  Then I have Flash going to this page, and showing the image in a dynamic text box as HTML text.  In Flash, it works fine.  On the chumby, it doesn't.  I get a black screen.

This is the first time I ever try to develop something for a Flash lite device, so is there something special I have to do to the file?  Any other possible solutions?  Can RSS work?  I tried the example RSS file and pointed it to the astronomy picture of the day RSS page but it said it wasn't accessible.  So I'm assuming they don't have a crossdomain.xml file.

Re: Problems creating astronomy widget

If you're using Firefox, check out Firebug (getfirebug.com). it'll let you watch the net traffic that your flash generates and diagnose issues. you can easily see if you're missing a crossdomain.xml

Do you have a permissive crossdomain.xml on your server that contains the PHP?

When you say "working in flash", do you mean when you run your movie from within flash, or when you export it and run it in your browser? The security model for movies within the flash environment is more permissive than running from a browser. Running from a browser is a better representation of how your device'll work on Chumby.

Re: Problems creating astronomy widget

You can try one of these tips for a workaround without having your own server.

http://forum.chumby.com/viewtopic.php?id=1146

Re: Problems creating astronomy widget

I did not have a crossdomain.xml file on the PHP server, but I did just add it.  It still doesn't work if I run the swf locally in a browser, but it did enable it to work from another server online.  So hopefully the chumby will work tomorrow (it's at work, and I'm now at home).

I did allow access to come from anywhere in the crossdomain.xml file with the wild card.  Since the chumby isn't a website, is there a way I can specify that it only allows access from the chumby?

Re: Problems creating astronomy widget

You'd put *.chumby.com in the crossdomain.xml file because that's the "security domain" of the widget (ie. from where it was downloaded into the chumby).

Re: Problems creating astronomy widget

Well this is annoying...it doesn't work on my chumby. sad
The preview works fine on the website in the "my channels" area.  I tried setting the crossdomain.xml file back to allow access from anything, but it still doesn't work.  Any more ideas?  I did change my script so it writes the URL to a txt file, and the swf is now accessing this txt file instead.  The reason I changed this is so I could do a daily cron job so my server only goes to the NASA website once a day instead of every time the chumby shows the widget.

Re: Problems creating astronomy widget

anyone?

8 (edited by jvc 2007-12-05 21:47:46)

Re: Problems creating astronomy widget

I would

1. upload the widget as private
2. enable ssh
3. ssh into the chumby
4. start the widget by running the commands
stop_control_panel
start_control_panel

use trace messages throughout to try and see if something is failing

some more stuff here http://wiki.chumby.com/mediawiki/index. … ng_Widgets

Launching_sshd_at_startup

Re: Problems creating astronomy widget

You're talking about ActionScript trace messages right?  How would I be able to view those without being in Flash?

Re: Problems creating astronomy widget

ok so nevermind that last post, I now know which tracing you're talking about.  Here's all the (relevant, I think) SSH info.  I can see that it accesses both the crossdomain.xml file as well as the txt file with the URL.  I don't see any obvious errors...


2007-12-06 09:50:19 TRACE: - loading widget movie "Astronomy Pic of the Day" from http://widgets.chumby.com/xml/movies/9C … 156009DD9B
2007-12-06 09:50:19 kStopSlave: no slave running or slave mismatch for instance id -1
2007-12-06 09:50:19 ClientObject::StartSlaveCommon() starting slave 'http://widgets.chumby.com/xml/movies/9C … 156009DD9B'
2007-12-06 09:50:19 ClientObject::StartSlaveCommon() created new settings instance 0x00235998 to be freed when slave dies
2007-12-06 09:50:19 ClientObject::ClientObject(this=0x00235a88) asynch load = Y
2007-12-06 09:50:19 ClientObject(5) mmobj=0x40a2b5d4, PlatformPlayer=0x40a33d98
2007-12-06 09:50:19 DisplayObject::<constructor>() UDMA is disabled, falling back to /dev/fb[#]
2007-12-06 09:50:19 FrameBuffer::<constructor>(0,320X240) 640 bytes per line, 153600 == buffer size
2007-12-06 09:50:19 FrameBuffer::AssureFrameBuffer() file for /dev/fb0 is 0x2357d8 (fileno 8)
2007-12-06 09:50:19 FrameBuffer::AssureFrameBuffer() m_frame_buffer=0x40a6c000
2007-12-06 09:50:19 FrameBuffer::GetFrameBuffer(0, 320X240) - creating new FrameBuffer instance 235c30
2007-12-06 09:50:19 DisplayObject::<constructor> got fb=00235c30 for 320X240 idx=0 153600 bytes
2007-12-06 09:50:19 SoundObject::SoundObject[b](0x00235d50 mmobj=0x40a2b5d4): initializing audio, buffers=16, bpb=2048
2007-12-06 09:50:19 SoundObject::Add[b](this=0x00235d50, mmobj=0x40a2b5d4)
2007-12-06 09:50:19 StreamSoundObject::StreamSoundObject(this=0x00235d50, mmobj=0x40a2b5d4==0x40a2b5d4): setting up audio
2007-12-06 09:50:19 KeyboardObject::<ctor>(this=0x00235df8 mmobj=0x40a2b5d4) next=0x00228518
2007-12-06 09:50:19 ClientObject::Initialize() - successfully set vector font data for 24991 bytes
2007-12-06 09:50:19 KeyboardObject::AssureEventInterface() unable to open /sys/class/input/event1
2007-12-06 09:50:19 KeyboardObject::AssureEventInterface() unable to open /sys/class/input/event2
2007-12-06 09:50:19 ClientObject::LoadSwfToMemFromURL(http://widgets.chumby.com/xml/movies/9C6EDE2E-A212-11DC-B5A1-00156009DD9B) - instantiating http object, async=Y, timeout = 60 sec
2007-12-06 09:50:19 FrameBuffer::GetFrameBuffer(1, 320X240) - adding ref to existing FrameBuffer instance 2288e0 with ref count 1
2007-12-06 09:50:19 DisplayObject::SwitchActiveDisplay(1) previous frame buffer was 1
2007-12-06 09:50:19 kStartSlave: Object origin=(null), length = 0, interface count = 0, first=0x70094e30
2007-12-06 09:50:19 TRACE: - using widget timing:
2007-12-06 09:50:19 TRACE:  - timeout, 30000 ms
2007-12-06 09:50:19 TRACE: - running the widget for 30 seconds
2007-12-06 09:50:19 TRACE: - expires at Thu Dec 6 09:50:49 GMT-0500 2007
2007-12-06 09:50:19 TRACE: Setting advance timer handler
2007-12-06 09:50:19 Setting input event routing to both (3)
2007-12-06 09:50:19 ClientObject::WidgetLoadPump() loaded 411 bytes
2007-12-06 09:50:19 ClientObject::WidgetLoadPump(http://widgets.chumby.com/xml/movies/9C6EDE2E-A212-11DC-B5A1-00156009DD9B) - successfully opened widget, elapsed time=0 sec
2007-12-06 09:50:19 ClientObject::SWFValidateCommon(url=http://widgets.chumby.com/xml/movies/9C6EDE2E-A212-11DC-B5A1-00156009DD9B,size=411) validate result 1
2007-12-06 09:50:19 ClientObject::Initialize() - preloading 1 class libraries
2007-12-06 09:50:19 TRACE: preload.swf v1.02
2007-12-06 09:50:19 ClientObject::Initialize() successfully loaded 1 preinstalled libraries
2007-12-06 09:50:19 ClientObject::WidgetLoadPump(http://widgets.chumby.com/xml/movies/9C6EDE2E-A212-11DC-B5A1-00156009DD9B) validation result 1, deferred var count = 5
2007-12-06 09:50:19 NetStreamRequest::Open(1): Opening protocol 'http://' host 'wayfaererstudios.com' port 80 location '/crossdomain.xml'
2007-12-06 09:50:19 NetStreamRequest::Open(1) opened http object id 10
2007-12-06 09:50:20 NetStreamRequest::ProcessHeaders(1) content-type: text/xml
2007-12-06 09:50:20 NetStreamRequest::Step(1) done, closing stream (203 of 203 bytes, avail=0) status=200
2007-12-06 09:50:20 TRACE: (Master heartbeat)
2007-12-06 09:50:20 NetStreamRequest::Open(2): Opening protocol 'http://' host 'wayfaererstudios.com' port 80 location '/astronomy/picture.txt'
2007-12-06 09:50:20 NetStreamRequest::Open(2) opened http object id 11
2007-12-06 09:50:20 NetStreamRequest::ProcessHeaders(2) content-type: text/plain
2007-12-06 09:50:20 NetStreamRequest::Step(2) done, closing stream (73 of 73 bytes, avail=0) status=200
2007-12-06 09:50:21 ClientObject::HeartBeat(306930) elapsed 15.040s previous high 15.070s
2007-12-06 09:50:25 TRACE: (Advance timer heartbeat)
2007-12-06 09:50:30 TRACE: (Bend sensor heartbeat)
2007-12-06 09:50:30 TRACE: (Advance timer heartbeat)
2007-12-06 09:50:35 TRACE: (Master heartbeat)
2007-12-06 09:50:36 ClientObject::HeartBeat(321940) elapsed 15.010s previous high 15.070s
2007-12-06 09:50:36 TRACE: (Advance timer heartbeat)
2007-12-06 09:50:42 TRACE: (Bend sensor heartbeat)
2007-12-06 09:50:42 TRACE: (Advance timer heartbeat)
2007-12-06 09:50:48 TRACE: (Advance timer heartbeat)
2007-12-06 09:50:49 TRACE: Advance timer expired
2007-12-06 09:50:49 TRACE: Loading next widget instance
2007-12-06 09:50:49 TRACE: Clearing advance timer handler
2007-12-06 09:50:49 TRACE: Processing widget instance
2007-12-06 09:50:49 TRACE: Clearing advance timer handler
2007-12-06 09:50:49 TRACE: Playing widget instance (current play mode "playing")

11

Re: Problems creating astronomy widget

so it looks like your crossdomain file and txt file are being fetched but not the picture


what are you using to try and get the picture? Flash's MovieClipLoader class works well

12 (edited by nemesis256 2007-12-06 09:38:40)

Re: Problems creating astronomy widget

I have a dynamic text box and I'm setting it's htmlText (or whatever the name of it is) property to the value of the txt file.  Can the MovieClipLoader class do the same?

13

Re: Problems creating astronomy widget

MovieClipLoader is just for loading swfs, jpg, and pngs. it can load the jpg from the value of your text file (assuming the value is correctly read, you may want to trace that out to make sure)

Re: Problems creating astronomy widget

nemesis256 wrote:

I have a dynamic text box and I'm setting it's htmlText (or whatever the name of it is) property to the value of the txt file.  Can the MovieClipLoader class do the same?

If you're expecting the htmlText field to handle embedded IMG tags, then you're out of luck because Flash Lite doesn't support that - the support for HTML tags is *very* limited (mainly text markup).

What I see when I hit your URL is a simple one-line text response of a URL to the image - you should probably fetch that with an XML object, using the onData hander to prevent it being parsed as XML, then send the URL off to a MovieClipLoader to pull the actual image from the NASA site.

Re: Problems creating astronomy widget

Awesome, thanks guys, I'll work on it tonight and see if it works.

Re: Problems creating astronomy widget

Alright, it's somewhat working fine here up to now (don't know about the chumby yet).  I have the image loaded with XML and displayed with MovieClipLoader like you mentioned.  The problem I'm having is with fitting the image to the right size so it's full screen on the chumby.  By default, the image is much bigger.  I tried using container_mc._width = 320; and same for the height, but it won't work.  The image won't even show up on the screen for some reason when I use that.  Right now I'm using _xscale to make it decent, but I would like to specify 320x240.  Here's my code up to now.

var pageURL = "http://wayfaererstudios.com/astronomy/picture.txt";

var xmlLoader:XML = new XML();

xmlLoader.onLoad = function(success)
{
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    mcLoader.loadClip(xmlLoader.toString(), container_mc);
    container_mc._xscale = 40;
    container_mc._yscale = 40;
}

xmlLoader.load(pageURL);

Re: Problems creating astronomy widget

The problem is that you can't set the dimensions of an image that hasn't loaded yet - what you need to do is create an onLoadComplete handler on a listener for the MovieClipLoader, which will then resize the image to the dimensions you want.  What I typically do is compute how much I'd have to scale in x and y to get the desired dimensions, then scale both with the minimum of the two, then I center the image.

18

Re: Problems creating astronomy widget

I moved some stuff to avoid scope issues but this should get you close..

var xmlLoader:XML = new XML();
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

xmlLoader.onLoad = function(success)
{
    mcLoader.loadClip(xmlLoader.toString(), container_mc);
}

function onLoadInit(target_mc:MovieClip)
{
    target_mc._xscale = 40;
    target_mc._yscale = 40;
}


xmlLoader.load(pageURL);

Re: Problems creating astronomy widget

It finally works on my chumby!  Thanks guys.

20 (edited by sonex293 2007-12-07 06:40:59)

Re: Problems creating astronomy widget

Are you planning on sharing the widget with the rest of us when it`s done?

--Michael

Re: Problems creating astronomy widget

I guess I could, but I'm wondering about how much bandwidth could potentially be used.  The image gets downloaded every time the widget is viewed from the chumby (or is there a cache?) and the text file is downloaded every time from my server.  It's probably not a big deal, but I would like to hear what people have to say about this and typical chumby bandwidth usage.

Re: Problems creating astronomy widget

There is an HTTP cache on the chumby - on your server, you should be able to set the HTTP Cache-Control header to set the cache time to whatever you feel is appropriate.

Since this image changes at most once a day, you can probably set it for quite a long duration, probably 6 hours or so to keep it from getting absurdly stale - or, if you're really clever, set it dynamically based on when you expect the picture of the day to change.

Of course, the actual cache behavior of the chumby depends upon how many resources are completing for it.

By default (ie *no* Cache-Control header), the chumby will cache data for 5 minutes.

Re: Problems creating astronomy widget

So I changed my widget to make it public.  I don't see it up there right now, so I assume it has to go through a longer process.  It will be in the photos section.

Re: Problems creating astronomy widget

It's been publicized!  Here's the link
http://www.chumby.com/guide/widget/Astr … 0the%20Day

Re: Problems creating astronomy widget

Thanks for making the astronomy photo-of-the-day, and congrats on getting your widget into the public pool, nemesis256.

Here's a request. smile

I'd prefer *just* the photo--without the explanation. (It would be tops if explanations could go on a second "page" but I really don't enjoy the photo *or* the explanation as is.)

-Jodi