Jump to content
Search Community

The SWF doesnt appear when I tried resizing the SWFLoader, someone pls help!!!!!

fauzihasnan test
Moderator Tag

Recommended Posts

When I try to resize it, it doesn't show.

 

 

It works fine like this

 

------

 

var loader:SWFLoader = new SWFLoader("livingroomout.swf", {container:this);

 

//Load Swf

loader.load();

{

 

-----

but when I try to resize the swf, by adding the height and width properties, it doesn't appear at all

-----

 

var loader:SWFLoader = new SWFLoader("livingroomout.swf", {container:this, width:300, height:300});

 

//Load Swf

loader.load();

{

-----

 

any help? pleasee???? im a noob at this

Link to comment
Share on other sites

A few questions:

  1. Are you using the latest version of LoaderMax/SWFLoader?
  2. Does your subloaded swf have a size set correctly (like a native size)? Is it something you published from an FLA file?
  3. Can you post a very simple example set of files that clearly demonstrate the issue? That way, we can publish on our end to see what's happening. It can be tough to troubleshoot blind :)

Link to comment
Share on other sites

The problem is that your subloading swf has a width/height of 0 when it first loads which messes up the automatic resizing. Zero times any factor is always zero. You could solve this by using an ENTER_FRAME to keep checking the rawContent to see when its width (and/or height) is no longer zero and then set the content's fitWidth and fitHeight, like this:

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.*;
import flash.events.Event;

var loader:SWFLoader = new SWFLoader("livingroomout.swf", {container:this, onInit:initHandler});

loader.load();

function initHandler(event:LoaderEvent):void {
   addEventListener(Event.ENTER_FRAME, checkResize, false, 0, true);
   checkResize(null);
}
function checkResize(event:Event):void {
   if (loader.rawContent.width != 0) {
       loader.content.fitWidth = 200;
       loader.content.fitHeight = 100;
       removeEventListener(Event.ENTER_FRAME, checkResize);
   }
}

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...