random


18
Feb 10

Is flex timer Accurate?

Would you would expect timers in ActionScript 3.0 to be accurate??

“yes, of course!” But there’s a problem:

If you set a Timer to go off indefinitely (i.e., with a repeatCount of 0), it appears that the timer doesn’t start the next interval until the listener function returns. So if you don’t correct for this, then your timer function will creep by the duration of the listener function. If your listener function does something that’s potentially lengthy, you might want to execute it with a callLater() so that the timer isn’t affected. But the timer will still creep unless you apply a correction. Here’s some sample code that demonstrates the effect, side-by-side with a correction.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
< ?xml version="1.0" encoding="utf-8"?>
<mx :Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="{onCreationComplete(event)}">
    </mx><mx :Script>
        < ![CDATA[
            import mx.utils.StringUtil;
            import mx.events.FlexEvent;
            private const BASE_INTERVAL:Number = 1000;
            private var _creepingTimer:Timer = new Timer(BASE_INTERVAL);
            private var _steadyTimer:Timer = new Timer(BASE_INTERVAL);
            private var _startTime:Date;
 
            private function onCreationComplete(e:FlexEvent) : void
            {
                _creepingTimer.addEventListener(TimerEvent.TIMER, onCreepingTimer);
                _creepingTimer.start();
                _steadyTimer.addEventListener(TimerEvent.TIMER, onSteadyTimer);
                _steadyTimer.start();
                _startTime = new Date();
            }
 
            private function onCreepingTimer(e:TimerEvent) : void
            {
                var now:Date = new Date();
                var deltaMS:int = now.time - _startTime.time;
                uiCreepingLog.text += StringUtil.substitute("\r{0}", deltaMS);
            }
 
            private function onSteadyTimer(e:TimerEvent) : void
            {
                var now:Date = new Date();
                var deltaMS:int = now.time - _startTime.time;
                uiSteadyLog.text += StringUtil.substitute("\r{0}", deltaMS);
                var offset:int = deltaMS % BASE_INTERVAL;
                _steadyTimer.delay = offset < 500 ? BASE_INTERVAL - offset : BASE_INTERVAL;
            }
 
 
        ]]>
    </mx>
    <mx :HBox width="100%" height="100%">
        <mx :TextArea id="uiCreepingLog" width="50%" height="100%" text="Creeping timer:"/>
        <mx :TextArea id="uiSteadyLog" width="50%" height="100%" text="Steady timer:"/>
    </mx>

read the orignal post at : joy of flex

Share:
  • DZone
  • Digg
  • Twitter
  • Google Bookmarks
  • Technorati
  • StumbleUpon
  • MySpace
  • Sphinn
  • del.icio.us
  • Facebook
  • Reddit
  • Mixx

18
Feb 10

Geometry 3 points in line test

inLine

GeometryMath.isLine() static function tests 3 Points and returns true if these points are in line. Optional 4th parameter defines if you require point2 to be in the middle between 1 and 3. Function is not based on vector algorithm, but on triangle equation. This simple function was developed in order to optimize number of points necessary to draw some paths. To draw a line, you do not need all the points, you can omit all the middle points that are on the same line and the result looks the same – optimizes performance or storage.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public static function isLine(point1:Point, point2:Point,
point3:Point, orderSensitive:Boolean = true):Boolean
{
var x1:Number = point1.x - point2.x;
var x2:Number = point2.x - point3.x;
var y1:Number = point1.y - point2.y;
var y2:Number = point2.y - point3.y;

if(orderSensitive &amp;&amp; ((x1 &gt; 0 &amp;&amp; x2 &lt; 0) || (x1 &lt; 0 &amp;&amp; x2 &gt; 0)
|| (y1 &lt; 0 &amp;&amp; y2 &gt; 0) || (y1 &lt; 0 &amp;&amp; y2 &gt; 0)))
return false;
else if(!y2)
return !y1;
else if(!x2)
return !x1;
else
return x1 / x2 == y1 / y2;
}
Share:
  • DZone
  • Digg
  • Twitter
  • Google Bookmarks
  • Technorati
  • StumbleUpon
  • MySpace
  • Sphinn
  • del.icio.us
  • Facebook
  • Reddit
  • Mixx

17
Feb 10

Did Google copy flex charts from wordpress??

Google just did a makeover on their Google Analytics package, completely revamping their UI. We won’t get to play with it for a while, though, because they’re slowing rolling out the new version across all their myriad users. Undoubtedly this strategy has two business-centric side effects:

  1. With a slow rollout, they can fix any bugs in the application which they might have overlooked. By the time the 95% start to use it, the 5% will have made it perfect.
  2. They can make it sure it scales. As they add site after site, they can accurately measure how much of their distributed grid will have to power the new, heavier UI.

google-stats.jpg

I don’t have access to a live version, but this screenshot looks a lot the newly announced free stat tracking app from WordPress. For comparison, here’s a screenshot from their web page:

wp-stats.png

I won’t argue that they’re the same, but the style is similar–and WordPress came way first. Copying or unconscious emulation? You decide.

Share:
  • DZone
  • Digg
  • Twitter
  • Google Bookmarks
  • Technorati
  • StumbleUpon
  • MySpace
  • Sphinn
  • del.icio.us
  • Facebook
  • Reddit
  • Mixx

25
Sep 09

doing nothing!

I got the Swine flu sad

well was browsing through a few examples and saw a datagrid pagination example.

check it out  here.

Share:
  • DZone
  • Digg
  • Twitter
  • Google Bookmarks
  • Technorati
  • StumbleUpon
  • MySpace
  • Sphinn
  • del.icio.us
  • Facebook
  • Reddit
  • Mixx