# Weird behaviour Sprite and UILoader

**URL:** https://forum.kirupa.com/t/weird-behaviour-sprite-and-uiloader/233655
**Category:** flash
**Created:** [July 25, 2007, 7:15pm UTC](https://forum.kirupa.com/t/weird-behaviour-sprite-and-uiloader/233655 "2007-07-25T19:15:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gr0undtek](https://avatars.discourse-cdn.com/v4/letter/g/b5ac83/32.png) [@gr0undtek](https://forum.kirupa.com/u/gr0undtek)
#### Post date: [July 25, 2007, 7:15pm UTC](https://forum.kirupa.com/t/weird-behaviour-sprite-and-uiloader/233655/1 "2007-07-25T19:15:50Z")

</div>

Hi,

I’ve stumbled accross a problem/behaviour I can’t understand so any help is appreciated.  
I’ll use \*\*sprite \*\*as the Sprite varname and \*\*uiLoader \*\*as the UILoader var name.

I am using a sprite and load( **sprite.addChild(uiLoader)** ) various UILoader variables in it.

Now if I just use the sprite and set width height  
**sprite.width = 300;  
sprite.height = 300;**

the swf that is loaded through the uiLoader variable is being stretched to the width of the sprite. I tried playing with the \*\*maintainAspectRatio \*\*and \*\*scaleContent \*\*values but it didn’t work as expected.

Now if I first draw a rectangle with the sprite ( **sprite.graphics.drawRect(0, 0, 300, 100)** ) and then I add the uiLoader ( **sprite.addChild(uiLoader)** ) stretching doesn’t happen and the loaded swf is loaded as expected. As well I

Any idea why I have to draw a rect and add the \*\*UILoader \*\*instead of just setting \*\*width height \*\*to the sprite directly to get no stretching?

Thanks  
ste
