frame 1 {
this.onEnterFrame = function () {
if (buttonIsDown) {
i += 1;
duplicateMovieClip(_root.layer.target, 'variable_name' + i, i);
// last argument is depth
}
};
}
Of course the button:
button 4 {
on (press) {
var buttonIsDown = true;
}
on (release) {
var buttonIsDown = false;
}
}
Doing, *basically*, the same thing in JavaScript results in the onmousedown being carried
out for *quite some time*, then, depending on how quickly I released the mouse button the
script runs out of execution time or continues on with it being false.
So, inevitably I was left with a script that attempted to close your browser each time it
ran.
Can anyone steer me in the general direction of having a persistent mousedown event? Not
a drag and drop, but perhaps just the drag, um, minus it needing to move?
-Lost
var mouseIsDown = true;
function start_md()
{
while (mouseIsDown == true)
{
document.getElementById('filler').innerHTML += ' text ';
}
}
function stop_md()
{
mouseIsDown = false;
}
window.onload = function()
{
document.onmousedown = start_md;
document.onmouseup = stop_md;
}
<p id="filler"></p>
This of course has major flaws. The greatest of which is that the while takes off
considerably faster than what Firefox seems to like. Finally, after a few to many seconds
later it appears to work. So this "chaotic" behavior is unsuitable and undesirable.
Any ideas?
-Lost
Browsers do not update graphics context (screen content) until after
the current execution thread is finished. Until it's finished the DOM
changes are being accumulated but not reflected on the screen. The
most commonly used way to overcome this - I would say weakness - is
using micro-breaks over setTimeout. In your code change:
> function start_md()
> {
> while (mouseIsDown == true)
> {
> document.getElementById('filler').innerHTML += ' text ';
> }}
to
function start_md() {
window.setTimeout(addContent, 60);
}
function addContent() {
document.getElementById('filler').innerHTML += ' text ';
if (mouseIsDown) {
window.setTimeout(addContent, 60);
}
}
the needed micro-break will make the magic for you.
<FAQENTRY>
Would FAQ maintainer consider adding relevant FAQ? It could be like
"I'm changing my page but nothing is changing on the screen. Why?"
I could write the initial short text.
IMHO this issue by its frequency and especially by its "mysterious
nastiness" is well qualified for a FAQ.
</FAQENTRY>
<snip>
> <FAQENTRY>
> Would FAQ maintainer consider adding relevant FAQ? It could be like
> "I'm changing my page but nothing is changing on the screen. Why?"
> I could write the initial short text.
> IMHO this issue by its frequency and especially by its "mysterious
> nastiness" is well qualified for a FAQ.
> </FAQENTRY>
Somewhere in the archives (I can't find it right now) there are several
threads where I asked about an entry of why the display isn't being
updated.
Post a short text and lets see where it goes. I don't have a problem
adding a new entry.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
FAQ Notes: http://www.jibbering.com/faq/faq_notes/faq_notes.html
ECMAScript Language Specification via FAQ2.6
I never thought of this. Thank you.
-Lost
Unless there is something I am missing, as in an apparent flaw, VK's suggestion worked
wonders.
If this code will be the basis for the write-up, then I would definitely like to see it
written up, eloquently.
-Lost