Difference between revisions of "Swf.pl"

From Organic Design wiki
m
(Compile from "init" and "main" frames)
Line 8: Line 8:
 
sub swfCompile {
 
sub swfCompile {
  
# Read peer.as source script
+
my $output = '';
my $as = readFile( my $file = 'peer.as' );
 
my @stat = stat( $file );
 
my $output = logAdd "Compiling from \"$file\" ($stat[7] bytes)\n\n";
 
  
 +
# Create new SWF movie instance
 
my $swf= SWF::Builder->new(
 
my $swf= SWF::Builder->new(
 
FrameRate => 50,
 
FrameRate => 50,
FrameSize => [0, 0, 640, 480],
+
FrameSize => [0, 0, 1024, 768],
 
BackgroundColor => 'cccccc'
 
BackgroundColor => 'cccccc'
 
);
 
);
  
# Red triangle
+
# Loop through peer ActionScript frames compiling each into SWF
my $shape = $swf->new_shape
+
my $frame = 1;
->fillstyle('ffffff')
+
for ( -init, -main ) {
->linestyle(1, '000000')
+
my $file = "peer$_.as";
->moveto(0,-11)
+
my @stat = stat( $file );
->lineto(10,6)
+
$output = logAdd "Compiling \"$file\" ($stat[7] bytes)\n";
->lineto(-10,6)
+
my $as = $swf->frame_action( $frame++ );
->lineto(0,-11);
+
$as->load( $file );
my $instance = $shape->place;
+
}
  
for ( my $x = 0; $x < 400; $x++ ) { $instance->rotate(15)->moveto( $x, 200 ) }
+
# Frame 3 loops back to frame 2 (main)
 +
my $as = $swf->frame_action(3);
 +
$as->gotoAndPlay(2);
  
 +
# Output resultant SWF file
 
$swf->save( $file = "$::peer.swf" );
 
$swf->save( $file = "$::peer.swf" );
 
@stat = stat( $file );
 
@stat = stat( $file );
$output .= logAdd "SWF Instance compiled: $file ($stat[7] bytes)\n";
+
$output .= logAdd "\nSWF Instance compiled: $file ($stat[7] bytes)\n";
 
return $output;
 
return $output;
 
}
 
}

Revision as of 02:57, 16 February 2006

use SWF::Builder;

  1. We may use a dedicated child for serving SWF requests

sub swfd { }

  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' );

# Loop through peer ActionScript frames compiling each into SWF my $frame = 1; for ( -init, -main ) { my $file = "peer$_.as"; my @stat = stat( $file ); $output = logAdd "Compiling \"$file\" ($stat[7] bytes)\n"; my $as = $swf->frame_action( $frame++ ); $as->load( $file ); }

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

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