Turbine
includes a set of commands designed to simplify common development
tasks - for example displaying a list of links can be done with the
<AutoMovieClip> MML command. Let's see an example of this in
action, starting by simple movie clip with a button:
Although
we could easily create the movieclip and button visually on a Flash
editor, we'll create it in MML, by using a <Movieclip>, <Button>
and <TextField> tags:
<Movieclip
id="button_movieclip_id">
<Button>
<State
type="up,hit"> <!--
these are the up/hit button states -->
<Shape>
<LineStyle
color="#404080" width="4"/>
<FillColor
color="#8080ff"/>
<Rect
size="220,50"/>
</Shape>
</State>
<State
type="over,down"> <!--
the over/down button states -->
<Shape>
<LineStyle
color="#8080dd" width="4"/>
<FillColor
color="#ddddff"/>
<Rect
size="220,50"/>
</Shape>
</State>
<Audio event="MouseOver"
src="tick.wav"/> <!--
a tick sound -->
<Script
event="Release"> <!--
getUrl to the button_url AS var -->
getUrl(button_url,
"_blank");
</Script>
</Button>
<!--
the button text label, with the button_label AS var
-->
<TextField variable="button_label"
pos="0,12"
size="220,30"
fontSize="20"
align="center"
flags="noSelect,readOnly">default
label</TextField>
</Movieclip>
The first
movie above was displayed by simply loading the above MML file.
Let's
now create the DataSet that will be used to display a number of instances
of this button - it will be loacted in the buttons_dataset.txt:
<button_label,
button_url>
"Dingo
Industries",
"http://www.example.com/?dingo"
"Lagoon
Supermarket",
"http://www.example.com/?lagoon"
"Martinica
Bar",
"http://www.example.com/?martinica"
"Dragon
Lounge",
"http://www.example.com/?dragon"
"Blue
Pasteur, inc",
"http://www.example.com/?pasteur"
"Sri Lanka
Bar",
"http://www.example.com/?sri"
"Sunday
Road inc.",
"http://www.example.com/?sunday"
"Bay Records",
"http://www.example.com/?bay"
"Friday
Bank",
"http://www.example.com/?friday"
"Global
Cloud Ltd.",
"http://www.example.com/?cloud"
"Beethoven
Sings, inc",
"http://www.example.com/?beethoven"
"Fill
Max inc.",
"http://www.example.com/?fill"
The above DataSet will be used by this <AutoMovieClip> MML command:
We have
two choices where to issue this command - either in the MML where
the button/movieclip is defined or on the .aspx script - let's issue
it from our script(automovieclip1.aspx):
<%@
Page language="c#" %>
<%
// create the Turbine object:
Turbine.Turbine7 Turbine = new Turbine.Turbine7();
//
load DataSet from the buttons_dataset.txt file:
Turbine.LoadDataSet("buttons_dataset.txt", "buttonsDataSet");
//
include movieclip.mml:
Turbine.Include("movieclip.mml");
//
create an <AutoMovieClip> tag:
Turbine.Create("<AutoMovieClip dataSet='buttonsDataSet'
defaultId='button_movieclip_id' defaultDy='56'/>");
//
now generate the movie to the web browser
Turbine.GenerateFlash();
%>
And we'll obtain the following Flash movie:
We have a problem
with the number of movie clips, which are too large to fit in a reasonable
size (and besides the number might grow as we change the DataSet)
- so add a Flash component that provides us with scrolling capabilities
- we can use the ScrollPane component from the "Flash UI Components
Set 2". We can add this component by drag'm'dropping an instance
of the component into an empty Flash .swf, and then simply including
it on our .aspx script here's our new script (automovieclip2.aspx):
<%@ Page language="c#"
%>
<%
// create the Turbine object:
Turbine.Turbine7 Turbine = new Turbine.Turbine7();
//
load DataSet from the buttons_dataset.txt file:
Turbine.LoadDataSet("buttons_dataset.txt", "buttonsDataSet");
//
include movieclip.mml:
Turbine.Include("movieclip.mml");
//
include the ScrollPane component:
Turbine.Include("scrollpane.swf");
//
place a ScrollPane component referring to the automovieclip_buttons
id we created above:
Turbine.Create("<Place
component='ScrollPane' size='240,222'><Param name='Scroll
Content' value='automovieclip_buttons'/></Place>");
//
now generate the movie to the web browser
Turbine.GenerateFlash();
%>
With
the above script we'll obtain a scrollable panel with our AutoMovieClip
generated movie clips:
A list
is nice - but let's now create a grid of movie clips. We can do this
easily with the <AutoMovieClip> tag by adding the cols and few
more attributes - arriving at the following <AutoMovieClip>
tag (created form the .aspx script):
And we'll
obtain the following movie (automovieclip3.aspx):
Hummm,
we again have a problem with sizes... Well, let's add the ScrollPane
component and it will be easily solved (automovieclip4.aspx):
Besides
the <AutoMovieClip> command, Turbine includes the <AutoImage>
command, that can create lists/grids of images, and the very powerful
<AutoMedia>, that can automate the display of any element type
- text, buttons, images - in fact, anything element possible in MML.