A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Turning a MouseClick function into a TIMER function

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    1

    Turning a MouseClick function into a TIMER function

    I had a function that occured on mouseclick called go_out. I want this function to occur when the timer fires after 5 seconds. After the 5 secons I receive this error:


    TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Timer@3fe4561 to flash.display.MovieClip.
    at home_flash_fla::MainTimeline/go_out()
    at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
    at flash.utils::Timer/flash.utils:Timer::tick()


    *****************************


    var myTimer:Timer = new Timer(5000);
    myTimer.addEventListener("timer", go_out);
    myTimer.start();



    function go_out(e:TimerEvent)
    {
    var mc:MovieClip = MovieClip(e.target);


    fm_tween = new Tween(mc, "x", Strong.easeIn, mc.x, 100, tween_duration, true);
    fm_tween.addEventListener(TweenEvent.MOTION_FINISH , go_in);
    new Tween(mc, "y", Strong.easeIn, mc.y, -180, tween_duration, true);
    }

    Let me know if you have any suggestions!

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    why are you trying to cast an object of type Timer into a MovieClip ? Im not sure what your code looked like before , but basically , when you say e.target , you are saying 'myTimer'. And a timer cant be a movieclip because it is not a display object. And that tween will not work either because you are going to be trying to tween a Timer. mc needs to receive the value of whatever Movieclip or Sprite you want to tween.

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