swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] Actionscript acting stupid...


From: John Sullivan
Subject: Re: [Swftools-common] Actionscript acting stupid...
Date: Wed, 26 Jan 2011 21:01:46 +0000

On Wednesday, January 26, 2011, 7:17:24 AM, Tail Kinker wrote:
> I've got a chunk of script:
>[...]
> Substitute any other 16x16 graphic for cherry.swf.

[Note: Not quite so simple. .put on a .swf creates a new movieclip,
.put on an image doesn't, which means the three cherries are then not
independently placeable. For testing without cherry.swf you must
convert to:

    .png cherry "cherry.png"

    .sprite cherries0
      .put cherry
    .end
    .put cherries0 x=5 y=40

    etc.]


> Now, the issue is this:  When I compile this, the first function 
> (initcherries) works precisely as advertised.  However, the second 
> function (updateScore) does not relocate the cherries, as intended.
>[...]
> And the only difference between the two functions is that the second is
> called by a SetInterval.

Firstly, Adobe document the function as "setInterval". Though it turns
out this isn't your problem because function names are
case-insensitive, at least in this version of AS, I wasn't sure this
was so and had to test it out. Best stick with the official
capitalisation to avoid confusion.

The actual problem is that the form of setInterval() you are using
takes a global function and timeout. But you use "this" within the
function and that value will not be available.

Instead, use the object form of setInterval. So instead of:

  updateScore = function() { }
  scoreUpdate = setInterval(updateScore, 25)

use:

  function updateScore() {}
  scoreUpdate = setInterval(this, "updateScore", 25);

That appears to fix it.

John
-- 
Dead stars still burn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]