Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » Width vs. Scale


Width vs. Scale

Reply
  #1 (permalink)  
Old 04-05-07, 03:10 PM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
Is there a way to change a movie clip's width without affecting _xscale?

Sorry - let me explain that better...

I am using a function that converts dynamically loaded images into bitmaps. This allows me to set "smoothing" for dynamic content. When I attempt to resize the image I load in, it resizes the "bitmap holder" but not the image itself.
actionscript Code:
  1. import flash.display.*;
  2.  
  3. function loadBitmapSmoothed(url:String, target:MovieClip) {
  4.     // Create a movie clip which will contain our unsmoothed bitmap
  5.     var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
  6.  
  7.     var listener:Object = new Object();
  8.  
  9.     // Track the target
  10.     listener.tmc = target;
  11.  
  12.     listener.onLoadInit = function(mc:MovieClip) {
  13.         mc._visible = false;
  14.     var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);   
  15.         this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);           
  16.        
  17.         bitmap.draw(mc);
  18.     bitmap.height = thumbH; //value set above
  19.     bitmap.width = thumbW; //value set above
  20.     };
  21.  
  22.     // Do it, load the bitmap now
  23.     var loader:MovieClipLoader = new MovieClipLoader();
  24.     loader.addListener(listener);
  25.     loader.loadClip(url, bmc);
  26. }
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."
Reply With Quote
  #2 (permalink)  
Old 04-06-07, 04:54 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
have a look at the BitmapData manual, especially the height property of the class. As you can see, the height property is read-only. So when you want to resize the bitmap, you should pass the resized width and height properties together with the constructor of the class:
Actionscript Code:
  1. new BitmapData(thumbW, thumbH, true);
i think this should, i'm not sure though. I've never faced this problem before, cause i change the size of my images manually (or with a server sided language) before loading them into flash

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 04-06-07, 10:57 AM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
I tried that (passing size with constructor) and it resizes the bitmap "holder", but not the actual image. For example, if I set it to 100x100, I only see the top-most and left-most 100 pixels - the rest of the image is cropped.

In this particular application, when a user clicks on a thumbnail, it zooms into a larger view. I don't want to resize the images out of flash because there needs to be a seamless "zoom".
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."
Reply With Quote
  #4 (permalink)  
Old 04-06-07, 11:11 AM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
I got it...

Code:
this.tmc._height = thumbH;
this.tmc._width = thumbW;
Rather than the bitmap itself. Thanks.
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rayvan Designs Tender Scale Revenant Job Offers & Assistance 1 04-06-09 03:55 PM
Firefox and align problems gigafare CSS 12 01-07-07 11:22 AM
link color.... stormshadow CSS 8 10-19-06 02:47 PM
span's width and height are 0! davidklonski JavaScript 0 06-30-04 03:50 AM
BUG in window.open(): resizable vs width bakcom JavaScript 0 12-15-03 06:41 AM


All times are GMT -5. The time now is 06:31 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.