Repetative Animation

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

  1. #1

    Default Repetative Animation

    I am working on a project that requires animation that loops until the user turns it off. This project contains sprites that represent light bulbs (so there are many of them) and I need to allow the user to enabe/disable the animation. The animation simulates the bulb sprites flashing ...(in various way). I have attempted to attach a behavior to each sprite that switches that sprite member with another one. The problem I am having is that upon enabling the animation I cannot do anything else without the program freezing up.


    bulldog65 webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. BOX AROUND THE ANIMATION
      Hello people from group. Greetings from Brazil. I got a problem after upgrade to flash player 8: a box started to appear around any swf viwed in...
    2. animation help from max
      can anyone reccomend any good tutorials on how to blend seperate animations? The files are w3d exported from max I have a charcter set up and...
    3. How to do this animation...
      Hi there... How can i code an animation like a brush painting a logo... Ex. I have the pic of the logo in vectorial format.. and i wanted to make...
    4. animation "open" onPress( animation "close" ) go to Frame "myFrame"
      I have searched hi and low for the answer and nothing has helped me as of yet. My Main timeline is sectioned off by keyframes that are 10 frames...
    5. keyframe animation detected on a resource that will marge -this animation willbe lost
      hi, sorry for the question but need a quick fix for it. i am exporting from max 5, a quick animation of a shark tail moving but on export i am...
  3. #2

    Default Re: Repetative Animation

    When the program 'freezes' can you unfreeze it with a command-period, if
    so it would be a lingo script endlessly looping that is tying up the
    system.

    Yoiu might accomplish what you need with a film loop, lay out the blink
    animation over a few frames, select and copy those frames from score and
    paste into the cast, creating a film loop. One might be able to turn it
    off and on by altering the "loop" property of the film clip member ( I
    don't recall the exact property name, could be but you will recognize it.


    member("myFilmLoop").loop = false -- turning it off
    JB Guest

  4. #3

    Default Re: Repetative Animation

    I don't see how I could get that to work. What I have is a string of lights, each one being it's own sprite. Is the command-period a Mac command? I'm using windows, and ESC will eventually stop the program.



    bulldog65 webforumsuser@macromedia.com Guest

  5. #4

    Default Re: Repetative Animation

    On 02 Dec 2003, "bulldog65" [email]webforumsuser@macromedia.com[/email] wrote:
    > Is the command-period a Mac command?
    It translates to [Ctrl]+. on Windows - a keyboard short cut to stop the
    movie. It can /usually/ break out of an infinite repeat loop, but you might
    also try [Ctrl]+[Alt]+. or [Ctrl]+[Shift]+. (I don't remember which was
    more successful).


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  6. #5

    Default Re: Repetative Animation

    The project stops when using [CTRL]+. (well one of the combinations you provided, I tried them all). So I assume that I have an infinite loop. Here is the behavior that I attach to the dynamically created sprites, to preform the animation. I have tried various ways( as seen by some of the commented out code) and get the same error locking up.


    global projObj
    property g

    on beginSprite
    g = 0
    end

    on enterframe me


    if projObj.blink_state = 1 then

    -- repeat while projObj.blink_state = 1
    --if g=0 then
    -- sprite(me.spriteNum).member = member "yellow_1" of castlib "Bulbs"
    -- g = 1
    --else
    -- sprite(me.spriteNum).member = member "yellow_3" of castlib "Bulbs"
    -- g = 0
    -- end if
    -- updatestage
    -- end repeat








    --g = 1
    --repeat while projObj.blink_state = 1

    if g = 0 then
    repeat with f = 1 to projObj.curObj.getaProp(#theSpriteList).count
    set val = projObj.curObj.getaProp(#theSpriteList).getAt(rand om(projObj.curObj.getaProp(#theSpriteList).count))
    sprite(val).member = member "yellow_3" of castlib "Bulbs"
    --if f > 1 then
    -- sprite(val -1).member = member "yellow_2" of castlib "Bulbs"
    --end if
    updatestage
    --if f = projObj.curObj.getaProp(#theSpriteList).count then
    -- f = 0
    --end if
    end repeat
    g = 1
    else
    repeat with f = 1 to projObj.curObj.getaProp(#theSpriteList).count
    set val = projObj.curObj.getaProp(#theSpriteList).getAt(f)
    sprite(val).member = member "yellow_3" of castlib "Bulbs"
    updatestage
    end repeat
    --sprite(125).member = member "yellow_3" of castlib "Bulbs"
    --sprite(126).member = member "yellow_1" of castlib "Bulbs"
    g = 0
    end if
    updatestage
    --end repeat

    --enableAnimation()
    else
    --disableAnimation()
    end if

    end



    bulldog65 webforumsuser@macromedia.com Guest

  7. #6

    Default Re: Repetative Animation

    Don't use a repeat loop, instead use the enterFrame handler:
    (not tested)

    property spriteNum, self
    propert active
    property myTimer, timeOnOff, state
    property bulbOn, bulbOff

    on beginSprite
    self=sprite(spriteNum)
    bulbOn=member("yellow_1", "bulbs")
    bulbOff=member("yellow_3", "bulbs")
    state=1
    myTimer=the milliseconds
    timeOnOff=300
    self.member=bulbOn
    active=true
    end beginSprite

    on enterFrame
    -- anything to do?
    if not(active) then exit
    if (the milliseconds-myTimer)<timeOnOff then exit
    -- alternate state between 1 and 2
    state=3-state
    self.member=[bulbOn, bulbOff][state]
    -- start the timing again
    myTimer=the milliseconds
    end enterFrame

    on enableAnimation
    active=true
    end enableAnimation

    on disableAnimation
    active=false
    end disableAnimation

    Andrew
    Andrew Morton Guest

  8. #7

    Default Re: Repetative Animation

    I entered your script as written, and it didn't work. was it written to be used as you wrote it , or am I supposed to incorperate it with my enterframe handler? Your script has the enableAnimation and disableAnimation methods, but they aren't called anywhere. when I run my program, I get the active var returning VOID as per your code, I assume that this is because the enable/disable animation methods are never called. You know, I have written this whole thing, and now I have to add this blinking light crap, and it is kicking my butt. I appreciate all the advise you've provided. Thank You!



    bulldog65 webforumsuser@macromedia.com Guest

  9. #8

    Default Re: Repetative Animation

    Second property declaration line: should say "property", not "propert".
    Make yourself a test movie: with just this as a frame script:-

    on exitFrame
    go the frame
    end enterFrame

    Now, put a bulb member on the stage and attach my behaviour to it. (You may need
    to change the names of the members for on and off.) Play the movie and the bulb
    will flash.
    Stop the movie. Create several bulbs and attach the behaviour to each. Play the
    movie. All the bulbs flash.
    In the message window type

    sendAllSprites(#disableAnimation)

    and they will all stop blinking. (Tested this time.)

    You can use sendSprite(n, #disableAnimation) to send the message to only sprite
    number n.

    Andrew

    Andrew Morton Guest

  10. #9

    Default Re: Repetative Animation

    I still can't get this to work. I put in "put" statements to see what is occuring when the behavour is executed and I found that all of then are VOID.


    bulldog65 webforumsuser@macromedia.com Guest

  11. #10

    Default Re: Repetative Animation

    None of the properties set in beginSprite are getrting passed to the enterframe method.


    bulldog65 webforumsuser@macromedia.com Guest

  12. #11

    Default Re: Repetative Animation

    I have modified your script and gotten it to work somewhat. Let me better describe how the bulds are placed on the stage. I have icon for the different buld colors, when I click the icon it places the initial bulb on the stage. After clicking this buld and holding down the mouse you can position this builb on the stage. After releasing the bulb, you are given a sencond bulb to position at the endpoint of your light string. Once you release the second bulb, bulbs are generated inbetween to fill the space. For every bulb created the animation behavior is attached to it.

    So now when I run the behavior that I modified, I get the initial bulb of each string flashing. The rest of the bulbs in the string do not flash, and the initial bulbs alternate in their flashing.

    Bulb1 on string 1 flashes for a few seconds and then stops
    Bulb1 on string 2 flashes for a few seconds and then stops

    etc.....

    repeat.

    here is the modified script:



    --on beginSprite
    --this= the currentspriteNum
    --bulbOn=member("yellow_3", "bulbs")
    --bulbOff=member("yellow_1", "bulbs")
    -- state=1
    --myTimer=the milliseconds
    --timeOnOff=300
    --this.member=bulbOn
    --active=false
    --end beginSprite

    on enterFrame me
    this= me.spritenum
    bulbOn=member("yellow_3", "bulbs")
    bulbOff=member("yellow_1", "bulbs")
    timeOnOff=300

    -- anything to do?
    if not(active) then exit
    --if (the milliseconds-myTimer)<timeOnOff then exit
    -- alternate state between 1 and 2
    state=(state mod 2) + 1
    sprite(this).member=[bulbOn, bulbOff][state]
    updatestage
    -- start the timing again
    myTimer=the milliseconds
    end enterFrame





    on enableAnimation
    active=true
    return active
    end enableAnimation

    on disableAnimation
    active=false
    return active
    end disableAnimation




    bulldog65 webforumsuser@macromedia.com Guest

  13. #12

    Default Re: Repetative Animation

    I've made some more progress, but still can't it to work completely. What I've found out is that the beginSprite handler is not getting called. So As I loop through and insert the bulbs on the stage(and attach the behavior) I call sendSprite(k,#beginSprite). Doing this results is ONLY the last bulb of each string flashing as expected. However for every string, the last bulb flashes. Anyone have any ideas on why I'm only getting the last bulb of the string to work. I have put a breakpoint on line

    self=sprite(spritenum)

    and the result returns

    self = (sprite 0)



    bulldog65 webforumsuser@macromedia.com Guest

  14. #13

    Default Re: Repetative Animation

    > getting called. So As I loop through and insert the bulbs on the stage(and
    attach the behavior)

    Woah there! How are you attaching the behaviour? If these are dynamically
    created sprites then you have to tell the behaviour which sprite channel it is
    in.

    Andrew

    Andrew Morton Guest

  15. #14

    Default Re: Repetative Animation

    Is that not being done by the following statement

    self = sprite(spriteNum)

    If not, then how do I correct the script to work in my case.



    bulldog65 webforumsuser@macromedia.com Guest

  16. #15

    Default Re: Repetative Animation

    Just wanted to let you know that I have it working now. Thank You, for your help.

    If you have any ideas on how I might change the pattern in which the bulbs flash, I would greatly appreciate it.

    As you are aware, the bulbs now flash together and thats great. How might I get them to flash both randomly and in a chasing pattern.

    I've tried a couple things, but without any success. Below is the code used attempting to simulate chasing.

    What I have is an array of objects with each array containing an array of sprites used to make up that object. So I am looping through my inventory and setting cur to the array of sprites, then I check that array for the spritenum of the behavior. I then used the delay command in hope of delaying the sprite member swapping by 10 cycles.


    repeat with a =1 to projObj.inventory.count
    cur = projObj.inventory.getAt(a).getAt(1)
    seed = cur.findpos(spritenum)
    if seed <> 0 then exit repeat
    end repeat

    delay 10*seed


    bulldog65 webforumsuser@macromedia.com Guest

  17. #16

    Default Re: Repetative Animation

    On 04 Dec 2003, "bulldog65" [email]webforumsuser@macromedia.com[/email] wrote:
    > The project stops when using [CTRL]+. (well one of the combinations
    > you provided, I tried them all). So I assume that I have an infinite
    > loop. Here is the behavior that I attach to the dynamically created
    > sprites, to preform the animation. I have tried various ways( as seen
    > by some of the commented out code) and get the same error locking up.
    I see you've already moved on to another method, but just wondering if you
    noticed the reason for the freeze up?

    In this case, it's not really an infinite loop, but if you're looping on
    this frame with a 'go the frame' command, then it constantly toggles the
    'g' variable. This causes the script to always enter into one or the other
    of your repeat loops.

    Here's a simplified version that should help illustrate the logic that is
    causing it.

    on enterFrame me
    if g = 0 then
    repeat with ...
    end repeat
    g = 1
    else
    repeat with ...
    end repeat
    g = 0
    end if
    end

    on exitFrame me
    go the frame
    end

    Just FYI since you've already found a solution.


    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  18. #17

    Default Re: Repetative Animation

    Any ideas regarding my last post? I'm still stuck!


    bulldog65 webforumsuser@macromedia.com 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