Images and Bitmap Data - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Images and Bitmap Data

Description:

Notifies us when the data has loaded and after it is initialised (for MovieClips) ... The loaded content will be accessible through the given reference, but the ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 20
Provided by: nathanielf
Category:
Tags: bitmap | data | images | loaded

less

Transcript and Presenter's Notes

Title: Images and Bitmap Data


1
Images and Bitmap Data
  • 2533CIT - Week 13

Coridyn Fitzgerald-Hood
2
Images
  • Working with images and bitmap data is an
    important part of flash programming.

3
Loading External Images
  • Flash allows us to load external Images and Flash
    movies (compiled swfs) using the MovieClipLoader
    class.
  • The MovieClipLoader class is the class-based
    equivalent to the MovieClip.loadMovie() and
    MovieClip.loadMovieNum() functions.

4
MovieClipLoader
  • Using the MovieClipLoader has quite a few
    benefits
  • The MovieClipLoader instance is reusable,
  • It supports event handling,
  • Notifies us when the data has loaded and after it
    is initialised (for MovieClips).
  • Provides an easy interface for monitoring the
    status of a MovieClip/image download.

5
MovieClipLoader
  • The MovieClipLoader is designed to allow you to
    load external graphical content into a particular
    MovieClip instance in your existing Flash movie.
  • The use of the MovieClipLoader class follows a
    standard pattern
  • Instantiate the MovieClipLoader instance.
  • Set event handling functions.
  • Initiate load.
  • Respond to events.

6
MovieClipLoader Example
  • See MCLExample in content.

7
MovieClipLoader
  • An important thing to take note of with the
    loadMovie function of the MovieClipLoader class
    is that the loaded content replaces the MovieClip
    instance passed as the second parameter.
  • The loaded content will be accessible through the
    given reference, but the original content will be
    unavailable.
  • The loaded content also inherits the rotation,
    scaling and translation properties of the
    original MovieClip.

8
Loading Images
  • It is important to remember that images loaded
    with the MovieClipLoader will also replace the
    existing content in the MovieClip target.
  • This is more important to remember for image
    content because images cannot be manipulated with
    actionscript code.
  • This is important enough for repetition
  • Images cannot be accessed or manipulated through
    Actionscript code.

9
Loading Images
  • To work with dynamically loaded image data we
    must perform a simple trick.
  • Load the image data into a child of the intended
    MovieClip target.
  • Once the image data has been loaded, treat the
    parent MovieClip as the image itself. This allows
    us to scale, rotate and translate the image on
    the screen.

10
Loading Images (Incorrect)
  • Loading Image content into a MovieClip instance.
  • Before
  • After

11
Loading Images (Correct)
  • Before
  • After

12
Bitmap Data
13
BitmapData Class
  • Flash 8 introduced the ability to directly access
    and manipulate bitmap image data.
  • This ability has been used to great effect in
    many Flash applications e.g. textured 3D
    renderers
  • (and to much lesser effect in others e.g.
    Puzzle Application).
  • Either way it is a useful and interesting class.

14
BitmapData - General Use
  • Instantiate the BitmapData class.
  • Attach the BitmapData instance to a MovieClip
    instance.
  • Manipulate the BitmapData instance drawing
    directly to the bitmap data or running filters on
    the existing data.
  • Draw the BitmapData to the stage.

15
BitmapData.draw()
  • The draw function lets us draw bitmap data
    directly from one source onto the current
    BitmapData instance.
  • This is very useful for drawing the current
    representation of a MovieClip or other BitmapData
    instance.

16
BitmapData example
  • See FlashPaint in content.

17
BitmapData.loadBitmap()
  • Use the loadBitmap() function to load an image
    from the library onto the stage.
  • The loadBitmap function was used in the Puzzle
    application to draw the initial puzzle image
    before being split into the puzzle pieces.

18
BitmapData.copyPixels()
  • Use the copyPixels function to quickly copy
    bitmap information from one BitmapData instance
    to another.
  • You can copy information from the same BitmapData
    instance if required.

19
loadBitmap, copyPixels Example
  • See Puzzle in content.
Write a Comment
User Comments (0)
About PowerShow.com