Dada 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 mail.cgi with the correct query string, which looks like this:
http://yoursite.com/cgi-bin/dada/mail.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 Dada = new XML(); Dada.load('http://yoursite.com/cgi-bin/dada/mail.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/dada/mail.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 flavor 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/dada/mail.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.
If you save the example .fla in anything over version Flash 5, (which is a very very good chance), you'll have to follow the instructions located here:
http://www.macromedia.com/devnet/flash/articles/fplayer_security_03.html
Generally, you'll need to put a file in your public html directory called, crossdomain.xml, with the following entry:
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <allow-access-from domain="*.example.com" /> </cross-domain-policy>
Where, example.com is the domain of the site you have Dada Mail installed.
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.
http://yoursite.com/cgi-bin/dada/mail.cgi?f=subscribe_flash_xml&l=listshortname&e=someone@address.com
to:
http://yoursite.com/cgi-bin/dada/mail.cgi?f=unsubscribe_flash_xml&l=listshortname&e=someone@address.com
in your actionscript.
Justin Simoni