• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Is it possible to dynamically determine what methods an MC is using?

I want to be able to ask a MC what methods it is currently using. Is there some sort of Flash method that returns a list existing methods of an MC?

Here's the deal I want to be able to check the methods of an MC that has various button methods added to it in AS.

I want to be able to save those methods as vars or objects, delete them for a time, then add them back. Sort of like this:

//get the _parent button method onRelease and enabled state then delete the onRelease method:

this[this._name+"_startAudio"].parentFunc = this._parent.onRelease;
this[this._name+"_startAudio"].parentEnabled = this._parent.enabled;
this[this._name+"_startAudio"].parent = this._parent;
delete this._parent.onRelease;

//when the child button is released, add the method back to the parent and set the enabled state to the previous state
this[this._name+"_startAudio"].onRelease = function(){
      this.enabled = false;
      //this._visible = false;
      this.parent.onRelease = this.parentFunc;
      this.parent.enabled = this.parentEnabled;
      trace(this.parent);
      removeMovieClip(this);
      playAudio("S");
}
This is working in my code, but I want to be able to cycle through all the "button" methods in an MC and save and delete then add them back later. I realize I could just create an array of all the possible "button" methods and then cycle through that way, but is there another way?

Thanks in advance!
0
acekz
Asked:
acekz
1 Solution
 
MontoyaProcess Improvement MgrCommented:
Well, you could do that by using addproperty or prototyping the mc.

The basic logic is that you will create the properties for the movie clip. Then, you will assign values to those properties when you cal the method/function/whatever...

Finally, you can trace the property of the mc to see its value.

Make sense?

0
 
acekzAuthor Commented:
I don't want to add properties to the MC, I just want to retrieve any methods that have been added to it...I may not have control over putting properties into it. I need to be able to detect if these methods exist without having created the clip myself so I wouldn't really know what methods to look for...I think i'll just create an array of "button" methods...
0
 
nifmcmCommented:
for (var i in mc) {
    if (typeof(mc[i]) == "function") {
        //save method to variable.
    }
}

out of interest, what is your reason for wanting to delete methods? would a simple mc.enabled = false not do?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now