Mojo Mail now has hooks for Flash that will return an SWF-friendly, XML document to allow you to create a subscription form in the animation itself, instead of having to use HTML form widgets. All the SWF animation has to do is load mojo.cgi with the correct query string, which looks like this:
http://yoursite.com/cgi-bin/mojo/mojo.cgi?f=subscribe_flash_xml&l=listshortname&e=someone@address.com
Breaking that down,
What do I mean by SWF-friendly? It means the XML doc that gets past back should work for all versions of the Flash 5 player and above, it does not have any newlines in it, or whitespace between tags, so you don't need any groovy undocumented Flash 5 XML method calls or #included code. All the tags are lowercase as well. I know, I've been there. I'm on your side, believe me. Oh, and the XML is given to Flash with a content type of 'application/x-www-form-urlencoded'.
Once you sort all that out, it's just a simple call in Actionscript:
var Mojo = new XML(); Mojo.load('http://yoursite.com/cgi-bin/mojo/mojo.cgi?f=subscribe_flash_xml&l=listshortname&e=someone@address.com');
to load up the XML. Well, what does the XML look like?
The XML document for this query:
http://yoursite.com/cgi-bin/mojo/mojo.cgi?f=subscribe_flash_xml&l=listshortname&e=someone@address.com
will look like this: (newlines added for clarity)
<subscription> <email>someone@address.com</email> <status>1</status> <errors></errors> </subscription>
Pretty self-explanitory, (ah, the wonders of meta data) The only elusive thing is the status. A status of 1 means everything checked out. The listshortname flava checks to see if - the list exists, the email is valid, the email is already subscribed, if the list is closed and if the email is blacklisted. Possibly better than the self-rolled version you may have been using.
A query like this:
http://yoursite.com/cgi-bin/mojo/mojo.cgi?f=subscribe_flash_xml&l=listshortname&e=bad
Will return something like this:
<subscription> <email>bad</email> <status>0</status> <errors> <error>invalid_email</error> </errors> </subscription>
Pretty slick, eh?
The error values are as follows:
again, self explainitory.
There's an .fla file called email_subscription_form.fla In the first frame of Scene 1, there are two variables you need to change... have at it.
The above instructions are meant to be digested by someone who knows what they're doin' in Flash Actionscript. Tutorials by me for Flash are up in coming.
Sometimes using XML from an outside source within Flash can be difficult to debug, so I made it easy for you to just check out the XML doc in your browser add &test=1 to the end of the already-too-large-to-type-yet-again query string and paste that into a web browser.
Justin Simoni
For support for this script, it's best to either post on the Mojo Mail message boards:
http://mojo.skazat.com/support/boards
or, subscribe to the Mojo Mailers discussion list:
http://mojo.skazat.com/cgi-bin/mojo/mojo.cgi?f=s&l=mojo_mailers