Professional Web Applications Themes

Need help generating variable name for timeout object - Macromedia Director 3D

Below is a function I am using to scale an object down and then hide it. It works fine on just one object, but if I try to run it on multiple objects at the same time, only the last object gets scaled down. I believe this is because the timeout list only ever has a single item in it, ?ShrinkTimeOut?. Does each entity in the timeout list need a distinct name? And if so, how would I dynamically generate a name and save it so I can kill the timeout object once the object has scaled down fully? //JavaScript ...

Sponsored Links
  1. #1

    Default Need help generating variable name for timeout object

    Below is a function I am using to scale an object down and then hide it. It
    works fine on just one object, but if I try to run it on multiple objects at
    the same time, only the last object gets scaled down. I believe this is
    because the timeout list only ever has a single item in it, ?ShrinkTimeOut?.

    Does each entity in the timeout list need a distinct name? And if so, how
    would I dynamically generate a name and save it so I can kill the timeout
    object once the object has scaled down fully?


    //JavaScript:

    //Scales an object over time.
    //mModel must be of the format: member("ModelName").getPropRef("model", 1)
    function fShrinkModel(mModel) {
    //Creates a timeout object.
    tShrinkTimeOut = new timeout("ShrinkTimeOut", 5, "fShrinkLoop", mModel);
    }

    function fShrinkLoop(mModel) {
    //Creates a variable that contains the vector value of the model's scale
    (vector( 1.0000, 1.0000, 1.0000 )).
    nScaleVector = mModel.getPropRef("transform").scale;
    //Checks to see if the model is 1% or less than its original size.
    if (nScaleVector[1]<=0.01) {
    //Makes the model invisible.
    mModel.visibility = symbol("none");
    //Kills the timeout object.
    tShrinkTimeOut.forget();
    } else {
    //If it is not, we scale the model down further and allow the loop to
    repeat.
    mModel.scale(0.9);
    }
    }

    Sponsored Links
    adam@blueapplestudio Guest

  2. #2

    Default Re: Need help generating variable name for timeout object

    tShrinkTimeOut = new timeout("ShrinkTimeOut" + string(the milliseconds),
    5, "fShrinkLoop", mModel);
    Sean Guest

  3. #3

    Default Re: Need help generating variable name for timeoutobject

    Thanks for the response, Sean.

    Does it look like I am getting rid of the timeout object properly in my code?
    I was trying to use forget with tShrinkTimeOut and not ?ShrinkTimeOut?.

    A broader question- does this look like a good method of scaling an object
    down over time? I need to shrink objects to (0, 0, 0) and would like to wrap
    it into a nice little function. Any thoughts?

    adam@blueapplestudio Guest

  4. #4

    Default Re: Need help generating variable name for timeout object

    > Does it look like I am getting rid of the timeout object properly in my code?

    Now that you mention it, and I have a look, no - it doesn't:
    //not sure of the order of parameters here:
    function fShrinkLoop(mModel, aTimeout) {
    //Creates a variable that contains the vector value of the model's
    scale (vector( 1.0000, 1.0000, 1.0000 )).
    nScaleVector = mModel.getPropRef("transform").scale;
    //Checks to see if the model is 1% or less than its original size.
    if (nScaleVector[1]<=0.01) {
    //Makes the model invisible.
    mModel.visibility = symbol("none");
    //Kills the timeout object.
    aTimeout.forget();
    } else {
    //If it is not, we scale the model down further and allow the loop to
    repeat.
    mModel.scale(0.9);
    }
    }
    Sean Guest

  5. #5

    Default Re: Need help generating variable name for timeoutobject

    Sean, that's exactly what I needed. Thanks for your help.
    adam@blueapplestudio Guest

Similar Threads

  1. Application Variable Timeout
    By Stressed_Simon in forum Macromedia ColdFusion
    Replies: 1
    Last Post: March 31st, 04:40 PM
  2. session variable timeout - application.cfm
    By wtjohnson1958 in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: February 22nd, 03:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139