Flash "Doesn't Notice" Variables

Discussion in 'Graphics & Multimedia' started by nickjason, Mar 12, 2010.

  1. #1
    This is the strangest thing that I have ever seen. Has this happened to anyone else?

    I'm trying to make a player AI, and I ran into a problem that the script would only run on certain frames.


    //Other code above
    }
    if(right==1||left==1){
    //Other Code Below


    For some reason, Flash refused to go into this if statement. Then I changed it to this for testing purposes:

    //Other code above
    }
    trace("R"+right+"L"+left);
    if(right==1||left==1){
    //Other Code Below


    After this, it began to work, and when I removed the line it stopped working. Does anyone know why?
     
    nickjason, Mar 12, 2010 IP
  2. ViolentAJ

    ViolentAJ Well-Known Member

    Messages:
    581
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    128
    #2
    I'd have to see the rest of the code to know what's going on.

    Honestly, I can't see what's going wrong.
     
    ViolentAJ, Mar 13, 2010 IP
  3. Flash Junky

    Flash Junky Well-Known Member

    Messages:
    319
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Is this script in the main timeline? If so, is the script present on the same frame as where you are having the trouble?

    Usually the biggest cause of this kind of problem is that you are trying to access a variable from a different frame in the timeline, or possibly a variable that is in the timeline of one of your MC's.

    The easiest fix, if this is the case, is to declare your variables as _root like (_root.myMovieClip) or (_root.variableName)

    If your variable is nested inside a MC timeline you have to call into the MC (_root.myMovieClip.variableName)

    If your still having trouble let us know...:)

    Hope this helps...
     
    Flash Junky, Mar 20, 2010 IP