view release on metacpan or search on metacpan
Revision history for Perl extension AMF::Perl.
0.15 Sun Sep 19 13:01:35 EDT 2004
Converted examples (except for Petmarket) to ActionScript 2.0 under Flash MX 2004.
Patches from Kostas Chatzikokolakis about error checking of input data length.
WriteUTF() writes the string length as long for lengths > 65535.
Also, check for (defined $s) and not just ($s) in writeUTF.
0.14 Sun Jul 11 18:59:36 EDT 2004
Really fixed the number 16 issue (forgot to include the change in 0.13).
Added Richard Boulton's change to readDouble() and writeDouble() to take into account endian-ness.
Changed the behavior of amf_throw() to enable die() to work.
0.13 Sun Jun 20 15:52:57 EDT 2004
Started duplicating changes in this file.
doc/code.html
doc/encoding.html
doc/cpu.pl
doc/index.html
doc/orn5.gif
doc/examples/README.txt
doc/examples/cpu/cpu.pl
doc/examples/cpu/cpu.fla
doc/examples/cpu/cpu.swf
doc/examples/cpu/cpu.html
doc/examples/dataGrid/dataGrid.pl
doc/examples/dataGrid/dataGrid.swf
doc/examples/dataGrid/dataGrid.html
doc/examples/basic/README.txt
doc/examples/basic/basic.fla
doc/examples/basic/basic.swf
doc/examples/basic/basic.html
doc/examples/basic/basic.pl
doc/examples/basic/basicservices/DataEcho.pm
doc/examples/sql/DataGlue.as
doc/examples/sql/README.txt
doc/examples/sql/park.fla
doc/examples/sql/park.html
doc/encoding.html view on Meta::CPAN
<h2>Using non-standard encoding</h2>
Kostas Chatzikokolakis submitted a patch with the following explanation:
<br>
All data in flash remoting are sent as unicode. However, database data
and scripts are usually in a local encoding. I made some enhacements to
AMF::Perl so that it automatically converts all strings to utf8 when sending
and back to the given encoding when receiving. The usage is:
<pre>
my $gateway = new AMF::Perl;
$gateway->encoding("iso-8859-7");
$gateway->setBaseClassPath("Services/");
$gateway->service();
</pre>
doc/examples/README.txt view on Meta::CPAN
AMF::Perl: Flash Remoting in Perl.
See http://www.simonf.com/amfperl for more information
Version: 0.09
Date: March 13, 2004.
1. The "cpu" directory contains an example of simple object registration that returns a complex data structure (array of hashes). The Flash movies shows a bar chart of the current server load as reported by uptime.
2. The "datagrid" directory is an example of using an advanced GUI control in a Flash movie.
3. The "basic" directory shows how data is passed from the client to the server and back. This example employs the advanced service registration when you register a directory and all Perl packages in that directory are automatically considered as ser...
It also shows how to throw exceptions via amf_throw.
4. The "sql" directory is the Parkservice example (borrowed from AMFPHP). It
uses SQL queries.
5. The "petmarket" directory is the Perl implementation of the Macromedia
Petmarket.
Simon Ilyushchenko
doc/examples/basic/basic.html view on Meta::CPAN
<body>
<center>
<table cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/amfperl/>AMF::Perl</a> in action.</H2>
<br>
<p>
Download Flash 7 player from <a href="http://www.macromedia.com/shockwave/download/alternates/">here</a> if you don't have it. It even works on Linux!
<p>
This shows various data types passed through AMF to the perl backend and sent back.
The most interesting this is not so much what it does, but how it works. The Perl script utilizes the "service discovery" approach - you simply put Perl modules into a certain directory, and they are automatically registered as services.
<br><br>
This example also shows how to throw exceptions, handled by functionName_onStatus in the Flash client (as opposed to functionName_onResult, which is called normally). Simply include in your Perl code
<pre>
use AMF::Perl qw/amf_throw/;
</pre>
and then call <em>amf_throw()</em> with a string or an arbitrary object as a parameter.
<br><br>
If you call <em>die "Error message"</em>, it will be also caught in the same way and sent as an error to Flash.
doc/examples/basic/basicservices/DataEcho.pm view on Meta::CPAN
},
"generateError" => {
"description" => "Throw an error so that _status, not _result on the client side is called",
"access" => "remote", # available values are private, public, remote
},
};
}
sub echoNormal
{
my ($self, $data) = @_;
return $data;
}
sub echoDate
{
my ($self, $data) = @_;
return $data;
}
sub echoXML
{
my ($self, $data) = @_;
return $data;
}
#This function will NOT return the value, because the call to amf_throw() will interrupt
#the control flow and cause the _Status function on the client to be called.
sub generateError
{
my ($self, $data) = @_;
amf_throw("An error!!!");
return "No error";
}
1;
doc/examples/dataGrid/dataGrid.html view on Meta::CPAN
<center>
<table cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/amfperl/>AMF::Perl</a> in action.</H2>
<br>
<p>
Download Flash 7 player from <a href="http://www.macromedia.com/shockwave/download/alternates/">here</a> if you don't have it. It even works on Linux!
<p>
This is an example of a GUI control (Data Grid) that would be non-trivial to implement in straight HTML. Note that by clicking on column headers the values are sorted by that column, and the columns can be resized. Click on a grid row to open the bro...
<br>
The datagrid component is not freely available, unfortunately. You can buy it <a href=http://www.macromedia.com/software/drk/productinfo/all_volumes/>here from Macromedia</a>.
<br><br>
<a href=dataGrid.pl>This is the server-side Perl script dataGrid.pl.</a>
</td>
<td width=600>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" id="DataGrid" width=550 height=350>
<PARAM NAME=movie VALUE="dataGrid.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="dataGrid.swf" quality=high bgcolor=#FFFFFF width=550 height=350
NAME="DataGrid" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</td>
</tr></table>
</center>
</body>
</html>
doc/examples/petmarket/README.txt view on Meta::CPAN
There are a few steps to get it working - you need to compile each movie separately, for example.
To make thing easier, a fully precompiled client side is provided at the AMF::Perl web site:
http://www.simonf.com/amfperl/examples/petmarket/index.html
(Unlike other examples, the client is NOT included into the AMF::Perl distribution due to its size.)
2. Usage.
You need to load the data in petmarket.sql into a database and configure
the database server, name username and password in dbConn.pm.
You HAVE to set your server URL in initFunction/mainInit.as and then recompile main.fla in order to point your
client to your server.
3. Notes about implementation.
You HAVE to have these files in the directory petmarket/api relative to your Perl gateway script,
because this is what the Flash client assumes.
doc/examples/petmarket/petmarket.sql view on Meta::CPAN
-- Table structure for table 'cart_details'
--
CREATE TABLE cart_details (
cartid varchar(100) default NULL,
itemid varchar(10) default NULL,
quantity int(11) default NULL
) TYPE=MyISAM;
--
-- Dumping data for table 'cart_details'
--
--
-- Table structure for table 'category'
--
CREATE TABLE category (
catid varchar(10) NOT NULL default ''
) TYPE=MyISAM;
--
-- Dumping data for table 'category'
--
INSERT INTO category VALUES ('BIRDS');
INSERT INTO category VALUES ('REPTILES');
INSERT INTO category VALUES ('DOGS');
INSERT INTO category VALUES ('FISH');
INSERT INTO category VALUES ('CATS');
--
doc/examples/petmarket/petmarket/api/stringresourcesservice.pm view on Meta::CPAN
$strings{"VALIDATE_SELECT_CC_MO_ERROR_MSG_str"}="Please select a credit card expiry month from the list.";
$strings{"VALIDATE_SELECT_CC_YR_ERROR_MSG_str"}="Please select a credit card expiry year from the list.";
$strings{"VALIDATE_CC_EXPIRED_ERROR_MSG_str"}="Please select a credit card expiry date that is not in the past.";
$strings{"VALIDATE_INVALID_CC_ERROR_MSG_str"}="Invalid credit card number. Please enter valid credit card number.";
$strings{"VALIDATE_PAYMENT_ERROR_TITLE_str"}="Payment Method Error";
$strings{"CREATE_USER_PROGRESS_TITLE_str"}="Creating account";
$strings{"CREATE_USER_PROGRESS_MSG_str"}="Account creation in progress, please wait.";
$strings{"LOGIN_USER_PROGRESS_TITLE_str"}="Logging in";
$strings{"LOGIN_USER_PROGRESS_MSG_str"}="Login in progress, please wait.";
$strings{"SUBMITTING_ORDER_PROGRESS_TITLE_str"}="Submitting order";
$strings{"SUBMITTING_USER_PROGRESS_MSG_str"}="Order submission in progress: sending user data.\n\nPlease wait.";
$strings{"SUBMITTING_ORDER_PROGRESS_MSG_str"}="Order submission in progress: sending order info.\n\nPlease wait.";
$strings{"CONFIRM_ORDER_TITLE_str"}="Thank You";
$strings{"CONFIRM_ORDER_MSG_str"}="Thank you for shopping at Pet Market. If this were a real pet store, your order would be completed.";
$strings{"AFFILIATE_BTN_LBL_str"}="affiliate program";
$strings{"LEGAL_NOTICES_BTN_LBL_str"}="legal notices";
$strings{"ABOUT_US_BTN_LBL_str"}="about us";
$strings{"HOME_BTN_LBL_str"}="home";
$strings{"EXP_MONTH_CHOOSE_str"}="Month...";
$strings{"EXP_YEAR_CHOOSE_str"}="Year...";
doc/examples/sql/DataGlue.as view on Meta::CPAN
// test w/ combobox, listbox, tree, chart?
_global.DataGlue = function(dataProvider)
{
this.dataProvider = dataProvider;
}
// specify a format string for each line of text
_global.DataGlue.bindFormatStrings = function (dataConsumer, dataProvider, labelString, dataString)
{
var proxy = new DataGlue(dataProvider);
proxy.labelString = labelString;
proxy.dataString = dataString;
proxy.getItemAt = _global.DataGlue.getItemAt_FormatString;
dataConsumer.setDataProvider(proxy);
}
// let a user-supplied function handle formatting of each data record
_global.DataGlue.bindFormatFunction = function (dataConsumer, dataProvider, formatFunction)
{
var proxy = new DataGlue(dataProvider);
proxy.formatFunction = formatFunction;
proxy.getItemAt = _global.DataGlue.getItemAt_FormatFunction;
dataConsumer.setDataProvider(proxy);
}
_global.DataGlue.prototype.addView = function(viewRef)
{
return this.dataProvider.addView(viewRef);
}
_global.DataGlue.prototype.getLength = function()
{
return this.dataProvider.getLength();
}
_global.DataGlue.prototype.format = function(formatString, record)
{
var tokens = formatString.split("#");
var result = "";
for (var i = 0; i < tokens.length; i += 2)
{
result += tokens[i];
result += (tokens[i+1] == "") ? "#" : record[tokens[i+1]];
}
return result;
}
_global.DataGlue.getItemAt_FormatString = function(index)
{
var record = this.dataProvider.getItemAt(index);
if (record == "in progress" || record==undefined)
return record;
return {label: this.format(this.labelString, record), data: (this.dataString == null) ? record : this.format(this.dataString, record)};
}
_global.DataGlue.getItemAt_FormatFunction = function(index)
{
var record = this.dataProvider.getItemAt(index);
if (record == "in progress" || record==undefined)
return record;
return this.formatFunction(record);
}
_global.DataGlue.prototype.getItemID = function(index)
{
return this.dataProvider.getItemID(index);
}
_global.DataGlue.prototype.addItemAt = function(index, value)
{
return this.dataProvider.addItemAt(index, value);
}
_global.DataGlue.prototype.addItem = function(value)
{
return this.dataProvider.addItem(value);
}
_global.DataGlue.prototype.removeItemAt = function(index)
{
return this.dataProvider.removeItemAt(index);
}
_global.DataGlue.prototype.removeAll = function()
{
return this.dataProvider.removeAll();
}
_global.DataGlue.prototype.replaceItemAt = function(index, itemObj)
{
return this.dataProvider.replaceItemAt(index, itemObj);
}
_global.DataGlue.prototype.sortItemsBy = function(fieldName, order)
{
return this.dataProvider.sortItemsBy(fieldName, order);
}
doc/examples/sql/README.txt view on Meta::CPAN
Installation notes on the ParkServices example.
1. Make sure you have access to a mysql database and that the DBI and DBD::Mysql modules are installed.
2. Import the park.sql script into your database.
3. Don't forget to put DataGlue.as in the same directory as the Flash movie.
4. Recompile the Flash movie to point to the location of your park.pl script.
Note that normally AMF::Perl tries to guess whether you are sending a number.
And if the database used is Mysql, AMF::Perl will retrieve column types
from the statement handle. This is done so that the server could send back
primitive data types in a recordset as numbers or strings avoiding the
guessing (which may be wrong if you do intend to send a number as a string).
doc/examples/sql/park.html view on Meta::CPAN
<body>
<center>
<table cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/amfperl/>AMF::Perl</a> in action.</H2>
<br>
<p>
Download Flash 6 player from <a href="http://www.macromedia.com/shockwave/download/alternates/">here</a> if you don't have it. It even works on Linux!
<p>
This is an example accessing a mysql database on the server side (taken from AMFPHP).
<br><br>
<a href=park.pl>This is the server-side Perl script park.pl.</a>
<a href=parkservices/ParkService.pm>This is a sample service ParkService.pm.</a>
</td>
<td width=600>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" id="park" width=550 height=350>
<PARAM NAME=movie VALUE="park.swf">
<PARAM NAME=quality VALUE=high>
doc/examples/sql/park.sql view on Meta::CPAN
ZIPCODE text,
COMPHONE text,
REGION text,
SUPTMGR text,
OFFHRS text,
DATEESTB text,
PARKTYPE text
) TYPE=MyISAM;
--
-- Dumping data for table 'tblparks'
--
INSERT INTO tblparks VALUES ('ARAHAM LINCOLN BIRTHPLACE NHS','2995 LINCOLN FARM ROAD','','','HODGENVILLE','KY','42748','502-358-3874','Southeast Region','Link, Carolyn E.','8:00 AM TO 4:45 PM','07/17/1916','National Historical Site');
INSERT INTO tblparks VALUES ('ADAMS NATIONAL HISTORIC SITE','P.O. BOX 531, 135 ADAMS STREET','','','QUINCY','MA','02269-0531','617-773-1177','NORTH ATLANTIC REGION','Peak, Marianne Potts','9:00 AM TO 5:00 PM','12/09/1946','NATIONAL HISTORICAL SITE');...
INSERT INTO tblparks VALUES ('AGATE FOSSIL BEDS NATIONAL MONUMENT','C/O SCOTTS BLUFF NATIONAL MONUMENT','P.O. BOX 27','','GERING','NE','69341-0027','308-668-2211','MIDWEST REGION','LARRY D. REED','8:00 AM TO 5:00 PM','09/26/1970','NATIONAL MONUMENT')...
INSERT INTO tblparks VALUES ('ALAGNAK WILD RIVER','C/O KATMAI NATIONAL PARK','P.O. BOX 7','','KING SALMON','AK','99613','907-246-3305','Alaska Region','BILL PIERCE','','12/02/1980','National (Wild/Senic River (Way)');
INSERT INTO tblparks VALUES ('ALASKA PUBLIC LANDS INFO CTR - ANCHORAGE','605 W. 4TH AVENUE, SUITE 105','','','ANCHORAGE','AK','99501','907-271-2737','Alaska Region','Morris, John, Acting','','08/01/1987','Miscellaneous');
INSERT INTO tblparks VALUES ('ALASKA PUBLIC LANDS INFO CTR - FAIRBANKS','250 CUSHMAN ST., SUITE 1A','','','FAIRBANKS','AK','99701','907-456-0527','Alaska Region','ROSSINI, ELIZABETH','10:00 AM TO 7:00 PM','10/13/1982','Miscellaneous');
INSERT INTO tblparks VALUES ('ALASKA REGIONAL OFFICE','NATIONAL PARK SERVICE','2525 GAMBELL STREET, ROOM 107','','ANCHORAGE','AK','99503','907-257-2690','Alaska Region','Robert D. Barber','7:30 AM TO 4:30 PM','12/03/1980','Regional Office');
doc/examples/sql/parkservices/ParkService.pm view on Meta::CPAN
package ParkService;
use warnings;
use strict;
use AMF::Perl::Sql::MysqlRecordSet;
my $dbhost = "localhost";
my $dbname = "database";
my $dbuser = "user";
my $dbpass = "password";
use DBI;
sub new
{
my ($proto) = @_;
my $self = {};
bless $self, $proto;
doc/index.html view on Meta::CPAN
<br>
September 19, 2004. <a href="AMF-0.04.tar.gz">An alpha implementation of AMF in <B style="color:black;background-color:#A0FFFF">Python</B>. Version 0.04.</a>
<br><br>
<a href="code.html">Usage instructions and code samples.</a><br>
<br>
<h2>What is this?</h2>
<h3> Short version<br>
</h3>
<a href="http://www.macromedia.com/software/flashremoting/">Flash
Remoting</a> is a way for Flash movies running in a web browser to
request structured data from the web server. The following data types
are supported - strings, numbers, dates, arrays, dictionaries/hashes,
objects, recordsets. Flash clients talk with the server using the AMF
protocol, which is proprietary to Macromedia. However, it's not that
hard to decode. <br>
<br>
Using AMF::Perl, it is possible to send arbitrary
data between client and server using very few lines of code. There is no
need to pack complicated data structures into CGI form parameteres or
XML strings. The coding time can be spent on better things - data
preparation and graphical presentation, not data delivery.<br>
<br>
<h3>Long version</h3>
<p>HTML forms are ugly. HTML itself is not well suited for presenting
data. Everybody knows that but still uses them. However, the Rich
Internet Client is back and it gets adopted more and more. In
part this has to do with Macromedia's eforts. <br>
<br>
<p>Macromedia Flash has matured enough to <br>
a) allow developers to build rich, visually attractive user interfaces
and <br>
b) receive data from the server in a convenient way.<br>
<p>But if you believe in the idea of more and more programmers
taking a shot at developing clients in Flash, you must also see the need
for a good data gateway between web clients (the Flash movie) and web
servers. Macromedia offers just that in Macromedia Flash Remoting,
available for ColdFusion, JRun, .NET, J2EE. </p>
<p>The Macromedia development tools are neither free nor
open-source. The server costs go into thousands. (There are
fully-fuctional trial versions available, though.)<br>
However, by using Perl to implement the server-side part of the
gateway, that part of the solution becomes free.<br>
</p>
<p> <a href="http://www.macromedia.com/software/flashremoting/">Flash
Remoting</a> protocol (AMF) is similar to SOAP, but the protocol
complexities are hidden from the developer. On the client side you call
a local function, and your call is passed to the corresponding function
on the server. Another function, a callback, is invoked by the framework
when the data is received. On the server side you provide a handler
with a certain name that registers certain functions, available to be
used by the client. Everything on the server side is within the syntax
of the server language. The client side uses ActionScript. <a
href="code.html">This is what the code looks like.</a><br>
To build/export .swf files with Flash Remoting, you need to install
Flash Remoting MX Components for free at:<br>
http://www.macromedia.com/software/flashremoting/downloads/components/
<br>
This will install the scripts "NetServices.as" and "NetDebug.as" that are
used in the ActionScript.
lib/AMF/Perl.pm view on Meta::CPAN
$gateway->service();
=head1 ABSTRACT
Macromedia Flash Remoting server-side support.
=head1 DESCRIPTION
This file accepts the data and deserializes it using the InputStream and Deserializer classes.
Then the gateway builds the executive class which then loads the targeted class file
and executes the targeted method via flash remoting.
After the target uri executes the the gateway determines the data type of the data
and serializes and returns the data back to the client.
=head2 EXPORT
None by default.
=head1 SEE ALSO
There is a mailing list for AMF::Perl. You can subscribe here:
http://lists.sourceforge.net/lists/listinfo/flaph-general
lib/AMF/Perl/Sql/MysqlRecordSet.pm view on Meta::CPAN
my $columnNames = $sth->{NAME};
my $columnTypes = $sth->{TYPE};
# grab all of the rows
# There is a reason arrayref is not used - if it is,
#the pointer is reused and only the last element gets added, though many times.
while (my @array = $sth->fetchrow_array)
{
# add each row to the initial data array
push @initialData, \@array;
}
return AMF::Perl::Util::Object->pseudo_query($columnNames, \@initialData, $columnTypes);
}
1;
lib/AMF/Perl/Util/Object.pm view on Meta::CPAN
# returns the body element at a specific index
sub getBodyAt
{
my ($self, $id)=@_;
$id=0 unless $id;
return $self->{_bodies}->[$id];
}
sub pseudo_query
{
my ($self, $columnNames, $data, $columnTypes) = @_;
my $result = new AMF::Perl::Util::Object;
# create the serverInfo array
$result->{"serverInfo"} = {};
# create an initialData array
my (@initialData, @columnNames);
$result->{serverInfo}->{initialData} = $data;
$result->{serverInfo}->{columnNames} = $columnNames;
$result->{serverInfo}->{totalCount}= scalar @$data;
# create the id field --> i think this is used for pageable recordsets
$result->{"serverInfo"}->{"id"} = "AMF::Perl";
$result->{"serverInfo"}->{"cursor"} = 1; # maybe the current record ????
$result->{"serverInfo"}->{"serviceName"} = "doStuff"; # in CF this is PageAbleResult not here
# versioning
$result->{"serverInfo"}->{"version"} = 1;
$result->{_explicitType}='RecordSet';
view all matches for this distributionview release on metacpan - search on metacpan