Cannot addChilld(sprite) into another sprite?


First post woo,

Anyways, I’m quite new to AS3, I worked a bit with AS2 but not to a great extent, and I am now trying to teach myself AS3 (with a little help). I am creating a flash portfolio and so far have got images to import via XML and some other things, but I am stuck at one particular point:

I have an AS file called that extends Sprite, it will contain all the code to draw the static elements of the portfolio, so far it draws a rounded rectange with gradient fine.

I then used URLRequest() and URLLoader() to load the XML, and then Loader to load the logo of the portfolio. I can add it to the Sprite now with:


But I want to manipulate the x and y coords first. I initially failed as I tried to position it in the top right of the portfolio using:

logoLoader.x = 720-logoLoader.width -10

(720 being the width of the portfolio, and 10 being the padding from the right)

This did not work, after tracing logoLoader.width it seems that this property is not given and so tells me the width of the logo is 0. Therefore the x coord of the logo was mostly off the screen.

I then tried putting the logo into its own sprite to manipulate using:

var logoSprite:Sprite = new Sprite;

This didn’t throw any errors, so I continued with:

public function logoComplete(evnt:Event)
{ = -10;

This gave me an x coord value of 382 which is correct, this would position the logo in the top right hand corner in exactly the place I wanted.

But when I tried adding it as a child to the class, I got an error:

1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display: DisplayObject.

I believe the problem is that I am trying to add a Sprite as a child into a Sprite. As AS3 is quite new to me, I don’t see why this should be a problem or a way around it, so my question is; Is what I am doing, the right way of manipulating the position of an external image before it being added to the stage?

Thankyou for your time,

Any reply is appreciated,



A new instance of the AS file is added to the stage via the DocumentClass.

Here is all the code relevant to the problem if needed:

package com.fusedDesign.userinterface
    import flash.display.*;
    import flash.geom.*;
    public class Statics extends MovieClip
        public function Statics()
        public function drawLogo()
            var urlRequest:URLRequest = new URLRequest("com/fusedDesign/folio/xml.xml");
            var urlLoader:URLLoader = new URLLoader();
        public function xmlComplete(evnt:Event)
            var imagesXML:XML = new XML(;
        public function loadImage(xml:XML)
                 var logoLoader:Loader = new Loader();
                var logoRequest:URLRequest = new URLRequest(xml.logo.attribute("href")[0]);
                var logo:Sprite = new Sprite();
        public function logoLoaded(evnt:Event)
   = 10;

I have removed the code that draws and adds the rounded rectangle.