Share Posted March 31, 2011 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 More sharing options...
Author Share Posted March 31, 2011 There must be something? Link to comment Share on other sites More sharing options...
Share Posted April 14, 2011 There is no width/height/scaleMode for DataLoader - that wouldn't make a lot of sense because it's just a generic data loader (the data could be virtually anything). But you certainly could use AutoFitArea if you want to fit a DisplayObject into a particular area - http://www.greensock.com/autofitarea/ Does that help? Link to comment Share on other sites More sharing options...
Author Share Posted May 6, 2011 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 More sharing options...
Share Posted May 6, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now