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

Posted on 2006-04-21
Last Modified: 2010-04-03
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;
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!
Question by:acekz
    LVL 19

    Expert Comment

    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?


    Author Comment

    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...
    LVL 3

    Accepted Solution

    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?

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now