Jump to content
Search Community

Resize image loaded via DataLoader?

vuk test
Moderator Tag

Recommended Posts

Hello,

 

I`m using DataLoader to load swf into specific mc.

However, I need to resize it to fit certain area (150x150), like I usually do in ImageLoader, but that isn`t working in DataLoader class.

 

var queue:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:processLoad});
queue.append( loader );
queue.append(new DataLoader(myImage, {name:"swf", format:"binary", width:150, height:150, scaleMode:"proportionalInside"}));

function processLoad (e:Event):void {
		trace (loadCheck);
		swf1 = new Loader();
  			corner.adHolder.ad.addChild(swf1);
  			swf1.loadBytes(LoaderMax.getContent("swf"));
}
	queue.load();

 

I must use DataLoader, since that is the only way to cache child swf, and then to control it`s sound.

So, is there a some other way to resize/rescale my child swf?

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

Hello,

yes, partly...

 

But to use AutoFitArea I need to know mc size. However, I don`t know how to get it? Can you please check this code?

 

var queue:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:processLoad});
queue.append(loader);
queue.append(new DataLoader(adImage, {name:"swf", format:"binary"}));

function processLoad (e:Event):void {
	if (loadCheck == 0){
		swf1 = new Loader();
  			corner.adHolder.ad.addChild(swf1 as DisplayObject);
  			swf1.loadBytes(LoaderMax.getContent("swf"));

// get size
		var rawContent:DisplayObject = swf1 as DisplayObject; //gets the image that was loaded
		var bounds:Rectangle = rawContent.getBounds(rawContent);
		trace("native width: " + bounds.width + ", height: " + bounds.height);

		corner.adHolder.ad.adArea.width = bounds.width;
		corner.adHolder.ad.adArea.height = bounds.height;
		var area:AutoFitArea = new AutoFitArea(corner.adHolder, 0, 0, 250, 50, 0x000000);
		area.attach(corner.adHolder.ad, {scaleMode:ScaleMode.STRETCH, hAlign:AlignMode.LEFT, vAlign:AlignMode.CENTER, crop:true});
		area.preview = true;
		}
}

Link to comment
Share on other sites

You don't need to know the size in order to use AutoFitArea - that's kinda the point. AutoFitArea will handle fitting it into the area you define. But I didn't see any obvious errors in your code - were you running into trouble? If so, please describe.

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...