Difference between revisions of "Swf.pl"

From Organic Design wiki
(Change swfd() to swfHandleRequest())
(Make frame2 reduction and go back to just peer.as)
Line 19: Line 19:
 
);
 
);
  
# Loop through peer ActionScript frames compiling each into SWF
+
# Import peer.as
my $frame = 1;
+
my $file = 'peer.as';
for ( -init, -main ) {
+
my @stat = stat( $file );
my $file = "peer$_.as";
+
$output = logAdd "Compiling \"$file\" ($stat[7] bytes)\n";
my @stat = stat( $file );
+
my $as = $swf->frame_action( 1 );
$output = logAdd "Compiling \"$file\" ($stat[7] bytes)\n";
+
$as->load( $file );
my $as = $swf->frame_action( $frame++ );
 
$as->load( $file );
 
}
 
  
# Frame 3 loops back to frame 2 (main)
+
# Frame 2: Nodal reduction (main)
 +
my $as = $swf->frame_action( 2 );
 +
$as->compile( 'space.reduce();' );
 +
 
 +
# Frame 3: Loop back to frame 2
 
my $as = $swf->frame_action(3);
 
my $as = $swf->frame_action(3);
 
$as->gotoAndPlay(2);
 
$as->gotoAndPlay(2);

Revision as of 10:10, 16 February 2006

use SWF::Builder;

  1. Process a message from SWF interface instance

sub swfHandleRequest { my $article = shift; return $article; }

  1. Compile a SWF interface for this peer

sub swfCompile {

my $output = ;

# Create new SWF movie instance my $swf= SWF::Builder->new( FrameRate => 50, FrameSize => [0, 0, 1024, 768], BackgroundColor => 'cccccc' );

# Import peer.as my $file = 'peer.as'; my @stat = stat( $file ); $output = logAdd "Compiling \"$file\" ($stat[7] bytes)\n"; my $as = $swf->frame_action( 1 ); $as->load( $file );

# Frame 2: Nodal reduction (main) my $as = $swf->frame_action( 2 ); $as->compile( 'space.reduce();' );

# Frame 3: Loop back to frame 2 my $as = $swf->frame_action(3); $as->gotoAndPlay(2);

# Output resultant SWF file $swf->save( my $file = "$::peer.swf" ); my @stat = stat( $file ); $output .= logAdd "\nSWF Instance compiled: $file ($stat[7] bytes)\n"; return $output; }