Skip navigation
Currently Being Moderated

help! I cant get my remove event listener to work?

Apr 17, 2012 9:32 AM

so i made a tween the on rollover plays out a tween i treyed the code below but it does not work, i need to remove the event listener once it is rolled over once but it gives me an error that says

 

Symbol 'pictures_mc',Layer 'actions', frame2, Line19 1067 :Implict coercion of a value of type.transitions:Tween to an to an unrelated type Function.

 

I have no idea what this means but i know its about the remove event listener in the code below.

 

import flash.events.MouseEvent;

import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;

 

stop();

 

 

var myTween:Tween = new Tween(sidebar, "x", None.easeIn, 0, -40, 1, false);

 

 

sidebar.addEventListener(MouseEvent.MOUSE_OVER,showsidebar)

 

 

function showsidebar(evtobj:MouseEvent){

 

          var Sidebartween:Tween = new Tween(sidebar, "x", None.easeIn, 0, -100, 1, false);

          sidebar.addEventListener(TweenEvent.MOTION_FINISH,deletearrow);

          function deletearrow(evtObj:TweenEvent){

                    delete(sidebar.arrow_mc)

          }

          stage.removeEventListener(TweenEvent.MOTION_START,Sidebartween);

}

 

like i said i need to remove the event listener because when i roll over it the tween just keeps playing if i dont can anyone help?

 
Replies
  • Currently Being Moderated
    Apr 17, 2012 11:38 AM   in reply to super waffle

    You want to add the listener to the tween instance, not the sidebar. Change:

     

    sidebar.addEventListener(TweenEvent.MOTION_FINISH, deleterarrow);

     

    to:

     

    Sidebartween.addEventListener(TweenEvent.MOTION_FINISH, deletearrow);

     

    And you can also just make it an anonymous function which is pretty much what you have anyhow.

     

    e.g.:

     

    Sidebartween.addEventListener(TweenEvent.MOTION_FINISH, function(e:TweenEvent):void{ delete(sidebar.arrow_mc); });

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 11:48 AM   in reply to sinious

    Here's your problem. You are way too into the code. You need the magic wand app for the iPad. You run the app and then wave the iPad over the code and it all just works. Dude! Trust me it works.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 11:56 AM   in reply to Solomon_Venturi

    I have that app.. it converted all the people in my agency into mac fans.. I deleted it.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 9:11 PM   in reply to super waffle

    I have the same problem and i don't have an Ipad, is there another way?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 6:14 AM   in reply to nickkapiten

    You should make your own post and give as much information possible, including code samples.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2012 4:01 PM   in reply to sinious

    ok thank u for the suggestion

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points