Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
ActiveX Web controler
Real Player ActiveX Control
ISOinteractive (Isometric Collision Path Editor) in BETA!
Amara Flash Photo Animation Software
Pretty Script
ZGTSB-ButtonDown
Roil-Alphamania
Pause Button
Toggle Pause / Play Audio
PC Mac Lan
 

 

 

Behavior Image Resizer v1.0

Added on 4/20/2006

 

Compatibilities:
behavior D6_5 D7 D8 D8_5 D9 PC

This item has not yet been rated

Author: proufas

You just have to put the prefered dimensions of an image and the script resize it without stretching.

----------------------------------------------------------------------------------------
---- I M A G E  R E S I Z E R v1.0 -----------------------------------------------------
---- ::: Copyright 2006 :::  -----------------------------------------------------------
---- [ Profitakis Konstantinos (proufas@mycosmos.gr) ::: BRAIN.net ::: GREECE ::: ] ----
----------------------------------------------------------------------------------------
---- How it works:
---- You have to insert the prefered image dimensions in the parameters and then, let -
---- the script work. ------------------------------------------------------------------
----------------------------------------------------------------------------------------

property spritenum, pMaxWidth, pMaxHeight

----------

on getBehaviorDescription me
  return "IMAGE RESIZER v1.0" & RETURN & "Copyright 2006 - Profitakis Konstantinos (proufas@mycosmos.gr) - BRAIN.net - GREECE" & RETURN   & "How it works:" & RETURN   & "You have to insert the prefered image dimensions in the parameters and then, let the script work."
end


----------

on getPropertyDescriptionList me
  
  --Dimension selection
  set plist to [:]
  addprop plist, #pMaxWidth, [#comment:"Max width of image", #format:#integer, #default:0]
  addprop plist, #pMaxHeight, [#comment:"Max height of image", #format:#integer, #default:0]
  return plist
  
end

----------

on beginsprite
  
  --Gets the initial dimensions
  mySprite=sprite(spritenum)
  InitImageWidth=mySprite.width
  InitImageHeight=mySprite.height
  
  --Checks if image is landscape or portrait
  if InitImageWidth>InitImageHeight then
    ImageType="landscape"
  else
    ImageType="portrait"
  end if
  
  --Makes the calculation
  if ImageType="landscape" then
    ratio=(InitImageHeight.float)/(InitImageWidth.float)
    FinalImageWidth=pMaxWidth
    FinalImageHeight=pMaxWidth*ratio
  end if
  
  if ImageType="portrait" then
    ratio=(InitImageWidth.float)/(InitImageHeight.float)
    FinalImageWidth=pMaxHeight*ratio
    FinalImageHeight=pMaxHeight
  end if
  
  --Final step and centers the registration point of the image
  sprite(spriteNum).member.centerRegPoint=1
  mySprite.width=FinalImageWidth
  mySprite.height=FinalImageHeight
  
end

----------


 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail