The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • rocking Author 
    • 290 
    • 0 
    • 0 
    Loading images takes up too much memory
    rocking

    No comments yet

    Be the first to comment

    Posted: Jul 01 2009, 03:44 PM

    by rocking

     

I am frustrated! I am working on an application, using Flash CS3 + AIR, that involves some heavy content loading. I need to fetch some 140 gif files each around 400x400 in resolution and 50KB in size and display them in a TileList. The code that I am using is pretty standard stuff, (excerpts from the cellrenderer of my TileList):

private function loadImage(imageUrl:String):void
{
    
var imageLoader:Loader = new Loader();
    var 
imageReq:URLRequest = new URLRequest(imageUrl);
            
        
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageFetched, false, 0, true);
        
imageLoader.addEventListener(IOErrorEvent.IO_ERROR, imageFetchedFailed, false, 0, true);
        
imageLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, imageFetchedFailed, false, 0, true);
            
    
imageLoader.load(imageReq);
}

private function imageFetched(e:Event = null):void
{

    
if (sectionImageHolderSprite == null)
    
{
        sectionImageHolderSprite 
= new Sprite();
        
this.addChild(sectionImageHolderSprite);
    
}

    bitmap 
= new Bitmap((e.target.contentLoaderInfo.content as Bitmap).bitmapData);
    
bitmap.smoothing = true;
    
bitmap.cacheAsBitmap = true;
    
bitmap.name = "bitmap";
    
        
/* Set the display size appropriately - maintain the aspect ratio */
    
var imageAspectRatio:Number = (bitmap.width < bitmap.height) ? bitmap.width/bitmap.height : bitmap.height/bitmap.width ;

    if(
bitmap.width >= bitmap.height)
    
{
        bitmap
.width = 150;
        
bitmap.height = bitmap.width * imageAspectRatio;
    
}
    
else
    
{
        bitmap
.height = 150;
        
bitmap.width = bitmap.height * imageAspectRatio;
    
}
    
    bitmap
.x = 25;
    
bitmap.y = 25;
            
    
/* Add it to the display list */
    
sectionImageHolderSprite.addChild(bitmap);
} 

One would think that the memory required for the images would be around 500KB each (assuming 3 bytes/pixel of raw bitmap data), totaling around 70MB. But when I see the memory in task manager, it takes around 320 MB. And my memory caps if I reload these images three times!

What is going on here? This is unacceptable frown Firefox/chrome take around 20MB to display an equivalent page. Why does flash require so much memory? Or am I doing something awful here?

  0 REPLIES
 
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 775  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,724  Assets
  • Profiles 282,659  Members
  • Topics 93,762  Topics
  • Blog 4  Blog
  • Facebook 1,680  Facebook
  • Twitter 1,165  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 04, 2012 - 20:08:29