Converting bitmap to sprite for animation

/*the point of this is to add a keyboardEvent to animate the image*/
I am loading a bitmap image using this function:
var myLoader : Loader = new Loader();
var myURLRequest : URLRequest = new URLRequest("thesus.png");
myLoader.load(myURLRequest);
function myOnComplete(event : Event) : Bitmap
var loader : Loader = Loader(event.target.loader);
var image : Bitmap = Bitmap(loader.content)
stage.addChild(image);
return image;
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myOnComplete);
then I am converting it to a sprite using this function:
function bitmapToSprite(image:Bitmap, smoothing:Boolean = false):Sprite
   var sprite:Sprite = new Sprite();
   sprite.addChild( new Bitmap(image.bitmapData.clone(), "auto", smoothing) );
   return sprite;
but I am unable to pass it to this sprite variable:
var thesus : Sprite = bitmapToSprite;
Any help would be greatly appreciated :-)

Thank you for your help Joporo,
I was trying to return a bitmap from an eventHandler, which cannot return anything I now know.
I ended up getting it to work like so:
var myLoader : Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myOnComplete);
var myURLRequest : URLRequest = new URLRequest("thesus.png");
myLoader.load(myURLRequest);
var image:Bitmap;
var thesus:Sprite;
function myOnComplete(event : Event) : void
var loader : Loader = Loader(event.target.loader);
image = Bitmap(loader.content)
thesus = (bitmapToSprite(image));
stage.addChild(thesus);
thesus.x = 90;
thesus.y = 165;
along with the bitmapToSprite method it added the image to the stage as a sprite

Similar Messages

  • Best method for animated bitmap sprites with GPU?

    I've been looking at how GPU Hardware Acceleration is achieved with cacheAsBitmap and cacheAsBitmapMatrix which I understand for static bitmap sprites (+rotation/scale) but I don't quite understand how this would be used to animate a sprite that had different animation frames.. in terms of what is done by the GPU and what is done by the CPU
    eg potential scenarios:
    1) cache sprite sheets to GPU. use copyPixels to blit the various sprites to a single canvas. In this case presumably the canvas would not be GPU accelerated because it is constantly changing every frame. Is there in fact any benefit of having the sprite sheet cached here? is the GPU actually used for the blit onto the CPU-rendered canvas?
    2) cache individual sprite bitmap(data) frames on the GPU. use object pooling for game character sprites and add them to stage on startup. Change the bitmap every frame dynamically,  for animated sprites, to one of the cached bitmapdata textures. is the GPU actually being used in this case to change the bitmap of the sprite? or is it forced to CPU processing again?
    The only scenario I currently know should be GPU accelerated is if I use a cached sprite that doesn't animate (other than rotating and scaling with the bitmap matrix).
    thanks for any advice
    J

    J, I believe (2) is how it is currently done. A better method is required! - basically the same question I have that you are helping me with . That link to 'Yeah, but is it Flash' in my post shows an example of exactly that method (individual BitmapData for each frame).
    Just for completeness I will add the one from my post (though unsure if it is even possible):
    (3) Single BitmapData sprite sheet cached to GPU. Each Bitmap that uses this sprite sheet can somehow specify the x,y,width,height of the frame within this sprite sheet to use.

  • PSD source file for animated GIF's - Fireworks CS3

    hi
    i've upgraded to Web Premium Suite CS3.
    Q: i have several PSD source file for animated GIF's created
    with ImageReday.
    how can i open/iomport/convert it in/to Fireworks CS3 without
    looing the "animation"
    many thanks
    Ueli

    ugisiger wrote:
    > hi
    > no any extras. simply 5 layers "distributed" on the
    timeline.
    > if i open a "animated" psd, so i get a file with the
    layers and one frame, but
    > loosing animation stuff like "when show witch layer an
    for how long"
    > -> there is no conversion to FW frames.
    >
    > Ueli
    >
    I don't do animations in PS or IR, but if you like, send me
    the file
    and I'll see if I can figure something out.
    Jim Babbage - .:Community MX:. & .:Adobe Community
    Expert:.
    Extending Knowledge, Daily
    http://www.communityMX.com/
    CommunityMX - Free Resources:
    http://www.communitymx.com/free.cfm
    .:Adobe Community Expert for Fireworks:.
    news://forums.macromedia.com/macromedia.fireworks
    news://forums.macromedia.com/macromedia.dreamweaver

  • CS6 Sprite Sheet animation alignment puzzle

    Hey all, I greatly enjoy using Flash CS6's Generate Sprite Sheet tool since it's much much quicker than exporting all the sprites and using TexturePacker (though I wager TP would provide far better optimization). One problem I seem to have is aligning different animations to the same origin - which isn't the origin of the sprite (top left corner).
    Say my character Jim has two animations:
    Run (small sprites, as he runs in place)
    Jump (short and tall sprites, and a bit wider than the Run)
    I currently generate a sprite sheet by highlighting both clips and right clicking. This gets me a perfect Sprite Sheet with both animations and their respective names (based on MC name). The Run and Jump frame sizes are different, because the Jump sprites are taller than the Run sprites -- this all makes sense.
    What doesn't is that there's zero information on how those two animations should be placed such that Jim can go from playing his run animation and then his jump animation with his feet in the same place, despite the fact that if you inspect either of those clips Jim is standing right at Flash's little origin point at the start of both.
    Sure, the data file (JSON in my case) has all the offsets for placing the individual frames in the right place, but how do I align Jim's feet from one set of frames to the next without having to do it all by hand? To date the only workaround I've found is to dump all the animations into a single timeline such that they all take the same frame size, but this is TERRIBLE for managing sprites and animations since it gives all the frames the same name as the combined timeline.
    What I really need is another set of numbers in the Sprite Sheet data file that tells me the frame x & y offset from Flash's movieclip origin. I have a suspicion this doesn't exist and is impossible.
    At a loss here other than aligning each animation's frame by hand, which may have to be done every time an interal sprite changes size.
    Thanks for any insight, none of the Adobe pages or demos go into any depth other than creating a sprite sheet of a single image or animation.

    Yes, I understand how to make animations blend together, but my question relates to the technical side of how sprite sheets are generated.
    When I generate a sprite sheet from multiple animation movieclips each animation has a unique frame size that Flash calculates and codes into the data file, and that frame size is not the size of document but the size of the smallest frame that can fit all of the sprites in the animation. I can't control this frame size or define a region within the document that is the frame size. Each animation within the sprite sheet could have a different frame size.
    I'm interested to know if there is a way to view, generate, or export the data that would relate one animation frame to another so that a character (Jim) could be standing at the movieclip origin in the Run animation which is size A and also be standing at the movieclip origin in the Jump animation which is size B, and not only are A and B different sized frames, but none of the corners are coincident. Since it doesn't do this currently I'd have to manually code the offsets of each animation to a common origin instead of being able to use the one that's already in Flash.
    I don't see how any of the default data that is exported along with the spritesheet PNG could relate that info and I'm very curious.
    (I could do it by putting every animation within the same movieclip, but then the spritesheet tool is pretty useless since it'd all be one animation)

  • Converting Bitmap to SVG with Illustrator

    Hi,
    Totally new to use Illustrator. Would be nice if I can do the folowing with Illustrator Cs4.
    I downloded trail verion (have no money really -).
    I would like to convert bitmap to svg tiny for mobile device. It looks if I save it as SVG tiny it can do it. But problem is with transparency.
    Let's say I have a circle image  in bitmap and if I save it as svg and use it in mobile application then the 4 corners are visible as square (as seen as white in my case). Any idea how can I make it transparent?
    br,
    Mahbub

    Mahbub,
    This is what a Helpfile (old one) says about the SVG format in a format comparison:
    Traditional image formats--GIF, JPEG, and PNG--are bitmap formats that describe  images, using a grid of pixels. The resulting files tend to be bulky, limited to  a single (often low) resolution, and consume large amounts of bandwidth on the  Web. SVG, or Scalable Vector Graphics, on the other hand, is a vector format  that describes images as shapes, paths, text, and filter effects. The resulting  files are compact and provide high-quality graphics on the Web, in print, and  even on resource-constrained, handheld devices. Users can magnify their view of  an SVG image on-screen without sacrificing sharpness, detail, or clarity. In  addition, SVG provides superior support for text and colors, which ensures that  users will see images as they appear on your Illustrator artboard.
    Illy, like SVG, is basically about vector, not raster/bitmap.
    All this means that you need vector artwork in order to enable scaling, which you may not need.
    But the corner issue seems to be related to bitmap images basically being rectangular. Some bitmap formats, such as PNG and GIF can have transparent parts, such as the areas forming the outside parts that should be invisible, such as  corner parts at roundings. You may seemingly cut parts of bitmap image shapes in Illy (by making parts transparent), using Clipping Masks; there may be easier ways in CS4. Some may suggest your using Photoshop for such tasks.

  • Sprite Sheet Animation started by Mouse Click

    I have a animated fire sprite. It is set to hidden, another button is set to "show" this sprite when it's clicked.
    Problem is that the animation runs while hidden so when you click the button that reveals the sprite, the animation cycle may be complete. It's set to loop but I would like the sprite to start on frame 1 and begin play once you click the button, not autoplay.
    Any ideas how to do this?

    You can uncheck(i.e. disable) the Autoplay for the spritesheet symbol from the property panel (which you will see when you select the stage of the symbol in the symbol editing mode).
    hth,
    Vivekuma

  • Is there support for animated .gif files?

    Is there support for animated gif files using
    form builder? I can't get it to work.
    Thanks
    Sean
    I am using forms 6.0

    She used the Link Tool, specfied 'Image URL' as the Source File Format and the url of the animated GIF in the Source Filename. Hope that helps.
    Makes sense but the form is not for the web.
    I have looked at doing it with timers and switching canvases, but that is just too much
    for sloppy animation. It's just not tight enough.
    Thanks,
    Sean
    null

  • Set frame delay time for animated gif using ImageIO

    I'm trying to change the delay time of each frame for an animated gif by changing the metadata for each frame as following but it doesn't change anything.
    static private IIOMetadata setMetadata(IIOMetadata metadata, int delayMS) throws IOException
              Node root = metadata.getAsTree("javax_imageio_gif_image_1.0");
              for (Node c = root.getFirstChild(); c != null; c = c.getNextSibling())
                   String name = c.getNodeName();
                   if (c instanceof IIOMetadataNode)
                        IIOMetadataNode metaNode = (IIOMetadataNode) c;
                        if ("GraphicControlExtension".equals(name))
                             metaNode.setAttribute("delayTime", Integer.toString(delayMS));
         }Does anyone know how to set delay time for animated gif using ImageIO ?

    I'm trying to change the delay time of each frame for an animated gif by changing the metadata for each frame as following but it doesn't change anything.
    static private IIOMetadata setMetadata(IIOMetadata metadata, int delayMS) throws IOException
              Node root = metadata.getAsTree("javax_imageio_gif_image_1.0");
              for (Node c = root.getFirstChild(); c != null; c = c.getNextSibling())
                   String name = c.getNodeName();
                   if (c instanceof IIOMetadataNode)
                        IIOMetadataNode metaNode = (IIOMetadataNode) c;
                        if ("GraphicControlExtension".equals(name))
                             metaNode.setAttribute("delayTime", Integer.toString(delayMS));
         }Does anyone know how to set delay time for animated gif using ImageIO ?

  • I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    You can't.

  • How can I convert an .m1v file for my MacBook to be able to play it?

    Hi!
    How can I convert an .m1v file for my MacBook to be able to play it?
    I tried numerous apps from the app store, but they failed
    Thanks!

    Hello:
    Rather than try to buy a box, I suggest you take the computer to a FedEx or UPS store.  They will wrap and safely package the device for a reasonable cost (I have shipped two iMacs this way).
    Barry

  • Converting Images to CMYK for Print Publication

    When in my workflow should I be converting images to CMYK for print publication?
    Currently, I shoot RAW photographs with my DSLR in Adobe RGB, import the images into Photoshop for manipulation and then convert the final, sized image to CMYK before placing it in my Indesign document. Before going to print, I convert my files to PDF using the [PDF/X-1a:2001] preset. I use a calibrated system with a profile set for my monitor.
    Since many of my pictures have shades of green, I'm often disappointed with the conversion to CMYK because I lose saturation and brightness. Am I doing anything wrong? Is there a better way of preserving the quality of colour in my images when going to a commercial printer?

    To see in InDesign what color shifts will occur, use View=>Proof Colors.
    I would also recommend View=>Overprint Preview.
    Yes there are color shifts when converting RGB to CMYK, but those are due to the fact that the gamut of CMYK is significantly less than AdobeRGB or even sRGB. The same color shifts going to CMYK will occur whether you convert the image in Photoshop or in InDesign during PDF export or at the RIP.
    Keeping the color in ICC color managed RGB has the advantage that last minute changes can be made as to what CMYK printing conditions are used, i.e. all CMYK is not the same. Furthermore, if you convert RGB to CMYK early in the workflow, you lose the ability to maintain the color gamut for display of the PDF as well as for printing to high fidelity color devices, i.e., offset or digital (especially inkjet) devices that have extra colorants such as light cyan, light magenta, orange, and/or green to dramatically expand the gamut. Once you lose the gamut in your imagery via conversion to CMYK, you can't go back.
              - Dov

  • Advantages of using Final Cut Pro for animation

    Is there anyone out there using Final Cut Pro 6 that could tell me what they feel are the advantages of using FCP 6 for animation as compared to Final Cut Express 3.5?

    Okay, cool. I was gonna use that in the first place but I'm still learning it and so far all I know how to do on it is clean up the audio. I'm going through a Soundtrack Pro book right now and had to stop because I couldn't continue without a microphone. I'm getting that microphone this week and by the time I have the next batch of audio files to edit I'll know what I'm doing in Soundtrack Pro.
    Thanks for the suggestion, I was seriously coming back to this question to elaborate for the sake of bumping this.
    Oh yeah, if Soundtrack Pro is the answer, is it possible to bypass FCP on the way in AND on the way out?
    Message was edited by: Etchie

  • I have hundreds of the same shape that needs to be converted into a symbol for easy editing. Is ther

    I have hundreds of the same shape that needs to be converted into a symbol for easy editing. Is there a way to do this in Illustrator?
    Background here may be relevant: The place I am working is currently using ai CS 3 & 5 and the files in question are converted Freehand files. I have never been a Freehand user, but apparently you were able to swap one shape for another in Freehand. The closest Illustrator equivalent that I am aware of is the symbols panel. I know how to swap one symbol for another, how to create a symbol from a piece of vector art and how to modify a symbol. What I am trying to do is convert several instances of the same object into several instances of the same symbol without having to replace hundreds of objects manually (ie. trying to get the right placement in a grid and everything).
    Is there any efficient solution to the task I have in Illustrator CS 3 or CS 5?

    Try this.
    http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena?redirect=1
    http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena_size?redirect=1

  • Convert spool to pdf for Chinese characters

    Hi,
       I need to convert spool to pdf for chinese font.
       Spool is creating successfully, and contents are displaying properly. When try to convert the spool to pdf using 'RSTXPDFT4', the pdf is generated successfully, when trying open the pdf, contents are missing, its like empy white pdf page. This is happening for the Chinese font. The same script is working fine for the English font.
    Plz suggets
    Thanks
    Balaji

    Hi Balaji,
    I am having a similar issue with Simplified Chinese, Traditional Chinese, and Thai fonts when saving spools to PDF.  Have you found any more information on why the output shows up as a blank screen?
    We are printing Purchase Orders and the T&Cs are coming through fine because they are saved as picture files but the smartform does not display at all.
    Any information would be appreciated!
    Thanks,
    Josh

  • Hello, what is the best way for me to convert RW2 raw format for use in Photoshop CC

    Hello, what is the best way for me to convert RW2 raw format for use in Photoshop CC. I would appreciate any help with this.

    Thanks for the quick help. I do have to leave for work. When I try to
    download the images from the camera they seem to only be in jpeg (I don't
    see any rw2 or raw files to download). If I select the jpeg file it seems
    to only download a jpeg file. I do understand that I do have the option to
    open the jpeg in RAW. In doing this, is all the extra information included
    in the RAW file there or is it lost coming from the camera
    Once again thank you for trying to make me understand how this works.
    Have a great day.
    On Sat, Sep 13, 2014 at 12:14 PM, ssprengel <[email protected]>

Maybe you are looking for

  • Deleted importain things on disk.. trouble powering up.. HELP?

    HI i have a15 inch powerbook and my disk was getting full so i started to delte items i though where uneeded.. turns out i deleted stuff in the system folder that were importain now it just keeps trying to power up then shutss its self down and keeps

  • Is it possible to send a bookmark from one iphone to another?

    I want to share a bookmark, not just the URL.. Is it possible to send it like a "bookmark file" in a mail or text? And is it possible to save it as a "add-to-home-screen", where the bookmark when saved from mail goes directly to the recievers home sc

  • Date not showed when report is viewed in PDF .

    Hi, We have a text field that shows the date on which the report is running.Date is not showed when report is viewed in PDF.But in HTML we can view them . Can any one help me out? Totally there are four pages for the report.

  • Mac Mail do not read/show emails prior Lion update

    Hi! I have faced the same problems as many others with Mac Mail (on my iMac), ie. could not launch Mail after update. Solved that problem with deleting some plist-files and everything looked good. However, Mail can not read/show/find emails prior the

  • Formatting error in the field COBL-GSBER - FF_5 Upload

    Hi Experts, When I upload the bank statement in FF_5, I am getting the following error. "Error: (00 298) Formatting error in the field COBL-GSBER ; see next message" If I make the field "Businees Area" Optional in Field Status Group of the "Bank Main