Professional Web Applications Themes

Problem picking model under another model - Macromedia Director 3D

Im using the following code to create a list of the 1st 2 models under the mouse which I can use in an if statement. example: on mouseDown me pt = the mouseLoc - point(pMySprite.left, pMySprite.top) modList = pMySprite.camera.modelsUnderLoc(pt, 2) if modList[1].name =p1stFloor or modList[2].name =p1stFloor then me.goToFloor("first") end if if modList[1].name =pKeycard or modList[2].name =pKeycard then me.collectItem(pKeycard, #_card) end if end The problem is when the playhead jumps to the movie specified in goToFloor() it displays this error; Object has been deleted. The movie that the playhead has jumped to has no refrence to modList at all and the ...

  1. #1

    Default Problem picking model under another model


    Im using the following code to create a list of the 1st 2 models under the mouse which I can use in an if statement.
    example:
    on mouseDown me
    pt = the mouseLoc - point(pMySprite.left, pMySprite.top)
    modList = pMySprite.camera.modelsUnderLoc(pt, 2)

    if modList[1].name =p1stFloor or modList[2].name =p1stFloor then
    me.goToFloor("first")
    end if

    if modList[1].name =pKeycard or modList[2].name =pKeycard then
    me.collectItem(pKeycard, #_card)
    end if

    end

    The problem is when the playhead jumps to the movie specified in goToFloor() it displays this error;
    Object has been deleted. The movie that the playhead has jumped to has no refrence to modList at all and the modList should only exists in the mouseDown of other movie. I dint know why director has a problem with the object being deleted.
    I assume the 'Object' is whatever is in [bmodList or pt because if I use a different picking script;
    if pMySprite.camera.modelUnderLoc(the MouseLoc - point(pMySprite.left, pMySprite.top)).name =p1stFloor and comment out the pt and modList variables there is no error.
    I also tried making pt and modList VOID before calling goToFloor() but an error result 'Object expected' came up, If I emptied pt and modList ie. modList=[] the error result would be index out of range so It seems like director is trying to look at the list even though I havent told it to.

    Does anyone know why this is happening? The only time pt or modList is refrenced is in the mouseDown hander its created in so I dont understand why it should matter if the data in pt or modList were deleted or not.



    Bazmati webforumsuser@macromedia.com Guest

  2. #2

    Default Re: Problem picking model under another model

    Could it be because you are referencing a list entry that might not exist ?

    Try only running the code if the modList.count is greater than zero.

    eg.

    on mouseDown me
    pt = the mouseLoc - point(pMySprite.left, pMySprite.top)
    modList = pMySprite.camera.modelsUnderLoc(pt, 2)
    if modList.count > 0 then
    if modList[1].name =p1stFloor or modList[2].name =p1stFloor then
    me.goToFloor("first")
    end if

    if modList[1].name =pKeycard or modList[2].name =pKeycard then
    me.collectItem(pKeycard, #_card)
    end if
    end if
    end

    Hope that might help.

    Rix


    Rix webforumsuser@macromedia.com Guest

  3. #3

    Default Re: Problem picking model under another model

    I'll try your suggestion but if the list is empty the handler goToFloor would not be called but it is, so the list must contail the model. The goToFloor handler doesnt use any refrence to modList as it is no longer needed and wouldnt be accessable outsite the mouseDown anyway. Also the error happens whan the play head gets to the next movie.
    Its a bit puzzling.


    Bazmati webforumsuser@macromedia.com Guest

  4. #4

    Default Re: Problem picking model under another model

    Is this script in a behavior ? If so put it in a frame script.

    Rix


    Rix webforumsuser@macromedia.com Guest

  5. #5

    Default Re: Problem picking model under another model

    Thanks for the reply Rix,
    Ive tried using a loop in my script but I still get the same error. The script is currently attached to the w3d sprite. Does placing such a scipt on the frame make it work differently if so why?


    Bazmati webforumsuser@macromedia.com Guest

  6. #6

    Default Re: Problem picking model under another model

    You need to be careful when calling a goto frame from a behavior, as the play head jumps to the new frame but the behavior carries on running to completion thus referencing a 3D model or member that does not exist.

    Make sure you only call gotoFrame from a frame script to avoid this. You can create a property flag which you can set from within the behavior, then act on that flag and perform the goto frame from within the frame script.

    Hope that makes some sort of sense ! :)

    Rix


    Rix webforumsuser@macromedia.com Guest

Similar Threads

  1. New release of Config::Model with fstab model example
    By Dominique Dumont in forum PERL Modules
    Replies: 0
    Last Post: May 22nd, 12:08 PM
  2. Move model over the others model in the scene
    By vgta in forum Macromedia Director 3D
    Replies: 2
    Last Post: August 8th, 07:32 AM
  3. detecting model collision of model
    By gopal73thakkar in forum Macromedia Director 3D
    Replies: 3
    Last Post: June 4th, 01:40 PM
  4. model showing in 3d editor but not in castmember model list
    By Gianpiero Colagiacomo in forum Macromedia Director 3D
    Replies: 1
    Last Post: May 6th, 02:05 AM
  5. Model within model transform.position, intersection, overlapping models
    By Zafada webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 0
    Last Post: August 30th, 12:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139