This is working for me:

<code>
package {
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;

    public class Zuki extends Sprite {
        [Embed(source="myImg.png")]
        private var appBg:Class;
        private var size:int;

        public function Zuki() {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP;

            var bg:Bitmap = new appBg();
            addChild(bg);

            trace('bg: '+bg);
            bg.width = 950;
            bg.height = 600;
            bg.x = 0;
            bg.y = 0;
        }
    }
}
</code>

Best
X.

On 5/29/06, Bjorn Schultheiss < [EMAIL PROTECTED]> wrote:

Hi,

 

Can someone please tell me where I'm going wrong here?

I am trying to load a background image in my application and it will not display.

Here is the code

 

package {

            import flash.display.Sprite;

    import flash.display.StageAlign;

    import flash.display.StageScaleMode;

    import flash.events.Event;

            import flash.utils.*;

            import flash.display.MovieClip;

            import com.zuki.view.Preloader;

            import flash.display.Bitmap;

           

            public class zuki extends Sprite

            {

                        public var className:String = describeType(this)[EMAIL PROTECTED]();

                       

                        [Embed(source="assets/image/bgswf.gif")] private var appBg:Class;

                       

                        private var preloader:Preloader;

                        private var size:int;

                       

                        public function zuki()

                        {

                                    trace('zuki');

            stage.scaleMode = StageScaleMode.NO_SCALE;

            stage.align = StageAlign.TOP;

           

            var bg:Bitmap = createImage('appBg');

           

            addChild(bg);

           

// this trace message below is not appearing in the console at all

            trace('bg: '+bg);

            bg.width = 950;

            bg.height = 600;

            bg.x = 0;

            bg.y = 0;

           

                                    preloader = new Preloader();

                                    addChild(preloader);

                                    preloader.x = 300;

                                    preloader.y = 100;

                        }

                       

                        private function createImage(embedLinkage:String):Bitmap

                        {

                                    trace('createImage');

                                    var imgName:String = className + "_" + embedLinkage;

                                    trace('imgName: '+imgName);

                                    var imgRef:Object = getDefinitionByName(imgName);

                                    var img:Bitmap = new imgRef();

                                    return img;

                                    //return imgName;

                        }          

                       

                       

            }

}

 

Bjorn Schultheiss
Senior Flash Developer

QDC

Personalised Communication Power

Level 2, 31 Coventry St.
South Melbourne

3205, VIC Australia

T:  +61 3 9674 7400
F:  +61 3 9645 9160
W:  http://www.qdc.net.au

 

((------------This transmission is confidential and intended solely for the person or organization to whom it is addressed. It may contain privileged and confidential information. If you are not the intended recipient, you should not copy, distribute or take any action in reliance on it. If you believe you received this transmission in error, please notify the sender.---------------))

 



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to