Armin Cifuentes
Armin Cifuentes

Reputation: 515

Call AS3-Parents function from AS2-Child

My parent ActionScript3 file has functions like these:

package  
{

    *lots of import.*

    public class Tabu extends MovieClip
    {


        public function callMe(name:String) {
            trace("callme");
        }

        public function setPage(e:MouseEvent)
        {
            if (e.target.name == "btn_1")
                changePage("campana.swf");
            if (e.target.name == "btn_2")
                changePage("toma_tabu.swf");
            else if (e.target.name == "btn_3")
                veranoPage("verano.swf");
            else if (e.target.name == "btn_4")
                changePage("manda_tu_tabu.swf");
            else if (e.target.name == "btn_0")
                changePage("home_1_v2.swf");
        }

I need to call the setPage() function from a ActionScript2 child that has been loaded within the ActionScript3 file.

In AS3, it's being called like this:

btn_1.addEventListener(MouseEvent.CLICK, (parent as MovieClip).setPage)

In ActionScript2, tried the following for both setPage() and callMe(), but none works:

on(release){
    parent.setPage();
    this.parent.setPage();
    _root.parent.setPage();
    _parent.setPage();
    this._parent.setPage();
    _root._parent.setPage();
}

I'm starting to think it can't be done at all. Suggestions?

Upvotes: 1

Views: 853

Answers (1)

weltraumpirat
weltraumpirat

Reputation: 22604

You can use LocalConnection, but communication between AVM1 and AVM2 movies can be tricky. Don't try to solve this yourself, use SWFBridge.

Upvotes: 2

Related Questions