0
votes

I want to load an SWF file which is in external server and play it in client side. I am succeeding in that, but I am having an alignment problem when it gets loaded. I am using the following code:

import flash.display.*;
import flash.net.URLRequest;

var rect:Shape = new Shape();
rect.graphics.beginFill(0xFFFFFF);
rect.graphics.drawRect(0,0,1000,1000);
addChild(rect);

var ldr:Loader = new Loader();
ldr.mask = rect;
var url:String = "http://www.unknown.example.com/content.swf";
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);

It loads fine, but when I maximize the frame thevideo alignment is changing and only half of the video is visible on the screen.

2

2 Answers

0
votes

Try to add this at the top of your code for frame 1:

import flash.display.StageScaleMode;
import flash.display.StageAlign;

stage.scaleMode = StageScaleMode.NO_SCALE;// Don't scale the contents of the swf (you may not want to use this
stage.align = StageAlign.TOP_LEFT;// Align the stage to the top left corner of the screen

You may need to add this to the other swf as well, but I'm not sure.

0
votes
import flash.display.StageScaleMode;
import flash.display.StageAlign;

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

rect.x = stage.stageWidth / 2;
rect.y = stage.stageHeight / 2;

rect to be positioned at the center of the stage all the time. The center of the stage is calculated by finding the width of the stage and then dividing it by two. We simply set that as the value for the .x property of the rect and it will do the job. The same thing is applied for the stage height and .y property of the rect as well.