Skip navigation
Razzi_A
Currently Being Moderated

Trouble with mouse input to change alpha

Jan 27, 2012 9:59 AM

Tags: #flash #as3 #alpha

I'm running AS3 in Flash CS5 and I'm trying to make a box fade in when the mouse moves to the right.

 

Here's my code thus far:

 

stage.addEventListener(MouseEvent.MOUSE_MOVE, changeAlpha);

function changeAlpha(event:MouseEvent) {

    fader.DisplayObject.alpha =(root.mouseX/550);

}

 

It is not responding to moving the mouse. I feel like the source of the codeis outdated. Does anybody know what's wrong?

 

Other info: there is only 1 frame with 2 layers; one layer is this code and the other is a box that covers the stage with instance name "fader"

I'm also getting this error: TypeError: Error #1010: A term is undefined and has no properties.

 
Replies
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 27, 2012 12:31 PM   in reply to Razzi_A

    this part of your code:

     

    fader.DisplayObject.

     

    is wrong.

     

    if fader is your object's instance name use:

     

    stage.addEventListener(MouseEvent.MOUSE_MOVE, changeAlpha);

    function changeAlpha(event:MouseEvent) {

        fader.alpha =(root.mouseX/550);

    }

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 27, 2012 2:40 PM   in reply to Razzi_A

    you're welcome.

     
    |
    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