Steve,
You can also track by using event.currentTarget, like this:

function DoSomething(e:MouseEvent):void{

             trace((event.currentTarget).TextField.text);
}

-- 
Greetings!
Hope this message of mine finds you in best of health and spirits.

On Fri, Apr 22, 2011 at 10:05 AM, Steve Abaffy <[email protected]>wrote:

> So basically the only way to make this work is to declare the myMovieClip
> as
> a global variable??
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Gerry
> Sent: Thursday, April 21, 2011 9:28 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] How to access MovieClip declared in one function
> in an event listener
>
> Steve,
>
> You have some things confused. Like Ross said, read up on event.target.
>
> Your code should look something like this...
>
> Var myMovieClip:MovieClip;
> Var myButton:SimpleButton;
>
> DrawMyStuffOnScreen();
>
>
> Function DrawMyStuffOnScreen():void{
>
>               myMovieClip = new DefinedMovieClip();
>
>               myButton = new DefinedButton();
>
>               myButton.addEventListener(MouseEvent.CLICK,DoSomething);
>
>               //Defined Movie clip has several input fields in it
>
>               myMovieClip.TextField.text = "SomeText";
>
>               addChild(myMovieClip);
>                addChild(myButton);
> }
>
> Function DoSomething(e:MouseEvent):void{
>
>               //What goes in this function to be able to do something like
>
>               Trace(myMovieClip.TextField.text); // This show a complier
> error of basically I don't know what myMovieClip is;
> }
>
>
> On Apr 21, 2011, at 9:44 PM, Steve Abaffy wrote:
>
> > Hello,
> >
> >
> >
> > I basically have the follow:
> >
> >
> >
> > Function DrawMyStuffOnScreen():void{
> >
> >                Var myMovieClip:MovieClip = new DefinedMovieClip();
> >
> >                Var myButton:SimpleButton = new DefinedButton();
> >
> >                myButton.addEventListener(MouseEvent.CLICK,DoSomething);
> >
> > //Defined Movie clip has several input fields in it
> >
> >                myMovieClip.TextField.text = "SomeText";
> >
> >                addChild(myMovieClip);
> >
> > }
> >
> > Function DoSomething(MouseEvent.CLICK):void{
> >
> >                What goes in this function to be able to do something like
> >
> >                Trace(myMovieClip.TextField.text); // This show a complier
> > error of basically I don't know what myMovieClip is;
> >
> >
> >
> >                Then tried:
> >
> >                Var myMC = new DefinedMovieClip();
> >
> >                Trace(myMC.TextField.text) // this works but is always
> empty
> > since it initializes empty.
> >
> >                So how do you access the textfield that is sitting on the
> > stage???
> >
> > }
> >
> > Thanks
> >
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to