A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How to Pass a Timer Value Generated in a Function Value to an EventListener

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Posts
    250

    How to Pass a Timer Value Generated in a Function Value to an EventListener

    Hello,

    How do I pass a value generated in a Function to a Mouse Event?
    I'm trying to pass the timer value to a function (see AS3 below.)

    mymc.addEventListener(MouseEvent.MOUSE_DOWN, fMDWN);
    function fMDWN(e:MouseEvent):void
    {
    //dosometning > can I capture the timer value here???
    }

    function ftimer():void{
    var vstep2:Timer = new Timer(1000,20);
    vstep2.addEventListener(TimerEvent.TIMER, vcount2);
    function vcount2(e:TimerEvent):void{
    //trace("@TMER====================================== ======== " + vcount2);//displays count
    }
    vstep2.start();
    }

    Any help would be greatly appreciated.

    Thanks

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Does this help at all
    PHP Code:
    import flash.utils.Timer;
    import flash.events.TimerEvent;

    function 
    ftimer():void
    {
        
    mymc.addEventListener(MouseEvent.MOUSE_DOWNfMDWN);
        
        var 
    vstep2:Timer = new Timer(1000,20);
        
    vstep2.addEventListener(TimerEvent.TIMERvcount2);
        
        function 
    vcount2(e:TimerEvent):void
        
    {
            
    trace(String(vstep2.currentCount " This is the timer."));
        }
        
        function 
    fMDWN(e:MouseEvent):void
        
    {
            
    trace(String(vstep2.currentCount " This is the clicked time."));
        }
        
    vstep2.start();
    }

    ftimer(); 

  3. #3
    Senior Member
    Join Date
    Jun 2001
    Posts
    250
    Hello Fruitbeard,

    Thanks for your reply. Been in back to back meetings past few days.

    That code definitely works. Now here's my followup question:
    Can we pass this timer value out of our current function into another?

    In old AS2 I could pass values from function to function via the parentheses.

    If not, I think I can use this format.


    Thanks again for your response.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center