1

I want to control movieclip "A" components from movieclip "B".

movieclip A :

function click1(event:MouseEvent):void
{ 
  // I want to change text of button which is inside movieclip "B" in here.
}

btn1.addEventListener(MouseEvent.CLICK , click1);

movieclip B :

function click2(event:MouseEvent):void
{ 
  //and here I want to change text of button which is inside movieclip "A".
}

btn2.addEventListener(MouseEvent.CLICK , click2);

how can I do this?

sorry for my English.

Elmi Ahmadov
  • 1,017
  • 5
  • 14
  • 25

1 Answers1

3

Making the assumption that both movieclips (mca and mcb) have been added to the stage -- stage is the parent of both -- it is as simple as:

function click1(event:MouseEvent):void
{ 
    // I want to change text of button which is inside movieclip "B" in here.
    stage.mca.someButtonObject.label = "some new button text";
}

function click2(event:MouseEvent):void
{ 
    //and here I want to change text of button which is inside movieclip "A".
    stage.mcb.someTextboxObject.text = "some new text";
}

Test this code out a bit, and let me know if that doesn't work (and please post your code if it fails).

iND
  • 2,663
  • 1
  • 16
  • 36
  • If you declare your code in the parent of the 2 MovieClips you would have the scope to be able to just say `mca.someButtonObject.label =...` instead of including the `stage` – ToddBFisher Dec 26 '11 at 16:17
  • @ToddBFisher Thanks for pointing out the more general case. In theory, use a common ancestor (parent, etc. . . usually the closest). – iND Dec 26 '11 at 16:42