Blog

  • Flex Chronicles #12: External Text Files for String Variables

    Typically, if you want external content in Flash, you link to an external text file, and load it into a text field like so:

    lv = new LoadVars();
    lv.owner = this;
    lv.onData = function(str)
    {
      this.owner.my_txt.text = str;
    };
    lv.load("yourTextFile.txt");

    Quick and dirty, right? Well, Flex does the same thing for you, but without all the work; check this out:

    <mx:String id="data_str" source="some.txt" />
    <mx:TextArea text="{data_str}" />

    Yes, that’s it, I swear! The line between authortime & compile time is blurred so technically this is compiled in, but it remains an external text file you can check into source control & deploy on your webserver, or keep locally.

  • Flash, Flex, & AMFPHP: RSS Reader Example

    Wanted to not only learn bindings in Flex, but see how they compared to Flash in terms of actually using them and seeing their benefits side-by-side to Flash. The fact you can bind any property to any property of a GUI component rocks the mic!

    So, since both of these RSS reader’s hit the same AMFPHP webservice, I figured I’d just upload the source so you could see how to use Flash & Flex with AMFPHP since there aren’t many examples around on using either, ecspecially for using RemoteObject with something other than Java, in this case PHP via AMFPHP without using the Flex server. Additionally, this is a simple enough example in Flex to see how the bindings work.

    You’ll have to setup AMFPHP yourself as the SWF’s are not using the Flex server as a proxy, and thus will not work unless hosted on www.jessewarden.com because of the security sandbox. Unless you spoof this, or use AMFPHP to actually forward the request (which is easy I believe), or just setup and run localhost.

    Here’s how they work:
    – Flash or Flex hits the AMFPHP gateway via Flash Remoting, and calls the getRSS1Feed method in a PHP class called RSSReader.
    – The RSSReader class’ method, getRSS1Feed takes 1 parameter, the URL to an RSS feed, and uses Magpie to parse it into a usable object. It then returns this object in the function.
    – AMFPHP sends the object back to Flash or Flex.
    – Flash or Flex then displays the RSS feeds and allows you to cycle through the blog entries.

    Needless to say, the Flex one was faster to build, and more fun!

    The Flash One

    The Flex One

    Files & Links

    Source Files

    Magpie PHP RSS Parser (his files need to be next to RSSReader.php in the AMFPHP “services” folder)

    AMFPHP

    Flex

    Flash

  • BBC Flash Components True to Their Word

    A long, long, time ago… say, the re-election of Bush (or dumbfoundedness of the mass media depending on how you look at it), a group of dev’s at the BBC mentioned they would release their component set.

    Naturally, I figured bollocks… I’ve heard that 50 billion times before from various company representatives, and the only people to deliver were EnFlash and the Bit Components. There may be more, I’m sure, but regardless I was quite surprised to see they finally did what they said they would do.

    After creating a bunch for myself over the years, I respect anyone who can pull off releasing a set to the public. Aral’s got the 4-1-1.