Ok I found a solution.

The MainAssets class:

    public class MainAssets {

        public static var P:PreloaderPanel = new PreloaderPanel();

        public function MainAssets(main:Sprite):void  {
            main.addChild(P);
        }
    }


The Main Class:

public class Main extends Sprite {


        public function Main():void {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            var MA:MainAssets = new MainAssets(this);
            test();
        }

        public function test():void {
            MainAssets.P.x = 300;
        }
    }

this works fine. I used static variables in order to access the assets from
anywhere in the application.

But is this the real solution?
On Tue, Aug 12, 2008 at 2:52 PM, Omar Fouad <[EMAIL PROTECTED]> wrote:

> Hi,
> In an AS3 Project that I am developing in FD, i have this Main class, that
> extends Sprite, with the Main function that is used as the entry point of
> the application.
> Of course I'd need to add instances of controls such as text fileds or
> MovieClip such as Boxes or whatsoever from this class.
> I created another class called MainAssets.as that extends this Main class.
> What I am trying to do is to create instances of those controls inside the
> MainAssets class and add them to the stage through addChild(), just to keep
> the GUI interface object in another place instead of having lots of code in
> this Main. Regardless this technique is wrong or right, I noticed that just
> creating another class that extends the Main class gives me an error saying
> that "the swf file contains invalid data".
>
> Is there any thechnique to have a "Design" Class that adds Children to the
> stage instead of creating lots of instances in the Main Class itself?
>
> I know that this might be a silly question but I am kinda new with OOP.
>
> Your cooperation will be highly appreciated.
>
> Thanks in advance.
>
>
>
> --
> Omar M. Fouad
>
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender. Thank you.
>



-- 
Omar M. Fouad - Digital Emotions
http://www.omarfouad.net

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to