Pretty sure that setting a templateXXX to a bunch of properties is the way
to go if you need to repeatedly create the same type of object, but I was
wandering about one-off's? I'm looking at a community provided script - and
it used the templategraphic technique to create each object - like this:

   1. set the prop x of the templategraphic to n
   2. set the prop y of the templategraphic to m ....
   3. create the graphic
   4. reset templategraphic

In my not entirely scientific speed tests I get 168 ticks for the creation
of 100 objects using this technique. As fo the technique of simple creation
and locking the screenr:

   1. lock the screen
   2. create the graphic
   3. set prop x, y, z....
   4. unlock the screen

I get 94 ticks for the creation of 100 objects using the lock screen
technique for each object creation. I guess simple creation of the object is
not only a little safer (no forgetting to rest), but nearly twice as fast
(which is surprising).

Here are the two scripts:

on mouseUp
>    put the ticks into startTick
>    set lockmessages to true
>    repeat 100
>       set the foregroundcolor of the templategraphic to colour_GetRandom()
>       set the backgroundcolor of the templategraphic to colour_GetRandom()
>       set the style of the templategraphic to "rectangle"
>       set the linesize of the templategraphic to random (8)
>       set the opaque of the templategraphic to true
>       set the loc of the templategraphic to the loc of this cd
>
>       create graphic "Test"
>       reset templategraphic
>    end repeat
>    set lockmessages to false
>    put the ticks - startTick
> end mouseUp
>
> on mouseUp
>    put the ticks into startTick
>    set lockmessages to true
>    repeat 100
>       lock screen
>       create graphic "Test"
>       put it into createdGraphic
>
>       set the foregroundcolor of createdGraphic to colour_GetRandom()
>       set the backgroundcolor of createdGraphic to colour_GetRandom()
>       set the style of createdGraphic to "rectangle"
>       set the linesize of createdGraphic to random (8)
>       set the opaque of createdGraphic to true
>       set the loc of createdGraphic to the loc of this cd
>
>       unlock screen
>    end repeat
>    set lockmessages to false
>    put the ticks - startTick
> end mouseUp
>
> function colour_GetRandom
>    put random(255) into item 1 of someColour
>    put random(255) into item 2 of someColour
>    put random(255) into item 3 of someColour
>    return someColour
> end colour_GetRandom
>
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to