BTW, all InteractiveObjects (superclass way up) dispatch a MouseEventType.DOUBLE_CLICK event so it may be that don’t need your workaround anymore.  However the metadata for doubleClick is currently not being passed through so you won’t be able to assign the handler from MXML, you’ll need to do it manually in AS.

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Gordon Smith
Sent: Thursday, October 20, 2005 11:01 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Flex 2: Where is the Timer Class

 

setInterval() still exists; it's now a function in the flash.util
package. But we do want folks to move to use Timer instead. Here's a
Flex 2.0 example of using Timer:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml">

    <mx:Script>
    <![CDATA[
     
        import flash.util.Timer;
        import flash.util.TimerEvent;
        import flash.util.TimerEventType;

        private var timer:Timer;
           
        private function startTimer():Void
        {
            timer = new Timer(1000);
            timer.addEventListener(TimerEventType.TIMER, timerHandler);
            timer.start();
        }
           
        private function stopTimer():Void
        {
            timer.stop();
            timer = null;
        }
           
        private function timerHandler(event:TimerEvent):Void
        {
            trace("timer");
        }

    ]]>
    </mx:Script>

    <mx:Button label="Start Timer" click="startTimer();"/>
    <mx:Button label="Stop Timer" click="stopTimer();"/>

</mx:Application>

Here are a few things to note:

1. A Timer dispatches "timer" events which you handle like any other
event.

2. When a Timer is first created with 'new', it is stopped; you have to
use the start() method to start it.

3. This examples creates and destroys a Timer object each time you click
the Start and Stop buttons. (Setting timer = null allows it to be
garbage collected.) But you could also create a Timer object, say at app
initialization, which you keep around, starting and stopping it multiple
times.

- Gordon


-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On
Behalf Of Greg Johnson
Sent: Thursday, October 20, 2005 10:25 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Flex 2: Where is the Timer Class

This is a repost since we can't edit something we already did.  I just
wanted to clerify the subject line.

Flex 2 docs say the old timer functions have been removed and there is
a Timer Class.  However in the docs for the Timer Class there is a
blank page.

Does anyone know where I can read about the methods etc of the new
class?  Or can tell me what they are?

I am trying to write a new doubleClick checker and this need a timer.

Thanks






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links











--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to