#!/usr/bin/perl -w use strict; use SWF qw(:ALL); #SWF::setScale(1.0); print "Content-type: application/x-shockwave-flash\n\n"; # movie properties #SWF::setScale(20.00000000); SWF::useSWFVersion(6); my $movie = new SWF::Movie(); $movie->setDimension(600,400); $movie->setBackground( 0xcc, 0xcc, 0xcc ); $movie->setRate(20); $movie->add( new SWF::Action(<<'EndOfActionScript') ); /*------------------------------------------------------------- mc.drawArc is a method for drawing regular and eliptical arc segments. This method replaces one I originally released to the Flash MX beta group titled arcTo and contains several optimizations based on input from the following people: Robert Penner, Eric Mueller and Michael Hurwicz. -------------------------------------------------------------*/ MovieClip.prototype.drawArc = function(x, y, radius, arc, startAngle, yRadius) { // ============== // mc.drawArc() - by Ric Ewing (ric@formequalsfunction.com) - v 1.5 - 4.7.2002 // // x, y = This must be the current pen position... other values will look bad // radius = radius of Arc. If [optional] yRadius is defined, then r is // the x radius // arc = sweep of the arc. Negative values draw clockwise. // startAngle = starting angle in degrees. // yRadius = [optional] y radius of arc. Thanks to Robert Penner for the idea. // ============== // Thanks to: Robert Penner, Eric Mueller and Michael Hurwicz for their cont // ============== if (arguments.length<5) { return; } // if yRadius is undefined, yRadius = radius if (yRadius == undefined) { yRadius = radius; } // Init vars var segAngle, theta, angle, angleMid, segs, ax, ay, bx, by, cx, cy; // no sense in drawing more than is needed :) if (Math.abs(arc)>360) { arc = 360; } // Flash uses 8 segments per circle, to match that, we draw in a maximum // of 45 degree segments. First we calculate how many segments are needed // for our arc. segs = Math.ceil(Math.abs(arc)/45); // Now calculate the sweep of each segment segAngle = arc/segs; // The math requires radians rather than degrees. To convert from degrees // use the formula (degrees/180)*Math.PI to get radians. theta = -(segAngle/180)*Math.PI; // convert angle startAngle to radians angle = -(startAngle/180)*Math.PI; // find our starting points (ax,ay) relative to the secified x,y ax = x-Math.cos(angle)*radius; ay = y-Math.sin(angle)*yRadius; // if our arc is larger than 45 degrees, draw as 45 degree segments // so that we match Flashs native circle routines. if (segs>0) { // Loop for drawing arc segments for (var i = 0; i 120 ) { arc = 120; } if( arc <= 0 ) { arc = 1; } var radius = Math.ceil( (y/400) * 150 ); var testarc = this.createEmptyMovieClip( "testarc", 10 ); //testarc.lineStyle( 1, 0x666666, 50 ); //testarc.moveTo( 300,200 ); //testarc.lineTo( 300,300 ); testarc.lineStyle( 3, 0x0000aa, 90 ); testarc.MoveTo( 300,200 ); testarc.lineTo( 200,200 ); testarc.MoveTo( 300,200 ); testarc.lineStyle( 3, 0x0000aa, 90 ); //testarc.beginFill( 0xcc0000, 50 ); var endpoint = testarc.drawArc( 300,200, radius, arc, 270, undefined ); testarc.moveTo( endpoint.x, endpoint.y ); testarc.lineTo( endpoint.x+100, endpoint.y); testarc.moveTo( 200,200 ); var endpoint = testarc.drawArc( 200,200, radius, -arc, 270, undefined ); testarc.moveTo( endpoint.x, endpoint.y ); testarc.lineTo( endpoint.x-100, endpoint.y); //testarc.endFill(); tfStatus.text = "click-n-drag: arc = "+arc+" degrees, radius = "+radius; }; doarc( 200,200 ); funclist = { onMouseUp: function () { draw=false; }, onMouseDown: function () { draw=true; }, onMouseMove: function () { if( draw ) { doarc(_xmouse,_ymouse); } } }; Mouse.addListener(funclist); EndOfActionScript $movie->output();