A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Undefined property Timer ??

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    69

    Undefined property Timer ??

    This is the code (simple):

    var timer:Timer = new Timer(2000, 1);
    timer.addEventListener(TimerEvent.Timer, onTimer);
    timer.start();

    function onTimer(evt:TimerEvent):void {
    r1.filters = sampleFilters; }


    This is the error:

    "access of possibly undefined property Timer through a reference with statis type"

    And I do did import flash.events.TimerEvent; --- am I supposed to import something else? Is this the problem?

    TIA

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    It should be TimerEvent.TIMER
    New sig soon

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Location
    Greece
    Posts
    6
    Of course you must import the Timer class itself.

    import flash.utils.Timer;

    http://www.gemstonedragon.com/

  4. #4
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    If it's just code in the timeline of the .fla, you don't need to import the Timer class, it's already there.
    New sig soon

  5. #5
    Junior Member
    Join Date
    Sep 2009
    Location
    Greece
    Posts
    6
    Have you tried it? If not it's only one line of code. I think you need to import it.

    http://www.gemstonedragon.com/

  6. #6
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    Of course I've tried it.
    New sig soon

  7. #7
    Member
    Join Date
    Jul 2009
    Posts
    69
    Weird.

    So, I set it up like this:

    import flash.events.TimerEvent.TIMER; (also tried this without the all caps for "Timer"
    import flash.utils.Timer;

    and I'm getting this error:

    1172: Definition flash.events.TimerEvent:TIMER could not be found.

    Then for the second line of the following code ...

    var timer:Timer = new Timer(2000, 1);
    timer.addEventListener(TimerEvent.Timer, onTimer);
    timer.start();


    I'm getting this error:

    1119: Access of possibly undefined property Timer through a reference with static type Class.

    PS - I'm working on the timeline.
    Last edited by Leftyplayer; 09-14-2009 at 03:20 PM.

  8. #8
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    No i mean like this:

    Code:
    var timer:Timer = new Timer(2000, 1);
    timer.addEventListener(TimerEvent.TIMER, onTimer);
    timer.start();
    
    function onTimer(evt:TimerEvent):void {
    	r1.filters = sampleFilters; 
    }
    No need to import anything, that's all you need.
    New sig soon

  9. #9
    Member
    Join Date
    Jul 2009
    Posts
    69
    Ahhh! thanks, man. Simple solution and it's working. I appreciate your help.

  10. #10
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    No problem.
    New sig soon

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