Professional Web Applications Themes

scripts that control other scripts - Macromedia Director Lingo

Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite? I want to try and create such a behaviour that would be along the lines of: on MouseUp me If condition is true then all other scripts for sprite(me.spriteNum) are functional else if condition is false then all other scripts for sprite(me.spriteNum) are non-functional end if end any ideas would be fantastic many regards fiona-beth...

  1. #1

    Default scripts that control other scripts

    Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite?

    I want to try and create such a behaviour that would be along the lines of:

    on MouseUp me
    If condition is true then
    all other scripts for sprite(me.spriteNum) are functional
    else if condition is false then
    all other scripts for sprite(me.spriteNum) are non-functional
    end if
    end

    any ideas would be fantastic

    many regards
    fiona-beth



    kiaoraFiona webforumsuser@macromedia.com Guest

  2. #2

    Default Re: scripts that control other scripts

    Sure, just create a property and use it's value to control whatever you
    like:

    ---------
    property thisSprite
    property onOrOff

    on beginSprite me
    thisSprite = me.spriteNum
    onOrOff = 0
    end

    on mouseEnter me
    if onOrOff then
    -- change member, etc.
    end if
    end

    on mouseLeave me
    if OnOrOff then
    -- change member, etc.
    end if
    end

    on mouseDown me
    if onOrOff then
    -- change member, etc.
    end if
    end

    on mouseUp me
    if onOrOff then
    onOrOff = 0
    else
    onOrOff = 1
    -- change member, etc.
    end if
    -------

    The mouseUp function will change the value of the property onOrOff
    every time it is used, so click once, everything works, click again,
    nothing works.

    Is that what you were looking for?

    --
    Rob
    _______
    Rob Dillon
    Team Macromedia
    [url]http://www.ddg-designs.com[/url]
    412-243-9119

    [url]http://www.macromedia.com/software/trial/[/url]
    Rob Dillon Guest

  3. #3

    Default Re: scripts that control other scripts

    you could set a flag, so for example:

    on MouseUp me
    If condition is true then
    all other scripts for sprite(me.spriteNum) are functional
    else if condition is false then
    all other scripts for sprite(me.spriteNum) are
    non-functional
    end if
    end



    On Fri, 3 Oct 2003 12:34:35 +0000 (UTC), "kiaoraFiona"
    [email]webforumsusermacromedia.com[/email] wrote:
    >Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite?
    >
    >I want to try and create such a behaviour that would be along the lines of:
    >
    > on MouseUp me
    > If condition is true then
    > all other scripts for sprite(me.spriteNum) are functional
    > else if condition is false then
    > all other scripts for sprite(me.spriteNum) are non-functional
    > end if
    > end
    >
    >any ideas would be fantastic
    >
    >many regards
    >fiona-beth
    >
    Richie Bisset Guest

  4. #4

    Default Re: scripts that control other scripts

    sorry, hit post before completing the message by accident. Rob's
    soluiton is better anyway.

    On Fri, 03 Oct 2003 14:19:08 +0100, Richie Bisset
    <richierocket.nospam.co.uk> wrote:
    >you could set a flag, so for example:
    >
    > on MouseUp me
    > If condition is true then
    > all other scripts for sprite(me.spriteNum) are functional
    > else if condition is false then
    > all other scripts for sprite(me.spriteNum) are
    >non-functional
    > end if
    > end
    >
    >
    >
    >On Fri, 3 Oct 2003 12:34:35 +0000 (UTC), "kiaoraFiona"
    >webforumsusermacromedia.com wrote:
    >
    >>Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite?
    >>
    >>I want to try and create such a behaviour that would be along the lines of:
    >>
    >> on MouseUp me
    >> If condition is true then
    >> all other scripts for sprite(me.spriteNum) are functional
    >> else if condition is false then
    >> all other scripts for sprite(me.spriteNum) are non-functional
    >> end if
    >> end
    >>
    >>any ideas would be fantastic
    >>
    >>many regards
    >>fiona-beth
    >>
    Richie Bisset Guest

  5. #5

    Default Re: scripts that control other scripts

    In article <bljqcr$qtn$1forums.macromedia.com>, "kiaoraFiona"
    [email]webforumsusermacromedia.com[/email] wrote:
    > Is there any behaviour script that when attached to a sprite can control
    the functionality of any other scripts attached to that sprite?
    >
    > I want to try and create such a behaviour that would be along the lines of:
    >
    > on MouseUp me
    > If condition is true then
    > all other scripts for sprite(me.spriteNum) are functional
    > else if condition is false then
    > all other scripts for sprite(me.spriteNum) are non-functional
    > end if
    > end
    >
    Rob's way is the most straightforward, but you should also look in to
    "sprite(x).scriptInstanceList". That is a list of all of the current
    behaviors. The advantage of taking scripts out of it or adding scripts to
    it is that the other scripts don't have to have any code added to them.

    -- Control other scripts on same sprite

    property spritenum,allOtherScripts

    on beginSprite me
    allOtherScripts = duplicate(sprite(spritenum).scriptInstanceList)
    myPos = getPos(allOtherScripts,me)
    deleteAt(allOtherScripts,myPos)
    end

    on killScripts me
    myPos = getPos(sprite(spritenum).scriptInstanceList,me)
    cnt = count(sprite(spritenum).scriptInstanceList)
    repeat with x = cnt down to 1
    if x = myPos then
    -- don't commit suicide
    next repeat
    else
    sprite(spritenum).scriptInstanceList.deleteAt(x)
    end if
    end repeat
    end

    on restoreScripts me
    repeat with instance in allOtherScripts
    sprite(spritenum).scriptInstanceList.append(instan ce)
    end repeat
    end

    Call from the message window or other code like

    sendSprite 5,#killScripts
    sendSprite 5,#restoreScripts

    The control script will remain, but the other behaviors on the sprite will
    be deleted.

    Gretchen Macdowall
    [url]http://www.updatestage.com/[/url]
    Gretchen Macdowall Guest

  6. #6

    Default Re: scripts that control other scripts

    Sounds like you want to dig into scriptInstanceList. You would actually attach and remove scripts for a sprite rather than turn them on or off.

    Hope this helps

    Charles Parcell
    Team Macromedia Volunteer for Director MX
    -----------------------
    Posted via Web Forums
    Charles Parcell webforumsuser@macromedia.com Guest

  7. #7

    Default Re: scripts that control other scripts

    hi KiFi

    you say you want to have several behaviors and one of the behaviors will control the behavior of another. well I kinda see what you mean. the obvious solution would be to build the lingo all in one behavior but this will work.

    behavior one

    property spn, flagg
    on beginsprite me
    spn=me.spritenum
    flagg=1
    end

    on mouseup me
    sprite(spn).flagg=random(1,2)
    end


    behavior two

    property spn,flagg
    on beginsprite me
    spn=me.spritenum
    end

    on exitframe me
    if sprite(spn).flagg=1 then
    --do something here
    end if
    end



    the basic point here being that if you want to set or retrieve a property from a different behavior youi just use the lingo

    sprite(2).proppa=2 -- this sets the value

    and this retrieves the value

    if sprite(2).proppa =1 then

    with proppa being the name of the property you wish to set and sprite 2 the number of the sprite with the behavior attached to it



    HAIRYBOBBY - why didn't I choose a really cool name like the vulcanpimp

    [url]http://www.geocities.com/hairybobby2000[/url]

    new vector shape behaviors here

    [url]http://www.geocities.com/hairybobby2000/vertexhome.html[/url]
    hairybobby webforumsuser@macromedia.com Guest

  8. #8

    Default Re: scripts that control other scripts

    thank you very much, the scriptInstanceList is very helpful. Though it took me a while to figure out it can only be accessed at run time!

    The new behaviour that controls the other scripts on the sprite is going to be placed on a number of different sprites. IS there a command in lingo that returns a list of all the sprites that have this behaviour attached. Would it be something to do with the scriptInstancList?

    thanks very much
    Fiona


    kiaoraFiona webforumsuser@macromedia.com Guest

  9. #9

    Default Re: scripts that control other scripts

    No, there is no spriteInstanceList to see which sprites have a specific Behavior. But it is pretty easy to make one. Just setup a global variable called spriteInstanceList = [] in your on startMovie

    Than as you add the script to different sprites, have it also increment or decrement to that list. You would add the sprite number or something else useful to the list.

    Hope this helps.

    Charles Parcell
    Team Macromedia Volunteer for Director MX
    ----
    Web Forums
    ----
    Feature Request &amp; Bug Form
    Charles Parcell webforumsuser@macromedia.com Guest

Similar Threads

  1. version control of server scripts
    By Bruno Gallant in forum Linux / Unix Administration
    Replies: 0
    Last Post: August 18th, 04:59 PM
  2. How di I use scripts?
    By Steve_Dorsey@adobeforums.com in forum Adobe Indesign Windows
    Replies: 2
    Last Post: July 24th, 02:35 PM
  3. CS: Scripts do not appear in Scripts menu
    By jlw99@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 3
    Last Post: May 18th, 04:49 PM
  4. Server Control Deployment and Client Scripts?
    By Jim Cheshire [MSFT] in forum ASP.NET Building Controls
    Replies: 10
    Last Post: April 9th, 02:44 PM
  5. Where should PHP scripts go?
    By Andrew C. in forum PHP Development
    Replies: 4
    Last Post: April 7th, 04:02 PM

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