Adobe Dreamweaver Forums



Last 10 THreads :         Adobe Flash 10 kills Wimpy (Last Post : midiwriter - Replies : 81 - Views : 949 )           »          How to align XML loading text to right (Last Post : Boxing Boom - Replies : 6 - Views : 7 )           »          Why is this not working!!! (Last Post : Boxing Boom - Replies : 8 - Views : 9 )           »          Referencing stage.stageWidth from a class (Last Post : 60Day - Replies : 2 - Views : 3 )           »          XML image gallery problem (Last Post : 2le - Replies : 3 - Views : 4 )           »          ProgressBar and myPlayer (Last Post : W_Bell - Replies : 0 - Views : 1 )           »          Kintana Dummy Page (Last Post : KiahMom - Replies : 2 - Views : 3 )           »          Re: Unable to Edit Text Captions (Last Post : cegrubb - Replies : 0 - Views : 1 )           »          Performing a search within multiple .as files (Last Post : Rothrock - Replies : 2 - Views : 3 )           »          left join won't work in query of query? (Last Post : Amm85 - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 12-04-2008, 11:53 PM
SiHoop
 
Posts: n/a
Diggs:
Default Why does this run so slowly?

The code below is pretty straightforward, but it slows down remarkably quickly.
Why does this happen and is there anything I could do to speed it up?
Thanks!

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()">
<mx:UIComponent id="mainDisplay"/>
<mx:Script>
<![CDATA[
import flash.display.Shape;
import flash.events.TimerEvent;
import flash.utils.Timer;

private var shape1:Shape
private function init():void {
var myTimer:Timer = new Timer(1);
var timeInterval:int=0
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
var x:int
function timerHandler():void{
x++
timeInterval+=1
drawWedge(100,300, timeInterval, 360, 100, 100)
trace(x)
}
}
private function drawWedge(x, y, startAngle, arc, radius, yRadius):void {
var segAngle:Number
var theta:Number
var angle:Number
var angleMid:Number
var segs:Number
var ax:Number
var ay:Number
var bx:Number
var by:Number
var cx:Number
var cy:Number
// 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;
// draw the curve in segments no larger than 45 degrees.
if (segs>0) {
// draw a line from the center to the start of the curve
ax = x+Math.cos(startAngle/180*Math.PI)*radius;
ay = y+Math.sin(-startAngle/180*Math.PI)*yRadius;
shape1=new Shape
shape1.graphics.moveTo(x, y);
shape1.graphics.lineStyle(1, 0xFFff00);
shape1.graphics.lineTo(ax, ay);
// Loop for drawing curve segments
for (var i:int = 0; i<segs; i++) {
angle += theta;
angleMid = angle-(theta/2);
bx = x+Math.cos(angle)*radius;
by = y+Math.sin(angle)*yRadius;
cx = x+Math.cos(angleMid)*(radius/Math.cos(theta/2));
cy = y+Math.sin(angleMid)*(yRadius/Math.cos(theta/2));
shape1.graphics.curveTo(cx, cy, bx, by);
}
mainDisplay.addChild(shape1)
// close the wedge by drawing a line to the center
//shape1.graphics.beginFill(0xFF0000);
shape1.graphics.lineTo(x, y);
//shape1.graphics.endFill();
}
};
]]>
</mx:Script>
</mx:Application>



Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 09:06 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk