Skip navigation
Currently Being Moderated

Timeout Object Problem: Can’t recreate scaling error

May 13, 2008 1:27 PM

In my movie there is a function that scales 3D objects over time using a timeout object. The 3D objects are in an array that is shuffled each round, and based on the outcome of the array shuffle, some 3D objects are scaled and some are not.

I have been testing this for a while and it almost always works as I anticipate, however I have encountered some events wherein unexpected 3D objects are scaled. To track down the error, I have been tracing the results of the array shuffle, as this is what drives the scaling. When I encountered an event where unexpected objects were scaled I recorded what I thought was a “bad” array shuffle. Then, disabling the array shuffle function, I set the shuffle result to my “bad” array. I expected it would recreate the problem (unexpectedly scaled objects) however it worked accurately this time around.

Are there any rules regarding timeout objects that are commonly broken that may be causing this? Does a timeout object behave any differently in the Director environment than it does in a published projector? Any broad or general tips (sorry I can’t post the code) are appreciated.
 
Replies
  • Currently Being Moderated
    May 13, 2008 2:44 PM   in reply to adam@blueapplestudio
    could you post the general structure of your timeout object and in what type of script you create it? Thanks.
     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2008 7:14 AM   in reply to adam@blueapplestudio
    sTimeout.forget() will not kill the timeout.... in fact, it should throw an error.

    you need to do this:
    timeout(sTimeout).forget()

     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2008 8:37 AM   in reply to adam@blueapplestudio
    You probably just need to go

    sTimeout.forget()

    if sTimeout is already a #timeout object, then you do not need to put
    another timeout() designation around it.
     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2008 10:15 AM   in reply to adam@blueapplestudio
    I am not too savvy with JS syntax, but my main question is what is the
    call to fShrinkLoop(mModel, sTimeout) sending as sTimeout?

    In order for that to work, sTimeout should be the timeout object. Not
    the name of the timeout. It should be what you previously referred to
    as tShrinkTimeOut
     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2008 6:07 AM   in reply to adam@blueapplestudio
    ok, when I originally posted I had done a test based off the code you posted... There should be no way sTimeout is a timeout object because it's simply a string variable in your code:

    sTimeout = String("ShrinkTimeOut"+(_system.milliseconds));

    passing it to the timeout handler/function as a parameter of the time object, it should still be a string, so this line:
    sTimeout.forget();

    should not work, and did not in the code I wrote to test it. Either the code you posted is different than the code you're using or the example I wrote to test is different in some fundamental way.
     
    |
    Mark as:
  • Currently Being Moderated
    May 19, 2008 7:04 PM   in reply to adam@blueapplestudio
    I downloaded the file and made a change which seems to work (don't know why, but it did):

    //Creates a variable for the timeout name.
    sTimeout = String("ShrinkTimeOut"+random(_system.milliseconds));

    use the random() function... don't know why this would work, but it seems to.
     
    |
    Mark as:
  • Currently Being Moderated
    May 19, 2008 9:15 PM   in reply to adam@blueapplestudio
    Hi

    In the "fShrink", function the variable called "sTimeout" is a string:

    sTimeout = String("ShrinkTimeOut"+(_system.milliseconds));

    in the function "fShrinkLoop", the second parameter being passed in is the timeout object. Therefore in this function, the variable called "sTimeout" is a timeout object.

    The thing to remember is the object that sends the message determines what the parameter is (it doesn't matter what you name the parameter).

    In the case of Timeout objects, the first parameter is the object that Director sends the timeout callback message to (in this case, your model object... and since your model doesn't have a method for handling the response, Direct tries the global name space instead - but still conveniently sends the reference to the 'callback object' as the first parameter). The second parameter is always a reference to the timeout object itself.

    (on a side note - you have taken advantage of a quirk with timeout objects that let you pass parameters with timeout callbacks by using the 'callback target' but letting a movie script handle the callback). If you want to send more than one parameter, you have to bundle them together into a single paremeter object).


    -- Luke


     
    |
    Mark as:
  • Currently Being Moderated
    May 20, 2008 12:06 PM   in reply to adam@blueapplestudio
    quote:

    Originally posted by: adam@blueapplestudio
    Chunick, what version of Director are you using? I am running MX 2004 10.1. Does this behavior exist in Director 11?
    I couldn't tell you. I'm using MX2004 v10.1.1 as well. My trial period has run out for D11.

    As for your previous question: There is a very remote chance of that returning the same value for multiple objects, right? Yes, There is, but it would indeed be remote. You could always add a couple other lines to test if it already exists in the timeoutList, but I don't think it's necessary.
     
    |
    Mark as:
  • Currently Being Moderated
    May 26, 2008 3:40 AM   in reply to adam@blueapplestudio
    Hi Adam,
    The issue here is that the timeout object is being over-written in a single exitframe call, since the same name is used for the timeout, i.e sTimeout variable.

    _system.milliseconds in the below function need not give a different value each time it is called. For e.g) If the same function is called multiple times within the same millisecond.

    _system.milliseconds, has to be changes to some counter, so that it gives a unique value each time it is called.

    Please check the modified code below.

    function fShrink(nModelNumber) {
    //Sets the variable.
    mModel = aAllNullsAndModels[nModelNumber+27];
    //Creates a variable for the timeout name.
    sTimeout = String("ShrinkTimeOut"+ _global.counter++ ; -- This needs to be unique each time the function is called.
    //Creates a timeout object.
    tShrinkTimeOut = new timeout(sTimeout, 10, "fShrinkLoop", mModel, sTimeout);
    }
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points