Ask a Question related to Macromedia Director Lingo, Design and Development.
-
bulldog65 webforumsuser@macromedia.com #1
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
-
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... -
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... -
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... -
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... -
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... -
JB #2
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
-
bulldog65 webforumsuser@macromedia.com #3
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
-
Mark A. Boyd #4
Re: Repetative Animation
On 02 Dec 2003, "bulldog65" [email]webforumsuser@macromedia.com[/email] wrote:
It translates to [Ctrl]+. on Windows - a keyboard short cut to stop the> Is the command-period a Mac command?
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
-
bulldog65 webforumsuser@macromedia.com #5
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
-
Andrew Morton #6
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
-
bulldog65 webforumsuser@macromedia.com #7
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
-
Andrew Morton #8
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
-
bulldog65 webforumsuser@macromedia.com #9
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
-
bulldog65 webforumsuser@macromedia.com #10
Re: Repetative Animation
None of the properties set in beginSprite are getrting passed to the enterframe method.
bulldog65 webforumsuser@macromedia.com Guest
-
bulldog65 webforumsuser@macromedia.com #11
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
-
bulldog65 webforumsuser@macromedia.com #12
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
-
Andrew Morton #13
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
-
bulldog65 webforumsuser@macromedia.com #14
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
-
bulldog65 webforumsuser@macromedia.com #15
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
-
Mark A. Boyd #16
Re: Repetative Animation
On 04 Dec 2003, "bulldog65" [email]webforumsuser@macromedia.com[/email] wrote:
I see you've already moved on to another method, but just wondering if you> 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.
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
-
bulldog65 webforumsuser@macromedia.com #17
Re: Repetative Animation
Any ideas regarding my last post? I'm still stuck!
bulldog65 webforumsuser@macromedia.com Guest



Reply With Quote

