Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getCachedImage(sku:String) : BitmapData
- {
- var numObjects:int = 0;
- var flashVar:Object = null;
- var regExp:RegExp = null;
- var startIndex:int = 0;
- var loader:Loader = null;
- var req:URLRequest = null;
- var context:LoaderContext = null;
- var i:int = 0;
- if(sku == null || sku == "")
- {
- return this.getDefaultPicture();
- }
- var bmp:BitmapData = this.mCachedObjects[sku];
- var uses:int = this.mUses[sku];
- var length:int = 0;
- if(this.mKeys == null)
- {
- length = this.mKeys.length;
- }
- if(bmp == null)
- {
- for each(bmp in this.mCachedObjects)
- {
- numObjects++;
- }
- if(numObjects == MAX_IMAGES)
- {
- for(i = 0; i < length; i++)
- {
- if(this.mUses[this.mKeys[i]] == 0)
- {
- delete this.mUses[this.mKeys[i]];
- BitmapData(this.mCachedObjects[this.mKeys[i]]).dispose();
- delete this.mCachedObjects[this.mKeys[i]];
- this.mKeys.splice(i,1);
- break;
- }
- }
- }
- flashVar = Star.getFlashVars();
- Security.loadPolicyFile("http://api.gamatar.org/crossdomain.xml");
- Security.loadPolicyFile("http://www.gamatar.org/crossdomain.xml");
- Security.loadPolicyFile("http://www8.gamatar.org/crossdomain.xml");
- Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
- Security.loadPolicyFile("http://cdn1.kongregate.com/crossdomain.xml");
- Security.loadPolicyFile("http://cdn2.kongregate.com/crossdomain.xml");
- Security.loadPolicyFile("http://cdn3.kongregate.com/crossdomain.xml");
- Security.loadPolicyFile("http://cdn4.kongregate.com/crossdomain.xml");
- Security.loadPolicyFile("http://api.kongregate.com/crossdomain.xml");
- Security.loadPolicyFile("http://l.yimg.com/crossdomain.xml");
- Security.loadPolicyFile("http://socialprofiles.zenfs.com/crossdomain.xml");
- Security.loadPolicyFile("http://avatars.zenfs.com/crossdomain.xml");
- regExp = /cdn.*.kongregate/i;
- startIndex = sku.search(regExp);
- if(startIndex > -1)
- {
- sku = sku.replace(regExp,"api.kongregate");
- }
- loader = new Loader();
- req = new URLRequest(sku);
- context = new LoaderContext(true);
- if(Security.sandboxType == Security.REMOTE)
- {
- context.securityDomain = SecurityDomain.currentDomain;
- }
- context.checkPolicyFile = true;
- loader.name = sku;
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.onComplete);
- loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.onError);
- loader.load(req,context);
- bmp = new BitmapData(IMAGE_SIZE,IMAGE_SIZE);
- bmp.draw(this.getDefaultPicture());
- this.mCachedObjects[loader.name] = bmp;
- }
- uses++;
- this.mUses[sku] = uses;
- return bmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement