A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: FreeCharacter tag

  1. #1
    Junior Member
    Join Date
    May 2001
    Posts
    26
    Hi:

    Can anybody tell me what is this tag and where I can find information and details about it please?

    thank you,
    Daniela

  2. #2
    This is one of the undocumented tags from Macromedia... Anyway, these are my findings:

    as you know every 'displayable' thing in Flash has to have an unique ID (Bitmaps, Symbols, Fonts, Movies, Sounds etc.). The idea is that when you have displayed one of these things (called character) and you don't need them anymore, you may free not only its ID but the memory associated with it. To be more clear: imagine a program that convert an AVI movie into a SWF file, this basically consists in reading the AVI video frame by frame, create a bitmap fill with each frame and display it using a rectangle shape. The dumped SWF file should look like this:


    Tag ID
    ......
    DefineBitsJPEG2 1 (or DefineBitsLossless if you prefer)DefineShape 2 (fill a rectangle with the bitmap above
    PlaceObject 2
    ShowFrame (displays first frame of the movie)

    DefineBitsJPEG2 3
    DefineShape 4
    PlaceObject 4
    RemoveObject 2 (we no longer need the first frame)
    ShowFrame (displays second frame of the movie)

    DefineBitsJPEG2 5
    DefineShape 6
    PlaceObject 6
    RemoveObject 4 (we no longer need the second frame)
    ShowFrame (displays third frame of the movie)

    DefineBitsJPEG2 7
    DefineShape 8
    PlaceObject 8
    RemoveObject 6 (we no longer need the third frame)
    ShowFrame (displays fourth frame of the movie)

    and so on.

    When you issue the RemoveObject tag, the object is only removed from the display list and not freed, so you can place it again later on. Above, you have the perfect case where when you remove an object you don't need it anymore and releasing the memory associated with it should greatly help the player (because they are all bitmaps), also you can reuse their character ID, in this way, the maximum memory usage of the player will be just of one bitmap (more or less). Applying this to the above code:

    Tag ID
    ......
    DefineBitsJPEG2 1 (or DefineBitsLossless if you prefer)DefineShape 2 (fill a rectangle with the bitmap above
    PlaceObject 2
    ShowFrame (displays first frame of the movie)

    RemoveObject 2 (we no longer need the first frame)
    FreeCharacter 2 (Free the shape)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1 (we can reuse the ID for bmp and shape)
    DefineShape 2
    PlaceObject 2
    ShowFrame (displays second frame of the movie)

    RemoveObject 2 (we no longer need the second frame)
    FreeCharacter 2 (Free the shape)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1
    DefineShape 2
    PlaceObject 2
    ShowFrame (displays third frame of the movie)

    RemoveObject 2 (we no longer need the third frame)
    FreeCharacter 2 (Free the shape)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1
    DefineShape 2
    PlaceObject 2
    ShowFrame (displays fourth frame of the movie)

    and so on.

    Now, I haven't tried the following, but looking at the source code of the player it should work, you should be able to just free the bitmap and define the new one in order to display it, like:

    Tag ID
    ......
    DefineBitsJPEG2 1 (or DefineBitsLossless if you prefer)DefineShape 2 (fill a rectangle with the bitmap above
    PlaceObject 2
    ShowFrame (displays first frame of the movie)

    // In the following code we remove the shape from the
    // display list to avoid display corruption, we free the
    // bitmap and define a new one, so the shape using that
    // fill should use that instead of the old one
    // This should possibly create some flicker on the screen
    // maybe simulating a double buffer using two shapes
    // should help

    RemoveObject 2 (we no longer need the first frame)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1 (we can reuse the ID for bmp)
    PlaceObject 2
    ShowFrame (displays second frame of the movie)

    RemoveObject 2 (we no longer need the second frame)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1
    PlaceObject 2
    ShowFrame (displays third frame of the movie)

    RemoveObject 2 (we no longer need the third frame)
    FreeCharacter 1 (Free bitmap)
    DefineBitsJPEG2 1
    PlaceObject 2
    ShowFrame (displays fourth frame of the movie)

    and so on.

    Hope this help.


    Cheers,
    Lev

  3. #3
    Senior Member
    Join Date
    Oct 2000
    Posts
    197
    So assuming I have this line in my code:

    movie.Frame(i)->RemoveObject(bitmap);

    Where and how should I call the "FreeCharacter" function?

    Xn

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    501
    After you are finished completely with the ID (so, after you remove it from the screen if you won't be using it again).

    --Jesse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center