A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Why am I getting this error? (undefined property and type not found)

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    69

    Why am I getting this error? (undefined property and type not found)

    This is the code:

    pants_mc.addEventListener(MouseEvent.MOUSE_DOWN, placePants);
    skirt_mc.addEventListener(MouseEvent.MOUSE_DOWN, placeSkirt);


    function placePants(event:MouseEvent):void
    {
    if(skirt_mc.x = bottomHold.x)
    {skirt_mc.x = skirtoriginal.x;}
    pants_mc.x = bottomHold.x; //this is where I'm getting errot about the "x"
    }

    function placeSkirt(event:MouseEvent):void
    {
    if(pants_mc.x = bottomHold.x)
    {pants_mc.x = pantsoriginal.x;}
    skirt_mc.x = bottomHold.x;
    }
    This is the error message:

    Scene 1 (on Timeline): 1046: Type was not found or was not a compile-time constant: skirtoriginal.
    Line 44 (in code): 1119: Access of possibly undefined property x through a reference with static type Class.
    Any help truly appreciated. Oh, and what I'm trying to do: I have a "bottomHold" mc on stage, as well as a "skirtoriginal" mc and "pantsoriginal" mc all set to alpha=0. If pants_mc is clicked, it should go to the same location as the bottomHold and simultaneously send the skirt_mc back to it's original position at skirtoriginal ... and vice versa if skirt_mc is clicked.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You have 4 errors in the above code.
    The first one is about skirtoriginal. Are you sure that it is defined? Check your spelling and capitalization.
    The second is about the undefined property x, which indicates that either pants_mc or bottomHold is not a MovieClip but a Class. You should be using the instance names, not the class names there.

    The third and fourth errors are using the assignment operator "=" instead of the equality operator "==" in your if tests.

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    69
    Thanks 5TonsofFlash. my skirtoriginal was defined, but for some reason not working. I changed the instance name to skirtoriginal_mc and it decided to work. Yuppie - I love simple. Fixing that bizarrely enough also fixed the error with the property x.

    And I switched to the use of a boolean variable to define whether the holder was "blocked" (meaning whether skirt_mc or pants_mc were at the holder location).

    Things are working now - thanks for the help.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You probably had the same identifier for your instance names and your class names. In that case, Flash can't determine which one you mean and the ambiguity causes issues like that. Glad you got it fixed.

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