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
Draw a line with lingo
DM ChangeRes
keyboard input control
Field Entry Dialog Box
Director 8.5 Shockwave Studio: The Complete Reference
Toggle Button
Page turn
Generic Slider w/Text
Ripple Rain-Alphamania
Smooth / transparent windows and more! (odd shape windows part2)
 

 

 

Behavior Returns Rect of visible PDF doc within an Impressario sprite

Added on 7/25/2004

 

Compatibilities:
behavior D8_5 D9 Mac PC

Required Xtras:
INM's Impressario

This item has not yet been rated

Author: peterh

I'm came up with this when creating an application where "sticky notes" were to be attached to locations within PDFs. In order to track locations where the users placed notes on a document I needed to know where the visible rect of the PDF document sits within the sprite when the scrollH = 0 and scrollV = 0 (view of pdf document is smaller than the sprite). Currently there is no property that exposes this information, so I wrote this behaviour. Use: (Impressario sprite).getRectOfView() returns a rect of the boundary of the current view of the document contained within the sprite, even if it's smaller than the sprite. Rect is relative to the stage (or activeWindow).

-----------------
Property spriteNum
on getRectOfView()  --Returns the rect of document visible within an Impressario sprite, relative to the current stage...
  --Note: No sprites must exist underneath the Impressario sprite because the routine compares the color of pixels on the stage in the sprite's rect to the stage's bgColor. If you do place an sprite underneath, it must be all one color and you must change the value of in the 5th line from (the activeWindow).bgcolor to the color of that sprite.
  --Use of (the activeWindow) instead of (the stage) ensures the routine is suitable for MIAWs.

  pdfSprite=sprite(spriteNum)
  
  img=(the activeWindow).image
  centreX=pdfSprite.left+pdfSprite.width/2
  centreY=pdfSprite.top+pdfSprite.height/2
  bkdCol=(the activeWindow).bgcolor
  
  --traverse from left until color change...
  x=pdfSprite.left
  repeat while img.getPixel(x,centreY)=bkdCol
    x=x+1
  end repeat
  
  --traverse from top until color change...
  y=pdfSprite.top
  repeat while img.getPixel(centreX,y)=bkdCol
    y=y+1
  end repeat
  
  return rect(x,y,pdfSprite.right-(x-pdfSprite.left),pdfSprite.bottom-(y-pdfSprite.top))
end
-----------------

 


Contact

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

Send e-mail