Loading bitmapdata from external image?

Hi everyone,
I'm trying to retrieve the bitmapdata from an external image. In order to test my code, I convert the bitmapdata data a bitmap and I add it to the stage. Unfortunately I get a TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Bitmap@6b147e1 to mx.core.IUIComponent.
Do you see why this error occurs?
My code:
import flash.display.BitmapData;
import flash.display.Bitmap;
private var bitmapData:BitmapData;
private function init():void
     var loader:Loader = new Loader();
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
     loader.load(new URLRequest("Beach.jpg"));
     var myImage:Bitmap = new Bitmap(bitmapData);
     addChild(myImage);    
private function onComplete (event:Event):void
      bitmapData = Bitmap(LoaderInfo(event.target).content).bitmapData;
Thanks in advance

Now I want to convert the bitmapdata to a bitmap and display it. I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::BitmapData@727c629 to flash.display.Bitmap.
Can you explain how to convert bitmapdata to bitmap and display it properly?
My code:
private var bitmapData:BitmapData;
private var myImage:Bitmap;
private function init():void
     var loader:Loader = new Loader();
     loader.load(new URLRequest("Strand.jpg"));     
     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
private function onComplete (event:Event):void
     myImage = Bitmap(LoaderInfo(event.target).content);
     bitmapData = new BitmapData(320,240);
     bitmapData = myImage.bitmapData;
     //adding the image to a container (  sprite  )
     var container:Sprite = new Sprite();
     container.addChild( Bitmap(bitmapData) );
     // adding the container to a stage
     this.rawChildren.addChild(container);   

Similar Messages

  • How to load webParts from external assemblies ?

    Hi
    i'm facing the problem when loading webParts from external assemblies. i've a lot of searched on internet, but nothing found! also i create a thread on
    asp.net forum, but nobody answer!
    does something wrong or is there any way to accomplish this ?
    thanks in advance
    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

    Hi, Sure!
    here is my code :
    Aspx :
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:WebPartManager ID="WebPartManager1" runat="server">
    </asp:WebPartManager>
    <div>
    <asp:DropDownList ID="ddlDisplayMode" runat="server" AutoPostBack="True"
    onselectedindexchanged="ddlDisplayMode_SelectedIndexChanged">
    <asp:ListItem>Browse</asp:ListItem>
    <asp:ListItem>Design</asp:ListItem>
    </asp:DropDownList>
    <br />
    <div id="divWebPartBar" runat="server" visible="false">
    <asp:DropDownList ID="ddlWebParts" runat="server">
    </asp:DropDownList>
    <asp:DropDownList ID="ddlZones" runat="server">
    </asp:DropDownList>
    <asp:Button ID="btnLoadWebPart" runat="server"
    Text="Load WebPart to Selected Zone" onclick="btnLoadWebPart_Click" />
    </div>
    <div>
    <asp:WebPartZone ID="WebPartZone1" runat="server">
    <ZoneTemplate>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </ZoneTemplate>
    </asp:WebPartZone>
    </div>
    <div>
    <asp:WebPartZone ID="WebPartZone2" runat="server">
    </asp:WebPartZone>
    </div>
    </div>
    </form>
    </body>
    </html>
    Default.aspx.cs :
    public partial class Default : System.Web.UI.Page
    const string _webPartsPath = "~/bin/CustomWebParts";
    private static Dictionary<string, Type> _dicWebparts;
    protected void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)
    _dicWebparts = LoadWebParts(_webPartsPath);
    foreach (string webPart in _dicWebparts.Keys)
    ListItem item = new ListItem(webPart);
    this.ddlWebParts.Items.Add(item);
    foreach (WebPartZone wpz in this.WebPartManager1.Zones)
    ListItem item = new ListItem(wpz.ID);
    this.ddlZones.Items.Add(item);
    //MyWebPart myWebPart = new MyWebPart();
    //this.WebPartManager1.AddWebPart(myWebPart, this.WebPartZone2, 0);
    protected void ddlDisplayMode_SelectedIndexChanged(object sender, EventArgs e)
    if (ddlDisplayMode.SelectedValue == "Browse")
    this.WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode;
    this.divWebPartBar.Visible = false;
    else if (ddlDisplayMode.SelectedValue == "Design")
    this.WebPartManager1.DisplayMode = WebPartManager.DesignDisplayMode;
    this.divWebPartBar.Visible = true;
    protected void btnLoadWebPart_Click(object sender, EventArgs e)
    Type type = _dicWebparts[this.ddlWebParts.SelectedValue];
    WebPart webPart = (WebPart)Activator.CreateInstance(type, null);
    //this.WebPartManager1.AddWebPart(webPart, this.WebPartManager1.Zones[this.ddlZones.SelectedValue], 0);
    WebPartZone zone = (WebPartZone)this.WebPartManager1.Zones["WebPartZone2"];
    this.WebPartManager1.AddWebPart(webPart, zone, 0);
    private Dictionary<string, Type> LoadWebParts(string path)
    Dictionary<string, Type> dicResult = new Dictionary<string, Type>();
    string[] webPartsAssemblyPath = Directory.GetFiles(Server.MapPath(path), "*.dll", SearchOption.AllDirectories);
    if (webPartsAssemblyPath != null & webPartsAssemblyPath.Length > 0)
    foreach (string file in webPartsAssemblyPath)
    Assembly assembly = Assembly.LoadFile(file);
    Type[] types = null;
    try
    types = assembly.GetTypes();
    foreach (Type type in types)
    if (typeof(WebPart).IsAssignableFrom(type))
    //object obj = Activator.CreateInstance(type);
    //WebPart plugIn = (WebPart)obj;
    dicResult.Add(Path.GetFileNameWithoutExtension(file), type);
    catch (Exception ex)
    continue;
    return dicResult;
    My sample webpart in external assembly :
    namespace MyWebPart1
    public class MyWebPart1 : WebPart
    protected override void CreateChildControls()
    this.Controls.Clear();
    Label lbl = new Label();
    lbl.Text = "Hello web part 1";
    this.Controls.Add(lbl);
    this.ChildControlsCreated = true;
    thanks in advance
    http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

  • Load data from external table

    Hi ,
    How to load data from external table to transaction table using SQLLDR ?

    You use an external table to load the data it is described in the link to the manual I provided.
    Here is an example.
    Re: Using DML order to import a .xls file
    You would not be using SQLLDR though as external tables replace that functionality.

  • Batch loading jpegs from external file

    Hello,
    I would like to preload a batch jpegs from an external file
    (to make it easy for changes) - than use them in a slide-slide show
    using a movieClip holder or loader component. I can use this
    tutorial -
    http://www.oman3d.com/tutorials/flash/portfolio_2_bc/index.php
    But I don't what to have each jpeg loaded separately I want
    them to preload b4 using..
    What would be the best way to preload the external batch to
    use for a slide show with next btn and prev btn? I can't find any
    tutorials one this.
    Thanks for any help,
    Dave

    In terms of where:
    Well, for as2, you will probably need to load them as
    dynamically created child clips of a single parent clip that you
    use to display one swf from. You would cycle through them and just
    set the _visible property of your 'current' clip to true and all
    the others to false. Your next and previous buttons could change
    which one was visible.
    But if they are large images, you'll probably use a lot of
    memory doing it this way and it would take longer to load them all
    at the start. Its more usual to, for example, load all the
    thumbnail images - smaller images, quicker to load - and then load
    the larger one into a main viewing area when its thumbnail is
    clicked.
    How
    There are plenty of examples of how to do this in tutorials
    etc.
    If you want to load all the thumbnails first, then perhaps
    you won't find exactly what you want as a tutorial. Not every
    possibility is covered in a tutorial. All I can really do is point
    your in the right direction. If it were me I would use something
    like David Stiller's MultiLoader class to make it easier perhaps
    (in fact I have my own which works a little differently but was
    seriously inspired by what I learnt from David's article at
    http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part1
    & 2 )

  • Saving JPEG from External Image Editor (CS2)?

    When I purchased Aperture I'd hoped it would store three copies of each photo; the original untouched RAW and a Photoshopped TIFF and JPEG, but 70mb+ TIFF files appear to be taking their toll. I will probably store them in another app, leaving the RAW and JPEG in Aperture.
    Anyway, to cut to the question.
    I send a 16 bit TIFF to CS2 directly from Aperture using the 'External Image Editor' option. When I've done all of the necessary work in CS2, save the 16bit TIFF, and then convert to 8 bit and 'Save As' to JPEG.
    Aperture appears to be able to automatically retrieve a TIFF file, but not a JPEG.
    Does anybody have any ideas of a way round this?
    Currently, I'm saving JPEG's to my desktop, then re-importing into Aperture. I hoping it doesn't need to be quite so long winded!

    Fast is a relative term. However, I will say this: I shoot primarily RAWs, and my largest megapixel count is the 11 megapixels of my Canon 1Ds. On my PowerBook I felt Aperture was fast enough for image sorting and metadata editing, but was a bit jerky and slow for image adjustments. Also, the PowerBook video card was not up to the task of switching views because it would regularly get scrambled and then settle down when switching views. I bought a MacBook Pro C2D w/2GB RAM and I'm very happy with the performance of Aperture on this machine. Adjustments are smooth. Even loading the Masters from 7200 RPM external drive seems much snappier on the MBP.
    I haven't had much time with Aperture on my G5 Dual 2GHz w/3.5GB RAM because I severely fractured my ankle shortly after I bought Aperture and only one hour after I arrived home with my new Raedon X800XT graphics card. (My G5 is up a flight of stairs in my studio and I have to sit with my leg elevated 24/7.) I've read in this forum that this combination is workable, but perhaps I'll find myself wishing for a MacPro. Given how happy I am with the MBP, I can't imagine being unhappy with a MacPro.
    I keep Activity Monitor running on my machine and have set it to load on boot. I set the icon to show the memory usage pie chart. I keep an eye on it as I run my programs. I only keep essential programs open when I am working in Aperture.
    I have found that smaller projects are quicker. Like you, I originally had multiple thousands of images in projects. Then I changed my structure to have many projects under blue folders. My projects are all under 1,000 images now.
    BTW, have you seen this post?
    http://discussions.apple.com/message.jspa?messageID=3663650#3663650
    -Karen

  • Best to load preloader from external file or place it directly into existing movie?

    Is it best to load the preloader from external file or place it directly into an already existing movie?

    there's no one answer for everyone.
    but for an inexperienced coder that's already completed their main project and is adding a preloader as an after-thought, it's usually easiest to create a stand-alone preloader.
    and even for experienced coder's, that's usually the easiest way to preceed.

  • Loading font from external *.swf

    So!
    I have 3 movies.
    1)Main movie - index.swf
    2)Movie with created & checked in linkadge "Export for
    runtime sharing" fonts in library - fonts.swf
    3)movie with text fields which need embeded fonts to work in
    a proper way. Fonts in the library checked in linkage as "import
    for runtime sharing" - content.swf
    What happens:
    I strike CTRL+ENTER and run movie index.swf.
    on the (for ex.) 10 frame it loads fonts.swf with
    movieClipLoader class..
    then in the same way on (for ex.) 100 frame, i load content
    swf
    BUT!!! before it starts loading process IT DOWNLOADS FONT.swf
    again
    SO HOW DO I PRELOAD fonts from external *.swf..
    maybe there is yhe way without using runtime sharing..
    but i've heard that loaded whith movieClipLoader movies don't
    adds objects from their library to main movie liblary...
    HOW DO I SOLVE THIS PROBLEM!

    can you give your erroe source code,and then i will give you the success code.
    in the function
    private function onLoadComplete(e:Event):void {}
    ApplicationDomain.currentDomain.getDefinition("com.scottgmorgan.ExternalMovie") ;
    use like this:
    var EMClass:Class=loader.contentLoaderInfo.applicationDomain.getDefinition("com.scottgmorgan.ExternalMovie") ;
    then you can new a instance :
    var emInstance:Object=new EMClass();
    emInstance.alert("hello word");
    and we also can use other method. so email me  [email protected]

  • ITunes won't load library from external HDD.

    I'm a DJ in Miami. I have 1TB+ of music. I have it in my HDD that I've used for months with my Macbook Pro Retina. For some reason I opened iTunes a couple days ago before a gig & my HDD wasn't loaded to the library. I went into the preferences & chose my HDD again but when I click apply it just closes the window & nothing happens. My music & playlists won't show up. Everything is still on my HDD so I know that's not it. I even formatted my Macbook & installed a fresh copy of Mavericks hoping that would solve it but it won't work. I have a backup HDD as well but iTunes won't load it either.

    I think if you are using iTunes in a semi-professional capacity you need to learn how it works:
    What are the iTunes library files? - http://support.apple.com/kb/HT1660
    More on iTunes library files and what they do - http://en.wikipedia.org/wiki/ITunes#Media_management
    What are all those iTunes files? - http://www.macworld.com/article/139974/2009/04/itunes_files.html
    Where are my iTunes files located? - http://support.apple.com/kb/ht1391
    iTunes 9 [and later]: Understanding iTunes Media Organization - http://support.apple.com/kb/ht3847
    Image of folder structure and explanation of different iTunes versions (turingtest2 post) - https://discussions.apple.com/docs/DOC-7392
    You will normally only have one .itl file.  It is the library file, along with a smattering of support files and folders.  Most of your files are just media files but it's the .itl that gives it all structure.  The reason I can't answer your question is most people don't understand "library" has a specific meaning in iTunes.  It isn't just media, it's the whole lot working together.  Now some people split their library and keep the main files on the main drive, and media on the external.  Better is to keep it all together, either on internal or external.
    You should have a .itl file somewhere.  Conceivably if your drive is corrupt or something weird happened then it might be gone.  That's what backups are for.  If nothing else you should have old copies of the library fro when you last upgraded iTunes.  Did you do a spotlight search?
    If your library file is really gone then you will have to build it again:
    iTunes: How to re-create your iTunes library and playlists - http://support.apple.com/kb/ht1451

  • Loading data from external system

    Hi,
    Im really having a hard time trying to load data with a DM package... im using  BPC 75 MS SP04, im trying to obtain data from a SAP ERP system... once obtaining it, I have 2 options:
    - Create a conversion file  in order to "unify" the master data from ERP to mine. Since i still dont understand how this works, i think that will imply writing a file with over 500 rows of data  (one for every converted member)... this is
    ACCOUNTS:
    SAP          -     BPC
    CUENTA10 - 4040
    CUENTA11 - 4041
    .....  and so on....
    - Or get that info converted to my syntax (ready for BPC),  and place it directly in the DB (sql server 2005)
    In either case, how can I do this?
    Thanx in advance.
    Velázquez

    Hi,
    This can be simplified using the java script. Conversion file supports java script. Please take a look at few examples in the below link from help.sap:
    http://help.sap.com/saphelp_bpc75_nw/helpdata/en/81/94a8a5febd40268d5c59b4fc31be37/content.htm
    Hope this helps.

  • Firefox not loading pages from external links

    When I get an email with a link, and ask Android to open it, the browser opens and appears to be loading. But only a blank page is there. If I then close the browser and reopen it, I see the page.
    Help appreciated.

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    The Firefox cache temporarily stores images, scripts, and other parts of websites while you are browsing. <br>
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies, do the following:
    #Tap the menu icon located at the top right corner. This is the icon with 3 bars. On older Android devices you'll have to press the hardware menu key and then tap More.
    #Tap '''Settings'''.
    #After that, you will be taken to the settings screen. In the settings screen, look under the section '''''Privacy & Security''''' and select '''Clear private data'''.
    #You will then be taken to a list of what can be cleared. Select the following 2 for deletion:
    #*Cookies & active logins
    #*Cache
    #After those have been selected, tap the '''Clear data''' button to actually clear the cache and cookies.
    Did this help you with your problems? Please let us know!

  • Loading Entourage from External HD

    My HD died and I have a clone of that HD on an external firewire drive.
    I was wondering if it would be possible to load my entourage calender without reloading the HD clone onto the HD in my powerbook (because i don't have my PB).
    I have access to another mac, or pc.
    Thanks.

    You need to let GB index them. Drop any folders of loops you have on the loop browser and let GB index them (don't have it Copy the files ... it will ask)

  • A problem with loading xml from external URl in flex

    So I have a server running (localhost) and I wrote an  application to request information from another website and return data  (xml). The application worked fine when I was using the flash builder  and just testing it on my machine (not using the localhost), when I  started using the server with the same exact code, it requested the  crossdomain.xml file to assure that I can request information from that  site, so I added the file and the file is right, the script gets it  (according to firebug), however, it is not getting the xml information  it should get, it just gets stuck with (waiting information from  blah.com) at the bottom.
    Is there a way to solve the problem?
    (I turned my firewall off and it didn't work either)

    Yeah I did test the URL and everything is going fine, the information is not returned to the flex application that's all.
    I am testing with FireBug and it is telling me that the request is in fact sent to the site but I don't think anything (either than the crossdomain function) is returned.
    Thanks for the help, I am really not sure what is going on.

  • Best way to load data from External data to ADC

    Hi Guy,
    I am new in BAM. I currently working for a existing system that have all it data in existing system, which i only have the view access to the database/table.
    so i just wonder, what is the best way to load the data so that it can populate to the active data cache?
    thanks.

    Hello,
    Use the EDS.For reference http://docs.oracle.com/cd/E14571_01/integration.1111/e10224/bam_extl_data_sources.htm
    Regards
    Siva Sankar

  • How do you load music from external hard drive

    I hvae tried everything the support page says but it is not working

    What exactly are you trying to do?

  • Load multiple external images

    If you load say 3 external images in AS3 and want to run a function "useImages()" only once all three images have loaded what is the best way of listening for them to complete loading.
    EG;
    loader1.addEventListener(Eveent.COMPLETE, incLoader)
    loader2.addEventListener(Eveent.COMPLETE, incLoader)
    loader2.addEventListener(Eveent.COMPLETE, incLoader)
    function incLoader(event:Event)
         numLoaded ++
         if (numLoaded == 3)
                   useImages()
    There must be a better way than the above.
    Any feedback would be much appreciated
    Thanks

    Here's a set of functions I used to load pages into a flip page magazine app.  They keep track of how many pages are supposed to load and how many actually load.  I also used an XML file that the web people can update so that it loads different images.  You can add the loader objects in the loaders Array into any DisplayObjectContainer:
    var pageCount:int = 3;
    var pagesLoaded:int = 0;
    var loaders:Array = new Array;
    public function loadPage(aPage:String):void
      var pictLdr:Loader = new Loader();
      var pictURLReq:URLRequest = new URLRequest(aPage);
      pictLdr.load(pictURLReq);
      pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
      pictLdr.addEventListener(IOErrorEvent.IO_ERROR, pictErrorHandler);
      loaders.push(pictLdr);
      updateLoadText();
    private function imgLoaded(event:Event):void
      pagesLoaded++;
      addPagesToFlipBook();
    private function pictErrorHandler(event:IOErrorEvent):void
      var ldrInfo:LoaderInfo = LoaderInfo(event.target);
      loaders.splice(loaders.indexOf(ldrInfo.loader), 1);
      pageCount--;
      addPagesToFlipBook();
    private function updateLoadText():void
      errorText.text = "Loading image " + (pagesLoaded + 1) + " of " + pageCount + "..."
    private function addPagesToFlipBook():void
      updateLoadText();
      if (pagesLoaded == pageCount)
        ... do more stuff
    *edit* How do I create a code window for code?

Maybe you are looking for