> Danny,
>
> Out of curiosity, why do you need a function that returns an object of a
> type passed as a string?  It's a neat idea, but I'm scratching my head as
to
> where one might apply it.

I've been hitting some memory problems when using Director's newObject()
function, which creates a new object inside an embedded Swf. Because the
object is unnamed, I have no way to destroy it in the Flash movie - it seems
to go somewhere in the global space. So instead, I'm making my own
tempObject function, which creates a new object in an array pTempObjects in
the Flash movie. When I've finished working with it, I run a
clearTempObjects() function to flush them out.

So I have this function:

function tempObject(tName:String) {
 var tObj:Object = <new Object of type tName>
 pTempObjects.push(tObj)
 return tObj
}

Now Director can call this function, get a new temporary Flash object and
work on it, then tell Flash to do something with the object (eg, setting the
properties of a TextFormat object before applying it to a field), and then
finally clear it out.

More detail than I think you wanted, but since you asked :)

Danny

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to