Share Posted December 21, 2012 Hello, I am working on a prototype in Flex using LoadMax to load an image into a loader FlexContentDisplay. The FlexContentDisplay is embed in a Canvas which is added to the TransformManager. I have to work on width, height, x and y of this image in the canvas. My question is : Is it better to work on the rawContent property of FlexContentDisplay or directly with the FlexContentDisplay ? I wonder this as the FlexContentDisplay extends UIComponent, I cannot really work on width and height but directly with scaleX and scaleY. Many thanks Link to comment Share on other sites More sharing options...
Share Posted December 21, 2012 I would probably use the FlexContentDisplay itself, as the rawContent is just a Bitmap which cannot (if I remember correctly) be added to the display list in a Flex app because it doesn't extend UIComponent. Are you saying that FlexContentDisplay doesn't work properly with TransformManager? Or that when you alter its width/height, it seemingly has no effect? Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2013 No it works fine. I used FlexContentDisplay directly with transformamanager. Now I wonder if I could load a bytearray in a flexcontentdisplay object using loadermax ? Another solution could be the use of a simple loader to retrieve the bitmap, but I don't know how to set this bitmap to the FlexContentDisplay as it is null. Best Link to comment Share on other sites More sharing options...
Share Posted February 22, 2013 Is there a reason you'd use a plain Loader instead of a LoaderMax ImageLoader? The ImageLoader works great with FlexContentDisplay. I suppose you could use a DataLoader to load a bytearray and then make that into an image and put it into the FlexContentDisplay, but I'm having a very hard time seeing why that would be better than simply using an ImageLoader. Much simpler, but maybe I'm missing something. Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2013 I tried ImageLoader and have an error :error occured with ImageLoader ... loading has not been completed I tried (where ba is my ByteArray): LoaderMax.contentDisplayClass = FlexContentDisplay; var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); queue.append( new DataLoader(ba, {format:"binary", name:_imageName}) ); private function completeHandler(event:LoaderEvent):void { var o:* = LoaderMax.getContent(_imageName); } o is null I do not understand. Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2013 For the error I mentioned LoaderMax.getContent return a FlexContentDisplay but with rawContent setted to null (o.rawContent == null) : LoaderMax.contentDisplayClass = FlexContentDisplay; var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); queue.append( new DataLoader(ba, {format:"binary", name:_imageName}) ); private function completeHandler(event:LoaderEvent):void { var o:* = LoaderMax.getContent(_imageName); } Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2013 When you said put it in FlexContentDisplay I wonder how, as the FlexContentDsiplay is still not instanciate and it needs a LoaderItem in its constructor. My situation is : 1) Selection of an image with a fileReference and load Bitmap from its content 2) Encode bitmapdata with JPEG or PNG Encoder and make a base64 of the bytearray returned 3) the string is store to be used at anytime. I make a base64 decode to retrieve the bytearray and now I want to load it in a container that use the FlexContentDisplay. Do you have any suggestions beacause I really do know how to load it in the FlexContentFisplay ? Link to comment Share on other sites More sharing options...
Share Posted February 22, 2013 Why would you want to use FlexContentDisplay? That class is intended to be used with LoaderMax loaders - why not use something like a FlexBitmap or FlexSprite? Link to comment Share on other sites More sharing options...
Author Share Posted February 23, 2013 Because the case for which this post is open represent only 10% in the application. All others cases use loadermax and flexcontentdisplay. The object which display the bitmap is based on FlexContentDisplay, and I wish to use this object to have an homogeneous behavior. You think that my case could not be solved using FlexContentDisplay ? Link to comment Share on other sites More sharing options...
Share Posted February 23, 2013 This definitely wouldn't be "supported" or recommended (because FlexContentiDisplay was designed to be used with LoaderMax), but you could try creating a FlexContentDisplay with a null loader and then set its rawContent to your content, like: var cd:FlexContentDisplay = new FlexContentDisplay(null); cd.rawContent = YOUR_DISPLAY_OBJECT; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now