Thank you for your help. I'm trying dynamicaly create a movieclip and be able 
to modify it, add and remove listeners etc. accesing it from any class.


Your example throws errors:
1046: Type was not found or was not a compile-time constant: Main
1180: Call to a possibly undefined method Main
1172: Definition Main could not be found // while trying to import

both classes are in the same directory.

k.
--- On Fri, 9/11/09, Merrill, Jason <[email protected]> wrote:

> From: Merrill, Jason <[email protected]>
> Subject: RE: [Flashcoders] Access dynamically created MovieClip from class?
> To: "Flash Coders List" <[email protected]>
> Date: Friday, September 11, 2009, 5:52 PM
> Not sure what you are trying to
> accomplish in what you are building (because I am suspicious
> your architectural approach may be a bit off - maybe), but
> to just answer your question, in the Main class, define the
> drawingSign Movie clip as a public variable like this:
> 
> package
> {
>     import flash.display.MovieClip;
> 
>     public class Main
>     {
>         //define it as public
> here:
>         public var
> drawingSign:MovieClip;
> 
>         public function
> Main():void
>         {
>            
> //create it here:
>            
> drawingSign = new MovieClip();
>            
> //blah blah more code here.
>         }
>     }
> }
> 
> Then, in your other class ClassDraw, import Main and create
> an instance of it:
> 
> package
> {
>     import flash.display.MovieClip;
>     import Main; 
> 
>     public class ClassDraw extends
> MovieClip
>     {
>         private var
> _main:Main;
> 
>         public function
> ClassDraw():void
>         {
>            
> //create an instance of Main:
>            
> _main = new Main();
>            
> //access the MovieClip you want in the other class:
>            
> trace(_main.drawingSign)
>            
> //blah blah more code here.
>         }
>     }
> }
> 
> 
> Jason Merrill 
> 
> Bank of  America   Global Learning 
> Learning & Performance Soluions
> 
> Monthly meetings on making the most of the Adobe Flash
> Platform - presented by bank associates, Adobe engineers,
> and outside experts in the borader multimedia community -
> join the Bank of America Flash Platform Community 
> (note: this is for Bank of America employees only)
> 
> 
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]
> On Behalf Of ktt
> Sent: Friday, September 11, 2009 10:25 AM
> To: Flash Coders List
> Subject: RE: [Flashcoders] Access dynamically created
> MovieClip from class?
> 
> Thank you the answer, but maybe I didn't define situation
> clearly:
> 
> I have two separate files main.as and classdraw.as
> 
> Movieclip is defined in main.as:
> 
> var drawingSign:Movieclip = new MovieClip();
> drawingSign.x = 40;
> drawingSign.y = 40;
> //drawingSign.addEventListener(MouseEvent.CLICK,mc_clicked);
> addChild(drawingSign);
> 
> I want to access drawingSign from my other classdraw.as
> file:
> 
> package (
> 
> import flash.events.*;
> import flash.display.*;
> import flash.utils.*; 
> 
> public class classdraw extends MovieClip {
> 
> private var newSign:drawingSign = new drawingSign(); // as
> it is used to access objects from Library
> 
> public function classdraw() {
> 
> addChild (newSign);
> 
> }
> 
> But I geting errors :
> 1046: Type was not found or was not a compile-time
> constant: drawingSign.
> 1180; Call to a possibly undefined method drawingSign.
> 
> Regards,
> Kioshin
> 
> --- On Fri, 9/11/09, Cor <[email protected]>
> wrote:
> 
> > From: Cor <[email protected]>
> > Subject: RE: [Flashcoders] Access dynamically created
> MovieClip from class?
> > To: "'Flash Coders List'" <[email protected]>
> > Date: Friday, September 11, 2009, 4:58 PM
> > var drawingSign:Movieclip = new
> > MovieClip(); //you forgot the "w" of new
> > drawingSign.x = 40;
> > drawingSign.y = 40;
> > drawingSign.addEventListener(MouseEvent.CLICK,
> > mc_clicked);
> > addChild(drawingSign);
> > 
> > private function mc_clicked(e:MouseEvent):void{
> >     trace("You have clicked drawingSign");
> > }
> > 
> > 
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]]
> > On Behalf Of ktt
> > Sent: vrijdag 11 september 2009 15:40
> > To: Flash Coders List
> > Subject: [Flashcoders] Access dynamically created
> MovieClip
> > from class?
> > 
> > Hello,
> > 
> > I have created Movieclip in main actionscript file
> main.as
> > :
> > 
> > var drawingSign:Movieclip = ne MovieClip();
> > drawingSign.x = 40;
> > drawingSign.y = 40;
> > 
> > How could I access it (add listeners etc.) from a
> class
> > file?
> > Is it possible?
> > 
> > Thank you in advance,
> > kioshin
> > 
> > 
> >       
> > _______________________________________________
> > 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
> 


      

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to