deleting an object
- Started
- Last post
- 8 Responses
- fourtenlabs
i want to create a method that deletes the object calling the method. i thought you could just put "delete this" inside the method but that won't delete the object. if i manually delete the object by name outside the class file it works fine but i can't delete an object inside its class! anyone know how to do this?
- ********0
good question, I'd be interested in the answer too. I'll see what I can find out tomorrow, it's bedtime now.
- fourtenlabs0
i think i figured it out. flash can't delete an object only the variable that references the object. then flash will automatically clean up the garbage when it sees nothing is referencing the object anymore. so you could pass the name of the object to the method and delete that name inside the method.
- ********0
sounds like a good solution, thanks for sharing!
- unfittoprint0
an object createad as a public/private var cannot be deleted.
Then again, why should it be deleted? it's part of the class. However you can reset its value to undefined/null.
if you're writing you own classes you can create objects that live only within your class methods scope [altough its not good policy to make them available to the 'public'].
- fourtenlabs0
i'm creating a motion blur effect class that you call:
var mb:MotionBlur = new MotionBlur(some_mc, maxBlur);
so you'll have a variable pointing on the main timeline presumably. then you can call:
mb.startMotionBlur(); and
mb.stopMotionBlur()starts and stops the interval causing the blur.
i wanted two other methods to kill all of the blurs and to kill a specific blur object as follows:
mb.killMotionBlur();
MotionBlur.killAll();that's where i was running into problems. i have an array that is a static property that's getting pushed with "this" each time the class is constructed so that i can kill all of the object references with killAll().
am i gonna run into problems trying to keep track of variables outside of the class when i try to use killAll() since i guess i have to delete all the variables pointing to the object private or not?
- ********0
edit>delete
duh
- bk_shankz0
How are you making the blur?
- fourtenlabs0
here's it in action:
http://www.andrewnida.com/experi…