The code I posted was just a simple little example of how you could
create a 'raw' container that has no layout capabilities, and can accept
any DisplayObject. You could do it either like this:
 
 
<RawContainer>
    <SomeFlashSprite />
    <SomeBitmap />
</RawContainer>
 
Or...
 
<RawContainer id="rc" />
 
var bmp:Bitmap = new Bitmap();
// get some content into the bitmap.
 
rc.content = [bmp];
 
Ely.
 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of tosadavemgr
Sent: Wednesday, March 21, 2007 11:50 AM
To: [email protected]
Subject: [flexcoders] Re: copying bitmap data



It is interesting that I would get 4 replies, 4 completely different
answers. My entire week is going this way. As is my Flex project.
So my choices were:

1. Try the Grant Skinner blog and his DisplayObjectWrapper. Not
exactly sure how this works or how to use it within my code. 
2. Add .clone to my existing syntax, which I tried without luck
3. Have an image load an image and then copy that - interesting, yet I
have a canvas loaded with many bitmaps and need to make a bitmap of
the canvas ??
4. And finally, from Ely, and extension of the UIComponent class. I'm
sure this is something, but I'm not sure how to use it. 

I really appreciate the helpful spirit on this message board. My own
green-ness with Flex is part of the problem, but I thought for sure my
original direction would work since I pulled it almost directly from
the Flex docs. 

Here's the code from Flex Docs:

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;

var tf:TextField = new TextField();
tf.text = "bitmap text";

var myBitmapData:BitmapData = new BitmapData(80, 20);
myBitmapData.draw(tf);
var bmp:Bitmap = new Bitmap(myBitmapData);
this.addChild(bmp);

They are copying a TextField rather than a canvas. Is that the issue? 
OK to turn a TextField into a bitmap, but not a canvas?

Dave

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Ely Greenfield" <[EMAIL PROTECTED]> wrote:
>
> 
> 
> 
> [DefaultProperty("content")]
> class RawContainer extends UIComponent
> {
> private var _content:Array = [];
> public function set content(value:Array):void
> {
> _content = value;
> for(var i:int = 0;i<_content.length;i++)
> {
> addChildAt(_content[i],i);
> }
> while(numChildren > _content.length)
> removeChildAt(_content.length);
> }
> public function get content():Array { return _content }
> }
> 
> Ely.
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Troy Gilbert
> Sent: Wednesday, March 21, 2007 9:42 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: Re: [flexcoders] copying bitmap data
> 
> 
> 
> Yeah, the problem is that the Canvas container only allows children
that
> implement IUIComponent. It would have been real nice if Adobe had
> provided a "raw" container that did no layout of its children (but
> implemented IUIComponent itself), but they didn't. 
> 
> Fortunately, Grant Skinner has provided just such a container...
> DisplayObjectWrapper. Check out his blog or Google for it.
> 
> If you wrap your Bitmap with the DisplayObjectWrapper first you'll
then
> be able to add it (or rather, the DisplayObjectWrapper) to the canvas.

> 
> Troy.
> 
> 
> 
> On 21 Mar 2007 08:18:46 -0700, tosadavemgr <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> > wrote: 
> 
> I have a canvas in my layout and the application allows dragging
> and
> dropping items into the canvas. I need to be able to grab a
> bitmap of
> the canvas when the user is finished, so I can display the
> drawing on
> another panel, and in the FlexPrintJob function.
> 
> I've tried using this code, initiated from a button:
> 
> private function myDrawing():void{
> var myBitmapData:BitmapData = new BitmapData(530, 445);
> myBitmapData.draw(myWorkspace1);
> var bmp:Bitmap = new Bitmap(myBitmapData);
> showDrawing.addChild(bmp); //this isn't working
> 
> }
> 
> myWorkspace1 is the ID of the canvas where everything is
> dropped.
> I have a canvas with the ID=showDrawing that I'd like the bitmap
> to
> appear in. 
> Anyone know what I need to add to the above function to get that
> done?
> 
> Dave
>



 

Reply via email to