Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You look like you need to scale your bitmaps into a 100x100 square. You'll need to wait until the loader has completed loading to do that because until then you won't know what the dimensions of the item are.</p> <p>When you create your loader, add an event listener, like this:</p> <pre><code>loaderArray[i].contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); </code></pre> <p>and then add this function:</p> <pre><code>function onLoadComplete(event:Event):void { var info:LoaderInfo = LoaderInfo(event.currentTarget); info.removeEventListener(Event.COMPLETE); var loader:Loader = info.loader; var scaleWidth:Number = 100 / loader.width; var scaleHeight:Number = 100 / loader.height; if (scaleWidth &lt; scaleHeight) loader.scaleX = loader.scaleY = scaleWidth; else loader.scaleX = loader.scaleY = scaleHeight; } </code></pre> <p>This may be a bit complicated, but all it really does is clean up the event listener that you had added, and find the dimensions of the loader (which it can get now because it's finished loading), and scale the loader appropriately.</p> <p>If you need it to be centered within your thumbnail, add this to the bottom of the onLoadComplete method:</p> <pre><code> loader.x = (100 - loader.width) * 0.5; loader.y = (100 - loader.height) * 0.5; </code></pre> <p>or you need it to take up the whole thumbnail and cut off the edges, change it to this (the inequality is the other-way around)</p> <pre><code> if (scaleWidth &gt; scaleHeight) loader.scaleX = loader.scaleY = scaleWidth; else loader.scaleX = loader.scaleY = scaleHeight; </code></pre> <p>and add this:</p> <pre><code> var shape:Shape = new Shape(); var g:Graphics = shape.graphics; g.beginFill(0x00FF00); g.drawRect(0, 0, 100, 100); g.endFill(); loader.mask = g; </code></pre> <p>I haven't tested this, so there may be a few glitches, but hopefully it gives you the right idea.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload