Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default Sprite "name"

    Hi,

    a question:
    I can use label to identify a frame instead of number, therefore I can
    change my score without problem...
    I can use cast member name to identify cast member, therefore I can change
    my member position without problem...

    How can I have the same with sprite. All lingo seems to call sprite with
    number, but if I move vertically my sprites, my lingo point to wrong sprite.
    There are a "relative" way to call sprite, instead of number?

    Thanks for help.

    ---

    Michele


    Michele Guest

  2. Similar Questions and Discussions

    1. CFINPUT type="radio" w/ "value" requires "label"
      On a Flash form, when you specify type='radio' and value='whatever', the value of the 'value' attribute will be displayed as a label if no 'label'...
    2. set the member of sprite x to "quicktimefile"
      I have a 400 x 300 pix image on the stage in sprite x, and a button with a script that changes the member of sprite x to a Quicktime VR file (also...
    3. some type of "after sprite plays" command?
      I have a menu background .swf that slides in. After that shockwave is done playing, I need the buttons to appear. Is there any type of "after sprite...
    4. Using Lingo to "focus" an editable text sprite
      Hi all. I'm using a few editable text sprites, and would like to make a behavior that detects when someone hits the return key, then make the next...
    5. "Start" "Program" "Menu" list is empty
      For what ever reason my list of installed programs in my "Start" "Programs" menu is empty. Anyone know how to restore the list. Thanks for your...
  3. #2

    Default Re: Sprite "name"

    Hello, Michele,
    > I can use label to identify a frame instead of number
    Yes, you can. Just click above the frame number on the Director time line
    and enter a label for that frame. After you've done that, say you called a
    frame "startFrame", you can go to that frame using

    go to "startFrame"

    You can find out the label of the currently shown frame at runtime using the
    property "the frameLabel".
    > I can use cast member name to identify cast member
    Yes, you can, and you should. For example:

    member("mySampleMember").backColor = 0
    > How can I have the same with sprite.
    That's a bit more difficult, you should use variables to store the sprite
    number or a reference to the sprite you want to address: For example:

    -- somewhere at the beginning of your code,
    -- maybe use a global variable (using keyword "global")
    theBitmapSprite = sprite(31)
    -- then you can address the sprite using:
    theBitmapSprite.visible = true

    or

    -- somewhere at the beginning of your code,
    -- maybe use a global variable (using keyword "global")
    theBitmapSpriteNum = 31
    -- then you can address the sprite using:
    sprite(theBitmapSpriteNum).visible = true

    Another hint: Except for the last question, it would have been faster if you
    just had tried things out yourself :-)

    Nonetheless, good luck!
    L.S.


    Loren Schwarz Guest

  4. #3

    Default Re: Sprite "name"

    Thank you Loren,

    but perhaps I'm not explained well, sorry.

    I already know how use label and cast member name. They are only examples
    because I need the same relative mode to call sprite.
    If I use variable to store the sprite number I don't solve my trouble
    because if (when I am authoring) I need to shift down my sprites in the
    score to make room for new sprites (and with this action my current sprite
    20 becomes sprite 25), my old script that call sprite(20).blend now change
    blend of a different sprite.
    I need to have a sprite name (or other relative reference to it).
    For example if I call the sprite 20: "background", I can use
    sprite("background").blend even if I change the sprtites position in the
    score.

    Thanks to anyone that help me.

    ---

    Michele



    "Loren Schwarz" <loren.schwarzNOSPAM@tiscali.de> ha scritto nel messaggio
    news:br58vg$rt$1@forums.macromedia.com...
    > Hello, Michele,
    >
    > > I can use label to identify a frame instead of number
    > Yes, you can. Just click above the frame number on the Director time line
    > and enter a label for that frame. After you've done that, say you called a
    > frame "startFrame", you can go to that frame using
    >
    > go to "startFrame"
    >
    > You can find out the label of the currently shown frame at runtime using
    the
    > property "the frameLabel".
    >
    > > I can use cast member name to identify cast member
    > Yes, you can, and you should. For example:
    >
    > member("mySampleMember").backColor = 0
    >
    > > How can I have the same with sprite.
    > That's a bit more difficult, you should use variables to store the sprite
    > number or a reference to the sprite you want to address: For example:
    >
    > -- somewhere at the beginning of your code,
    > -- maybe use a global variable (using keyword "global")
    > theBitmapSprite = sprite(31)
    > -- then you can address the sprite using:
    > theBitmapSprite.visible = true
    >
    > or
    >
    > -- somewhere at the beginning of your code,
    > -- maybe use a global variable (using keyword "global")
    > theBitmapSpriteNum = 31
    > -- then you can address the sprite using:
    > sprite(theBitmapSpriteNum).visible = true
    >
    > Another hint: Except for the last question, it would have been faster if
    you
    > just had tried things out yourself :-)
    >
    > Nonetheless, good luck!
    > L.S.
    >
    >

    Michele Guest

  5. #4

    Default Re: Sprite "name"

    well ..
    you attach a behaviour to the sprite that
    has a property for the name defined through the getpropertydescriptionlist
    handler and then use a sendallsprites with parameter the name of the sprite
    you want
    for example

    -- behaviour code

    -- the name you want to call this sprite
    -- will be assigned a value later

    property pName

    on getPropertyDescriptionList me
    pList = [:]
    pList[#pName] = [#format:#string,#default:" a default name ",
    #comment:"What should this sprite be called"]
    return pList
    end

    on GetSprite me, aName
    if aName = pName then
    return sprite(me.spritenum)
    end if
    end

    -- end behaviour

    now when you drop this behaviour on a sprite
    it will pop a window asking for a name for that sprite

    now from anywhere in your code you can call
    aSprite = sendAllSprites(#GetSprite, "a name you gave to one of the
    sprites")
    now aSprite contains a reference to the sprite you want and all command
    valid to the sprite are valid for this variable
    like
    aSprite.loc
    etc...
    be careful not to givetwo sprites the same name because you will only
    receive the one when issuing the above command

    hope this helps

    gabriel


    gabriel Guest

  6. #5

    Default Re: Sprite "name"

    Michele,

    the sense of using a global variable to store a reference to a sprite or the
    spriteNum is that you have to hard-code the sprite number only once in your
    movie. You can do that at a single central location (for example in an
    prepareMovie script) If you have to rearrange your sprites, you have to
    adjust hard-coded "magic numbers" only once, at that central place.

    global mySprite, myOtherSprite

    on prepareMovie me
    mySprite = sprite(12)
    myOtherSprite = sprite(14)
    end

    Throughout your movie all references to your sprites are done using the
    global variables, for example:

    on mouseDown me
    mySprite.blend = 50
    myOtherSprite.member = member("whichever")
    end

    I think this solution is quite simple and practical...

    L.S.


    Loren Schwarz Guest

Posting Permissions

  • You may not post new threads
  • You may 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