How can I store bitmap data in the SharedObject class?

Any ideas?

What I tried to do. First run the "code" then the "Second code '.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
     <![CDATA[
          import mx.controls.Image;
          private function init():void
          {
               var o:SharedObject = SharedObject.getLocal("t1","/");
               
               //First code
               o.clear();
               var bit:Bitmap= new Bitmap(new BitmapData(100,100,false,0));
               o.data.bit=bit;
               o.flush();
               
               //Second code               
               var bit:Bitmap = o.data.bit;
               var pic:Image = new Image();
               pic.source=bit;
               Application.application.addChild(pic);
               
               
          }
     ]]>
</mx:Script>     
</mx:Application>

godilya,

Sorry about that. Since there were a lot of mistakes in your code I just fixed all. But you are right that even after he still not actually saved it to the SO.

I would recommend saving them as a ByteArray, that appears in literature as one of the supported by the SharedObject object classes.

First code

var bitmap: Bitmap = new Bitmap (BitmapData (100,100,false,0xFF0000) new);

var bitmapData:BitmapData = bitmap.bitmapData;

var byteArray:ByteArray = bitmapData.getPixels (bitmapData.rect);

so. Clear();

so.data.byteArray = byteArray;

so. Data.Width = bitmapData.rect.width;

so. Data.Height = bitmapData.rect.height;

so. Flush();

Second code

var byteArray:ByteArray = ByteArray (so.data.byteArray);

var bitmapData:BitmapData = new BitmapData (so.data.width, so.data.height);

bitmapData.setPixels (bitmapData.rect, byteArray);

var bitmap: Bitmap = new Bitmap (bitmapData);

Photo: Image of var = new Image();

PIC.source = bitmap;

Application.application.addChild (pic);

I have tested it properly, with a comment, then the other.

Thank you

Philippe

Post edited by: Philip Keiter

Tags: Flex

Similar Questions

Maybe you are looking for

  • Satellite A210-1AO does not start

    Hello I could use a little help. My 4 year old A210 1AO worked perfectly until today (except to change the HARD disk a few months before). Tonight, I tried to turn it on, but almost nothing happens. The light 'on' is on, the battery the power and lig

  • elitbook HP 2740 Important Bios

    I downloaded this player ' HP Notebook System BIOS update VERSION: F.04 "of your Web site and after this set.The unit does not light Then the machine was not able to open any interface In this case, can someone help meSend me a valid BIOS update file

  • Event ID of diagnosis-perfomance: 100. Slow start

    No recent changes. A boot suddenly dropped from 30 seconds to 3 minutes. Log name: Microsoft-Windows-Diagnostics-Performance/OperationalSource: Microsoft-Windows-Diagnostics-PerformanceDate: 2010-07-12 19:30:48Event ID: 100Task category: startup perf

  • Report - unsubscribe by email

    Hello Eloqua community!I'm looking for a report that will give her me cancel the subscription emails from 10 or 15 global albums gave us. In other words, this e-mail had the highest rate of churn during the last month or X calendar. I see a report "T

  • Is it possible to get Windows 7 (the driver installation) to recognize the HP DeskJet 722C printer. ?

    I have a 722C Deskjet connected via a cable to a computer running Win XP on a network.  I just added a new HP pavilion p2-1102 with Windows 7 on the network.  Windows 7 sees the printer but will not install the driver because I can't use the USB port