Flash-FLAP

 view release on metacpan or  search on metacpan

README.txt  view on Meta::CPAN

FLAP: Flash Remoting in Perl. 
See http://www.simonf.com/flap for more information

Version: 0.09
Date: March 13, 2003.

This is the code and several examples that show the possibility of using Perl to talk to a Macromedia Flash client using AMF (Action Message Format).

To install:

1a. If you have access to Macromedia Flash MX, load the docs/examples/cpu/CpuExample.fla file.  Edit the actions for Layer Name to use the URL of your script.

1b. If you do not have Macromedia authoringh tools, embed the
docs/examples/cpu/CpuExample.swf movie into a web page. 
Use docs/examples/cpu/cpu.html as a template. When the movie starts, enter the URL of your script into the text field.

2. Observe the load of your server when you click Refresh!

Simon Ilyushchenko

doc/cpu.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap) 
#for more information.

use strict;

=head1 COMMENT
        
    ActionScript for this service:

    #include "NetServices.as"

doc/examples/README.txt  view on Meta::CPAN


1. The "cpu" directory contains an example of simple 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...

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.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap)
#for more information.

#You have to copy the directory "basicservices" into the same directory as this script.

use strict;
use Flash::FLAP;

my $gateway = Flash::FLAP->new;
$gateway->setBaseClassPath("./basicservices/");

doc/examples/cpu/cpu.html  view on Meta::CPAN


<center>
<table width=800 cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/flap/>FLAP</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>
These are the 1, 5 and 15 minute load values on this web server. Press Refresh to see the current load.
If you want to use this on your server, but do not have Macromedia authoring tools, you can type your URL instead of the default URL that you see in this Flash movie.
<br>
<a href=cpu.pl>This is the server-side Perl script cpu.pl.</a>
</td>
<td width=400>
<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="CpuExample" width=400 height=400>
<PARAM NAME=movie VALUE="cpu.swf"> 
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>

doc/examples/cpu/cpu.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The initial code is based on the AMF-PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap) 
#for more information.

#You can pass arguments from your Flash code to the perl script.

use strict;

=head1 COMMENT
        
        ActionScript for this service:

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/flap/>FLAP</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 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>
&nbsp;&nbsp;&nbsp;
<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>

doc/examples/dataGrid/dataGrid.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap) 
#for more information.

#You can pass arguments from your Flash code to the perl script.

use strict;
use lib '/var/www/libperl';

=head1 COMMENT
        

doc/examples/petmarket/README.txt  view on Meta::CPAN

README for the server side of the Macromedia Petstore implementation

1. Sources.

The original Macromedia client can be downloaded from
http://www.macromedia.com/devnet/mx/blueprint/

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 FLAP web site:

http://www.simonf.com/flap/petmarket/

(Unlike other examples, the client is NOT included into the Flash::FLAP distribution due to its size.)

2. Usage.

doc/examples/petmarket/petmarket.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap)
#for more information.

use strict;
use Flash::FLAP;

my $gateway = Flash::FLAP->new;
$gateway->setBaseClassPath(".");
$gateway->debugDir("/tmp");
$gateway->service();

doc/examples/petmarket/petmarket/api/cartservice.pm  view on Meta::CPAN

package petmarket::api::cartservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
no warnings "uninitialized";
use strict;

use petmarket::api::dbConn;
use vars qw/@ISA/;
@ISA=("petmarket::api::dbConn");

doc/examples/petmarket/petmarket/api/catalogservice.pm  view on Meta::CPAN

package petmarket::api::catalogservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
use strict;

use petmarket::api::dbConn;
use vars qw/@ISA/;
@ISA=("petmarket::api::dbConn");

use Flash::FLAP::Util::Object;

doc/examples/petmarket/petmarket/api/dbConn.pm  view on Meta::CPAN

package petmarket::api::dbConn;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
no warnings "uninitialized";
use strict;

my $dbhost = "localhost";
my $dbname = "database";
my $dbuser = "user";
my $dbpass = "password";

doc/examples/petmarket/petmarket/api/orderservice.pm  view on Meta::CPAN

package petmarket::api::orderservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
use strict;

use petmarket::api::dbConn;
use vars qw/@ISA/;
@ISA=("petmarket::api::dbConn");

sub methodTable

doc/examples/petmarket/petmarket/api/stringresourcesservice.pm  view on Meta::CPAN

package petmarket::api::stringresourcesservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
use strict;

my %bundle;

sub new
{
    my ($proto) = @_;

doc/examples/petmarket/petmarket/api/stringresourcesservice.pm  view on Meta::CPAN

    
    return \%bundle;
}

sub getAboutUsStrings()
{
    my ($self) = @_;
    
    my %strings;
    $strings{"HEAD_str"} = "ABOUT US";
    $strings{"BODY_HTML_str"} = "The Pet Market application illustrates how Macromedia MX products work together, and integrate with standard server technologies, to deliver a rich, dynamic Internet application.\n\nWith a demo, code samples, developm...
    $strings{"logoFrameLabel"} = "macr";
    $strings{"url"} = "http://www.macromedia.com";
    
    return \%strings;
}

sub getLegalStrings()
{
    my ($self) = @_;
    my %strings;
    $strings{"HEAD_str"} = "LEGAL INFORMATION";
    $strings{"BODY_HTML_str"} = "Copyright © 2001-2002 Macromedia, Inc.  All rights reserved.  Macromedia, the Macromedia logo, and Flash are trademarks or registered trademarks of Macromedia, Inc.\n \nMany of the images used in this experience were ...
    $strings{"logoFrameLabel"} = "macr";
    $strings{"url"} = "http://www.macromedia.com";
    
    return \%strings;
}


sub getAffiliateStrings()
{
    my ($self) = @_;
    my %strings;
    $strings{"HEAD_str"} = "SITE DESIGN";
    $strings{"BODY_HTML_str"} = "We chose Popular Front to design the Pet Market shopping experience because of their demonstrated ability to enhance user experiences with our technologies. Popular Front has created numerous award-winning solutions t...
    $strings{"logoFrameLabel"} = "PopularFront";
    $strings{"url"} = "http://www.popularfront.com";
    
    return \%strings;
}



1;

doc/examples/petmarket/petmarket/api/userservice.pm  view on Meta::CPAN

package petmarket::api::userservice;

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/flap for more information.

use warnings;
use strict;

use petmarket::api::dbConn;
use vars qw/@ISA/;
@ISA=("petmarket::api::dbConn");

use Flash::FLAP::Util::Object;

doc/examples/sql/park.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/flap)
#for more information.

use strict;
use Flash::FLAP;

my $gateway = Flash::FLAP->new;
$gateway->setBaseClassPath("./parkservices/");
$gateway->debugDir("/tmp");
$gateway->service();

doc/index.html  view on Meta::CPAN

<body
 style="background-image: url(orn5.gif);">
<div style="position: absolute; left: 20px;">
<center><h1>FLAP - Flash Remoting in Perl<br>
</h1></center>
<table cellpadding="7" cellspacing="7" border="0"
 style="text-align: left">
  <tbody>
    <tr>
      <td style="vertical-align: top;width: 400px"><br>
      <h2> Open source implementation of Macromedia's AMF protocol </h2>
			</td></tr>
    <tr>
      <td style="vertical-align: top;width: 400px"><br>

      <a href="Flash-FLAP-0.09.tar.gz">Download it! Current version is
Flash-FLAP-0.09.tar.gz.</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 FLAP, 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

doc/updates.html  view on Meta::CPAN

		Aug 3, 2003. Version 0.08 uploaded. Petstore example implemented!!! Also, rewrote Flash::FLAP::new() to accept both Flash::FLAP->new and $flap->new.<br><br>

		Jul 26, 2003. Version 0.07 uploaded. Fixed a bug that would wrongly detect end-of-file in the input data on Windows and replaced the "our" keyword that is not backwards-compatible. Created pseudo_query() in Util::Object that encapsulates the record...

		Jun 22, 2003. Version 0.06 uploaded. Added an example that talks to a database on the server side. This is implemented via Flash::FLAP::Sql::MysqlRecordSet.pm. Got rid of a couple of "uninitialized" warnings.<br><br>

		Apr 29, 2003. Version 0.05 uploaded. It supports Windows and mod_perl 1.<br><br>

        Apr 14, 2003 - FLAP renamed to Flash::FLAP. Version 0.03 uploaded. Added ser
vice discovery - now you can register a directory and put Perl packages in it. Every
 package will be considered a service. Macromedia Service Browser support added.

<br>
<br>
	Mar 11, 2003 - FLAP-0.02 uploaded. Verified trasfer of basic data types from Flash to Perl. Parameters are now sent to Perl functions as an array, not an array ref.
    </tr>
  </tbody>
</table>
</div>
<br>
<br>

lib/Flash/FLAP.pm  view on Meta::CPAN

See the documentation and examples for details.

	my $flap = FLAP->new;
	$flap->setBaseClassPath('./services');
	$flap->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.




( run in 0.962 second using v1.01-cache-2.11-cpan-49f99fa48dc )