dominoGuru.com
Your Development & Design Resource
Flash Banners and Domino - Targeted Marketing Flash-based Banners and Clearframe's Domino-based Utilities (Part 2)
05/23/2006 11:24 AM by Chris Toohey
Along with our fields, our banner will need a submit button. At this time, we will use the Components section of the Flash client (fig. 4) - which houses pre-designed functional items such as fields, alerts, and (of course) buttons. If this Components section is not immediately found in the right-hand column of your Flash client on launch, you can open and "dock" this section via the File menu by selecting Window\Components or using the keyboard command Ctrl+F7!
Once we've done this, we're going to add another Layer to the Flash banner
for actions. Flash, for all intends and purposes, produces an animation. Every
frame in this movie will execute in one smooth arc from beginning to end, as
you'd expect it to. The problem with this, is that we're attempting to mirror
some very static functionality: entry form and then a submission response. To
execute this properly, we'll want to stop the frames from progressing forward
past our form, and only move onto the next frame in the animation (which will
be out submission response) when the workflow of the form calls for such. Now
that we've added the second layer to our Flash banner movie, we will go to our
actions layer and force the frame to stay at frame 1 when loaded. To
do this, we simply add the stop();
to the frame (fig. 5). We will
additionally, once this banner is completed, set our second frame in the
actions layer to not loop via the same stop();
function.
Now we have pretty much everything that we will need to make this form work,
except for the form functionality! So we'll need to start building the
application logic behind this Flash banner/form that we're building. To do
this, we'll state that we're going to post data via a GET-style method from
this Flash banner to a Domino database, and using a CGI Variable defined in the
Document Context of the post's processing agent (the session created when the
user communicates through the Flash banner object with the Domino Agent
element). To mirror the GET method, we'll actually tell Flash to load an
external movie via the loadMovie()
actionScript function. Once we
have successfully submitted the form data from our banner, we will progress the
animation 1 frame, which will contain our post-submission message. To do this,
we will add the following code to the button's on (release)
event:
on (release) {
var sfirstname = escape(this.name_first.text);
var slastname = escape(this.name_last.text);
var shomephone= escape(this.phone_home.text);
var semailaddress= escape(this.emailaddr.text);
var surl = "http://utilities.clearframe.com/signupexampleurl";
this.createEmptyMovieClip("SU", this.getNextHighestDepth());
SU.loadMovie(surl + "!OpenAgent&name_first=" + sfirstname +
"&name_last=" + slastname + "&phone_home=" + shomephone + "&emailaddr=" +
semailaddress + "&Source=banner", "GET");
nextFrame();
}
What we've done here is simply create an equivalent to a DOM layer in Flash
(which they refer to as Depth) to execute the launching of our external movie
via the GET method, which is actually a very simple and straight-forward call
to an agent defined in the surl
variable. From the code, you can
see that we then progress to the next frame in the Flash banner movie, which
displays a static response message. It's now up to us, at the Domino Agent
element-side of the workflow to process, to parse the information from the
Query_String parameter which you can extract from the Document Context of this
post's processing agent!
Of course, this actionScript contains no validation, so here's a look at what I used in the finished banner product, wherein we required at minimal an email address:
on (release) {
var sfirstname = escape(this.name_first.text);
var slastname = escape(this.name_last.text);
var shomephone= escape(this.phone_home.text);
var semailaddress= escape(this.emailaddr.text);
if ((semailaddress.length<6) || (semailaddress.indexOf(",")>=0) ||
(semailaddress.indexOf(";")>=0) || (semailaddress.indexOf(":")>=0) ||
(semailaddress.indexOf("/")>=0) || (semailaddress.indexOf(" ")>=0) ||
(semailaddress.indexOf("@")<=0) || (semailaddress.indexOf("@") !=
semailaddress.lastIndexOf("@")) ||
(semailaddress.lastIndexOf(".")semailaddress.length))
{
Selection.setFocus( "emailaddr" );
stop();
}
else
{
this.createEmptyMovieClip("SU",
this.getNextHighestDepth());
SU.loadMovie(surl + "!OpenAgent&name_first=" + sfirstname +
"&name_last=" + slastname + "&phone_home=" + shomephone + "&emailaddr=" +
semailaddress + "&Source=banner", "GET");
nextFrame();
}
}