On 2/24/06, Richard Lyman wrote:
> I haven't gotten any feedback yet (should I have waited longer? How
> 'active' is the wiki?)...
>
> ... so I just want to fan the flames a bit and ask for feedback...
>
> http://osflash.org/fxr
> and
> http://osflash.org/fxr_howto
>

Hey Richard,

Well, you've successfully fanned the flames.  Luke Bayes
(http://www.lukebayes.com) and I (http://www.alimills.com) have been
working on this idea on and off for over half a year.  We call it,
SwfRunner.  I'll try to post more in a couple of days, but in the
meantime here're some answers:

> 1. Is this helpful to anyone but me?

Yep.  My ultimate interest in writing software has always been to
write apps that work on desktop/web/device in online/offline modes on
multiple platforms.  That's why I develop for the Flash player, and
that's why Luke and I chose XulRunner for AsUnit's
(http://www.asunit.org) toolset .  SWFs running in XulRunner make the
desktop part of this puzzle a reality.

> 2. Other than the current requirement of packaging XULRunner along
> with your app - what negatives do you see?

There are a couple:
1. It's illegal to distribute the Flash player without a license to do
so.  As far as I know, MDM (http://www.multidmedia.com) is the only
company with this license in the desktop wrapper space.

2. If you ship your app without the Flash player, getting it is yet
another download dependecy for your app to run.  Even more concerning,
your app may be designed to work with a version of the Flash player
that's ends up being no longer available.

3. XulRunner currently doesn't install browser plugins properly.

4. XulRunner doesn't have an installer yet.  You need an installer to
place a 'FlashPlayerTrust' file on the end user's machine for local
file I/O.

5. The Linux Flash player may be buggy.  I don't know if this is true
or not, but I feel like I heard it somewhere.

> 3.
>   a) Is anyone as excited as I am that you can get a 'standalone
> desktop application' that uses Flash as it's interface?
>   b) Are you excited that you can any look and feel by just swapping
> out any of the emerging Flash-based GUI toolkits - and that your look
> and feel will be _exactly_ the same on win/nix/osx?

Hellz yes!

> 4. What ways would you use to connect Flash to something that would
> allow you to access files on the host machine? XPCOM? XMLSocket (what
> I use)? AMF?

XMPCOM works and is the cleanest, but you'll have to create a
'FlashPlayerTrust' file.  If I new C/C++ I'd have written the
installer for XulRunner already.  You need an installer to put this
file in the proper location.  You can learn more about those and other
Flash 8 security related issues at
http://www.macromedia.com/devnet/flash/articles/fplayer8_security.html.
 Here's some code that I have working:

[xul_code]
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window
        id="swfrunner"
        title="SwfRunner"
        persist="height width screenX screenY"
        width="550"
        height="400"
        screenX="50"
        screenY="200"
        xmlns:html="http://www.w3.org/1999/xhtml";
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>
<script>
        function proxy(str) {
                alert(">> proxy: " + str);
        }
        
        function nsFileRead(location) {
                var loc = 
"C:\\cygwin\\home\\alimills\\projects\\SwfRunner\\trunk\\core\\src\\xul\\swfrunner\\chrome\\swfrunner\\SwfRunner.txt";
        
                var file = Components.classes["@mozilla.org/file/local;1"]
                                     
.createInstance(Components.interfaces.nsILocalFile);
                file.initWithPath(loc);
                

                if ( file.exists() == false ) {
                        alert("File does not exist");
                }


                var is = 
Components.classes["@mozilla.org/network/file-input-stream;1"]
                        .createInstance( 
Components.interfaces.nsIFileInputStream );
                is.init( file,0x01, 00004, null);
                var sis = 
Components.classes["@mozilla.org/scriptableinputstream;1"]
                        .createInstance( 
Components.interfaces.nsIScriptableInputStream );
                sis.init( is );
                var output = sis.read( sis.available() );
                return output;
        }

        function nsFileWrite(str, location) {
                // write file to location
        }
</script>

<html:embed id="swfrunner" name="swfrunner"
        src="SwfRunner.swf"
        quality="high"
        bgcolor="#66cc66"
        width="100%"
        height="100%"
        align="middle"
        allowScriptAccess="always"
        type="application/x-shockwave-flash"
        pluginspage="http://www.macromedia.com/go/getflashplayer"; />


</window>
[/xul_code]

[as_code]
package org.swfrunner.net {
        import flash.external.ExternalInterface;

        public class File {
                private var location:String;
                private var data:String;
                
                public function File(loc:String) {
                        location = loc;
                        data = "";
                }
                
                public function read():Void {
                        data = ExternalInterface.call("nsFileRead", location);
//                      data = "Reading in data...";
                }
                
                public function write():Void {
//                      ExternalInterface.call("nsFileWrite", data, location);
                }
                
                public function toString():String {
                        if(data == null) {
                                data = "";
                        }
                        return data;
                }
        }
}
[/as_code]

The above code with the information at the OsFlash link you sent and
the the Macromedia link about 'FlashPlayerTrust' files should be
enough for you to get XPCOM working.

I haven't talked about SwfRunner before today because I've been
working on an AS/JS library for it to support online/offline file
access.  I feel like such a library is essential to writing
online/offline apps properly.  While working through the problems, my
reading (which I really haven't had enough time for) has included the
only two books I've found that come close to dealing with disconnected
software.  The books are Enterprise Integration Patterns
(http://www.amazon.com/gp/product/0321200683/sr=8-1/qid=1140844930/ref=pd_bbs_1/002-8946131-3020003?%5Fencoding=UTF8)
and Data Patterns
(http://www.amazon.com/gp/product/0735622000/qid=1140844979/sr=2-1/ref=pd_bbs_b_2_1/002-8946131-3020003?s=books&v=glance&n=283155).
 You should consider checking them out.

> 5. Are there ways you could transparently connect to a resource on the
> host machine to fulfill #4? (transparently means that the host os
> _does not_ pop up any warning like: application such-and-such is
> attempting to connect to... do you want to allow it to connect?)

Yep.  The above code does as long as the SWF and the XUL document are
on the same local machine.  You start to run into problems when
they're hosted remotely.

Here's a list of resources that I've found useful and bookmarked:

Xul
------------------------------------------
http://lukebayes.blogspot.com/2005/07/xul-runner.html
http://lukebayes.blogspot.com/
http://www.darronschall.com/weblog/archives/000108.cfm
http://developer.mozilla.org/en/docs/XULRunner
http://www.mozilla.org/xpfe/xulref/
http://www.oreillynet.com/mozilla/

Disconnected Patterns
------------------------------------------
http://www.richinternet.de/blog/index.cfm?entry=9D486E1A-A9CF-673F-9941EE719FAE197B
http://www.enterpriseintegrationpatterns.com/
http://martinfowler.com/bliki/EventPoster.html

My soon (next week) to be active blog
------------------------------------------
http://www.assertTrue.com

Well with all that said, the work we've done on SwfRunner will
probably be made public sometime soon.  It's been our goal all along
to package and release the work as an open source project called
SwfRunner.  The problem is, XulRunner isn't mature enough.  At the
least, it needs to install plugins properly.  And if you want Flash
and XUL to communicate, you also need an installer to get those
stinkin 'FlashPlayerTrust' files where they belong.

I'll be at Flashfoward next week and would be excited to talk more
about SwfRunner there if you're attending.

Have fun and congradulations on the find.  I think that XulRunner and
SWFs make a very happy couple.

Take care.


Ali

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to