A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] Problem with converting frames of a MovieClip to Bitmaps

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    7

    resolved [RESOLVED] Problem with converting frames of a MovieClip to Bitmaps

    Hello everyone, I'm trying to convert the frames of a MovieClip (mc) --which are vector graphics-- to Bitmaps in order to improve performance.

    The Logic is simple: During the first time play of the mc on every frame I convert the vector display of the mc to BitmapData with their appropriate transformation applied and store these BitmapData instances in an Object with the frame number as the key. I use these BitmapData instances to create Bitmap instances and use them in place of the actual mc during the successive play.

    Everything works fine except that there is a random but small position error for the created Bitmap instances so it looks like its vibrating in its place. I have no idea what is causing this.

    Any insight into the problem is much appreciated. I have attached the Flash Builder 4 AS project for anyone who wants to look at the code. The swf file can be found in the 'bin-debug' folder when extracted.
    Attached Files Attached Files

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Why not just manually export each frame of the .fla as a .png and replace your vector frames altogether?

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    That will be too much of a hassle for the graphic designers... besides, I dont see why the Bitmap looks like its vibrating... I mean I do have applied the geometric transformation matrix and placed it at the proper position...

  4. #4
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Also, exporting each frame as a .png drastically increases file size...

  5. #5
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You can try messing the the cacheAsBitmap options for your sprite or the pixelSnapping setting for your bitmaps.

  6. #6
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Tried that too but to no effect...

  7. #7
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I only glanced at your code so I can't say for sure what's causing it. I would suggest however not using the dimensions of each captured bitmapdata. Instead create each bmd object with exactly the same width and height and drawing the pixels starting at the exact same coordinate. PixelSnapping should be turned off.

  8. #8
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    hmm... that is a very good suggestion... I'll try that out and let u know... Thank u very much jAQUAN...

  9. #9
    Member
    Join Date
    Aug 2010
    Posts
    65
    its an old problem, here is a thread with a demo http://www.coldhardflash.com/phpbb/v....php?f=2&t=277

  10. #10
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Not the same problem I think. Imo, jAQUAN's suggestion is going to fix it.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  11. #11
    Junior Member
    Join Date
    Aug 2010
    Posts
    7

    [RESOLVED] Problem with converting frames of a MovieClip to Bitmaps

    Quote Originally Posted by Smilev View Post
    Not the same problem I think. Imo, jAQUAN's suggestion is going to fix it.
    U're right about that Smilev, its not the same problem...

    I finally found the solution: Even though jAQUAN's suggestion not exactly fix it, the solution I found works on the same grounds: keeping the size and position constant... I could have used jAQUAN's suggestion exactly as he said but,
    1) I dont know how big the movieclip was going to be and the size of its frames(dimension-wise) --I dont know the size, and
    2) The registration point of each movieclip was not exactly at the top-left corner of the movieclip and its chosen based on a criterion we have set earlier --so I dont know the position

    So what I did was I drew a rectangle of alpha=0 and of fixed size and position and put it at the lowest layer of the moviclip but whose size is big enough to accommodate all the animations that happen in the mc but not so big as to increase the dimensions of the BitmapData tremendously. I also made the size values and the position values to integers just to be extra careful... This has solved the problem and I'm happy with it...

    Thank u all for ur help...
    Last edited by sanoysyk; 08-21-2010 at 01:07 AM.

  12. #12
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    This is an example of why there's not a silver bullet fix for every problem. Way to get creative with the solution.

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