I am loading an external movie clip in my SWF. The stage scale mode is "no scale" and stage align is TOP LEFT. I am resizing move clip to the actual height and width of parent movie clip using following in OnResize event:
object.x = stage.x;
object.y = stage.y;
object.width = stage.stageWidth;
object.height = stage.stageHeight;
But it's not working. Two important points:
Any help of any sort would be highly appreciated as I am blocked just coz of this. I don't want to use exact fit scale mode of the stage.
Thanks!
Remember that the object.height and object.width refers to the active content on the object depending on how you're importing it:
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.MovieClip;
function startLoad()
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("test.swf");
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event)
{
var object:MovieClip = loadEvent.currentTarget.content;
object.x = stage.x;
object.y = stage.y;
trace(object.width);
trace(stage.stageWidth);
object.width = stage.stageWidth;
trace(object.height);
trace(stage.stageHeight);
//object.height = stage.stageHeight;
addChild(object);
}
function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
}
startLoad();
That code above works, but you may be stretching the width to the point where the content is being stretched out of the scene, trace the width and height.
EDIT:
for youtube it would be something like this:
var loader:Loader = new Loader(); - global variable
function initialzer(){
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
}
private function onLoadInit(event:Event){
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
loader.content.addEventListener("onError", onPlayerError);
}
function onPlayerReady(event:Event):void {
player = loader.content;
player.width = 111;
player.height = 111;
}