>Are there other ways to interrupt repeat loops?
exit repeat. You can exit when you reach a number, when a condition becomes
true (or not true).
>No, I did not write it any handler. Actually, I do not know what handler
>to use. Perhaps you may be so kind as to enlighten me.
Ok, here's the basic idea. I'll outline it, and you tell me if I'm right.
You have a series of pictures you want to scroll across the screen. I think
you want to initiate the scroll on some action--let's say a button click.
You want to be able to interrupt it with a mouse down.
So, you need two basic scripts. One is a behavior to attach to the button.
The other is a behavior to attach to each of the scrolling sprites.
The button behavior should do this:
When it is clicked, it sends a message to all the scrolling sprites telling
them to get going.
The sprite behavior should do this:
When it receives a message from the button, it scrolls a certain number of
pixels left or right. This may take it off screen (left?) or on screen
(from the right?)
Does that summarize what you want your code to do?
>If you know what I want, why don't you tell me?
Sorry, it doesn't work that way. I'm not a mind reader--you have to tell me
what you want, and I'll help you figure out how to do it.
I can, however, spot code errors and tell that it's probably *not* what you
want to do.
>Yes. I am trying to re-write the code I gave you earlier, which you said
>was inefficient.
>
>>on mouseUp me repeat with i = 1 to 100 repeat with sprNum = 1 to 20
>>set the LocH of sprite sprNum = (the LocH of sprite sprNum)-i
>>updateStage end repeat end repeat end
>
>
>
>I'm still trying to figure out how to redo it. I gathered from what you
>have written that it is not advisable to have a loop within a loop
Actually, I said it depends on the situation. You can use nested loops to
good effect in the right situation.
Let's go back to the grocery store analogy. You want to send your husband
to 10 stores, and buy 5 things in each store. You could write that like this:
repeat with store = 1 to 10
goToStore
repeat with items = 1 to 5
getItem
end repeat
end repeat
So far, so good. Ah--you forgot that you have to pay for the items and take
them to the car. Where do you do that? Like this?
repeat with store = 1 to 10
goToStore
repeat with items = 1 to 5
getItem
payForItem
takeToCar
end repeat
end repeat
If you follow the logic there, you're getting one item, paying for it,
taking out to the car, then going back into the store for another. It would
be much more efficient to do this:
repeat with store = 1 to 10
goToStore
repeat with items = 1 to 5
getItem
end repeat
payForItem
takeToCar
end repeat
Do you see how much more efficient that is?
>If I don't use it, I use what?
I'm not telling you you shouldn't use it--I'm just saying that, from the
code you posted, I don't see it being used.
>If you do not follow it, do you think I will be able to do so?
You *have* to if you're going to succeed as a programmer. Algorithm + data
= code. You have to understand the problem and figure out the solution. We
can help you with the syntax, but the other end is your job.
>Why do you need to encapsulate it? Isn't a property just a characteristic
>of the object?
Yes, a property is a characteristic of the object. That *is*
encapsulation--I'm describing what it is, not suggesting something else to do.
>So, am I correct to say that properties are used for individual objects
>but when they are used by all objects, they become globals?
Close. Properties are always specific to individual objects. Globals are
variables, but not properties. It's a subtle difference, but important in
Director.
>Could it then be compared to local and global variables?
yep.
>In Special Edition using Macromedia 8, Pg282,
>the author uses the on exitFrame handler to loop. Is this what I should
>be doing instead?
It's hard to generalize. Repeat loops do hog the cpu, but there are times
when you do want to use them. If you loop on the exitFrame handler, then
your loop executes at the movie's frame rate. Sometimes that's what you
want, sometimes not.
>Pg 283 the author has avoided hard coding the default value. He specified
>a range for the default. <snip>
> #default: 5 \
>#range: [#min : -20, #max:20] \]
Actually, what he's done here is closer to hard coding a value. It will
still pop up with a default of 5, but the #range *limits* what you can
enter--you can't enter anything less than -20, or greater than 20. A range
may work fine for you, but it doesn't really have anything to do with hard
coding values.
>At the rate I'm going, it's going to take me 10,000 light years?
No :-)
You're catching on.
It only took Armstrong, Collins, and Aldrin 3 days to get to the moon. But
they spent 5 years preparing.
Cordially,
Kerry Thompson
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]