Animate an image

I have a read a few ways to animate an image in AS3 and not sure what is the most efficient way.
I  want to load 4 images(in 4 files) in a class. Each image is a different  frame of a walking movement of a character. What I want to do is load  all the images in the constructor and assign the sprite the current  frame to display.
eg sprite=bitmap1  then after some time swap images so
sprite=bitmap2  then after some time swap images so etc
sprite=bitmap3....
Is this the logic you do in AS3?
The code loads 1 image so I can change this to 4 images to load (4 bitmaps and 1 sprite for the current frame?)
private  var sp:Sprite=new Sprite();
          public function ClassImg2(myimg:String,xx:int,yy:int)     {
          img1=myimg;
               myx=xx;
               myy=yy;
          var loader:Loader = new Loader;
          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
          loader.load(new URLRequest(img1));
          private function imageLoaded(event:Event):void
           var image:Bitmap = new Bitmap(event.target.content.bitmapData);
             sp.addChild(image);
             sp.x = myx;
             sp.y = myy;
             addChild(sp);

HI have spent ages on this and snippets of code isnt clarifying this for me.
I want to load images into BItmapData and display one of those to the screen Bitmap. To animate I want to swap images every so often
I need to know
1)I dont know how to load an image into a bitmapData object
2) I need to assign the bitmapData to a bitmpa so I can display it
3) I will need to perform keyevents/mouse events on the image display on screen so the bitmap  must be converted to a sprite somehow.
IT would help me the most if someone was to look at my code and I will try to find some AS3 animation tutorials complete examples (NOT EASY!)
private   var img1:Bitmap;
          private   var bmp:BitmapData;
            private var MyImages:Array = [];
            var urls:Array = ["scave4.png", "scave5.png", "scave6.png", "scave7.png"];
          public function ClassImg3()     {
          imgStr="scave4.png";
               for each (var el:String in urls) {
                    var loader:Loader = new Loader;
                    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
                    loader.load(new URLRequest(el));
          private function imageLoaded(event:Event):void
          // var image:Bitmap = new Bitmap(event.target.content.bitmapData);
          // img1= new Bitmap(event.target.content.bitmapData);
            var bmd:BitmapData = event.target.loader.content.bitmapData;
          // bmp=new BitmapData(event.target.content.bitmapData);
            MyImages.push(bmd);
          img1.bitmapData = bmd;
          addChild(img1);
          img1.x =30;
          img1.y=100;
            // sp.addChild(image);
             //sp.x = myx;
            // sp.y = myy;
             //addChild(sp);
             dispatchEvent(new Event("image_loaded"));
          public function moveChar()
               img1.x+=1
               if (img1.x>400)
                    img1.x=10;

Similar Messages

  • I am trying to import scanned illustrations into Final Cut Pro (6) as layered photoshop images, however when I try and animate the image is blurred.....please help!

    I am trying to import scanned illustrations into Final Cut Pro (6) as layered photoshop images, however when I try and animate the image is blurred.....please help! Will I need to create the photoshop files as a certain size/resolution? I am working to 4:3.....

    You should take your question to the Final Cut Studio forum. This is FCPX.

  • Adobe Edge Animate CC image loading bug

    hello,
    The animation which i created in Adobe Edge Animate which is published for web, and when i load the main file in browser noticed that the images which i used inside the Edge Animate for animations are loading two times one with "edge.3.0.0.min.js:240"  and  "jquery-2.0.3.min.js:5",  i hope this is a bug.  how can i a avoided this multiple loading of same image files.

    Hi, canpark-
    We do not have a Korean localized version of Edge Animate, sorry!
    -Elaine

  • How to animate still images

    I'm trying to figure out how to use still images to create an animated video - similar to:
    http://www.pbs.org/wgbh/amex/oakley/promo/promo_qt_oakley.html
    Any help would be much appreciated -

    Use tables for putting graphics together to reduce the size of a gif animation.  Depending on what your animation is like, tables can help reduce its overall  file size. For example, you may have an image you want to animate, but only a  small part of the image will actually be the animation. You can manually cut up  the image into different pieces using a program like photoshop, or  automatically, using a special utility like Ulead SmartSaver Pro. If you use  photoshop, you must put the resulting graphics back together in your html editor  using table cells. Programs like SmartSaver creat the html file with the  graphics already in the table cells. By slicing up your image into sections, the  samll part of the image that animates will now be in a table cell by itself. The  rest of the image in the other table cells does not become part of tthe actual  animation itself, thus reducing file size.

  • How can i animate .jpg image?

    hi
    how can i animate images which i edit in GIMP?
    i mean, i have 1 video clip showing a tree. and then i have 1 .jpg image of an airplane
    how can i make that airplane from jpg image to appear in the video showing the tree? i want to make that airplane crash into the tree and explode.
    i see a lot of similar stuff on youtube (like "cyriak animation mix")  but i don't know what this technique is called. animation of still images? google search gave me lots of dubious results, none of them came straight to the point.
    all i know it involves some manipulation of keyframes but i need to know more keywords to further research this technique. or better yet - find a decent article explaining basics.
    can somebody help?

    First, you will probably want to Key out the background around the plane. Look into Chorma Key, or one of the other Keying Effects in PrE, depending on how the plane was shot, or created. If you created it, you can probably Mask out any background, and Save_As a format, that support Transparency, such as with an Alpha Channel Mask.
    Then, with the plane on a higher Video Track, than your tree, use the Fixed Effect>Motion>Position to Keyframe the Position of the plane, moving it across the Frame. Steve Grisetti has a great Learning Series on Basic Keyframing and Advanced Keyframing, available at Muvipix.com: http://www.muvipix.com/products.php?searchphrase=Basic+Keyframing&btn.x=-1091&btn.y=-78
    Good luck,
    Hunt

  • Animate 2 images on the click of a button

    I'm working on a script to display a short animation once the user has clicked a button; however I currently have the following error;
    Cannot find method; animateTransform()
    All I need is for plate1 to move South East whilst plate2 is moving North West for only a matter of seconds.
    I've never worked with animation in Java so apologies in advance for the state of the code shown below;
    import java.net.URISyntaxException;
    import java.net.URL;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.ImageIO;
    public class TransformFault2 implements ActionListener
        private static final String IMAGE_PATH = "img/transform_screen.gif";
         private static final String plate1_IMAGE_PATH = "img/transform_plate1.gif";
         private static final String plate2_IMAGE_PATH = "img/transform_plate2.gif";
         private ImageIcon animateBtn, boundsBtn;
         private JButton animateOption, boundsOption;
         private int x_1 = 225; // horiz
         private int y_1 = 265; // vert
         private int x_2 = 290;
         private int y_2 = 165;
         private boolean transformFault = false;
         private Timer timer;
         private ActionListener timerListener;
        private BufferedImage myImage = null;
         private BufferedImage plate1 = null;
         private BufferedImage plate2 = null;
        private JPanel imagePanel = new JPanel(null)
            protected void paintComponent(Graphics g)
                super.paintComponent(g);
                if (myImage != null)
                    g.drawImage(myImage, 0, 0, this);
                   if (plate1 != null)
                    g.drawImage(plate1, x_1, y_1, this);
                   if (plate2 != null)
                    g.drawImage(plate2, x_2, y_2, this);
              public void animateTransform()
                        do
                             x_1 = +1;
                             y_1 = +1;
                             x_2 = -1;
                             y_2 = -1;
                        while (transformFault = true);
                   repaint();     
                   try
                        Thread.sleep(4000);
                   catch (InterruptedException e)
        public TransformFault2()
              timerListener = new ActionListener()
               public void actionPerformed(ActionEvent actionEvent)
                        transformFault = false;
                        timer.stop();
              timer = new Timer(4000, timerListener);
              timer.setRepeats(false);
              animateBtn = new ImageIcon(getClass().getResource("img/animate.gif"));
              animateOption = new JButton(animateBtn);
              animateOption.setBorder(null);
              animateOption.setContentAreaFilled(false);
              animateOption.setSize(164,66);
              animateOption.setLocation(500,500);
              animateOption.setOpaque(false);
              animateOption.addActionListener(this);
              animateOption.setActionCommand("animate");
              boundsBtn = new ImageIcon(getClass().getResource("img/boundaries.gif"));
              boundsOption = new JButton(boundsBtn);
              boundsOption.setBorder(null);
              boundsOption.setContentAreaFilled(false);
              boundsOption.setSize(164,66);
              boundsOption.setLocation(200,500);
              boundsOption.setOpaque(false);
              boundsOption.addActionListener(this);
              boundsOption.setActionCommand("boundaries");
            imagePanel.setPreferredSize(new Dimension(800, 600));
            imagePanel.add(animateOption);
              imagePanel.add(boundsOption);
              imagePanel.setBackground(Color.WHITE);
            try
                myImage = createImage(IMAGE_PATH);
            catch (IOException e)
                e.printStackTrace();
            catch (URISyntaxException e)
                e.printStackTrace();
              try
                plate1 = createImage(plate1_IMAGE_PATH);
            catch (IOException e)
                e.printStackTrace();
            catch (URISyntaxException e)
                e.printStackTrace();
              try
                plate2 = createImage(plate2_IMAGE_PATH);
            catch (IOException e)
                e.printStackTrace();
            catch (URISyntaxException e)
                e.printStackTrace();
         public void actionPerformed(ActionEvent e)
          if(e.getActionCommand().equals("animate")) 
                   timer.start();
                   animateTransform();
         else if(e.getActionCommand().equals("boundaries")) 
             WOT2.contentCardLayout.show(WOT2.contentCard, "Boundaries Screen");
        private BufferedImage createImage(String path) throws IOException,
                URISyntaxException
            URL imageURL = getClass().getResource(path);
            if (imageURL != null)
                return ImageIO.read(new File(imageURL.toURI()));
            else
                return null;
        public JPanel getImagePanel()
            return imagePanel;
    }Any help would be much appreciated!

    When using JLabel to place the images I receive no errors when compiling or in the console upon execution; however the images do not appear on-screen.
    When the animate button is clicked nothing happens but Java is crashing, so I assume there must be a problem with the loop?
    Amended code can be seen below;
    public class TransformFault implements ActionListener
        private static final String IMAGE_PATH = "img/transform_screen.gif";
         private ImageIcon animateBtn, boundsBtn, plate1img, plate2img;
         private JButton animateOption, boundsOption;
         private JLabel plate1, plate2;
         private int x_1 = 225; // horiz
         private int y_1 = 265; // vert
         private int x_2 = 290;
         private int y_2 = 165;
         private boolean transformFault = true;
         private Timer timer;
         private ActionListener timerListener;
        private BufferedImage myImage = null;
        private JPanel imagePanel = new JPanel(null)
            protected void paintComponent(Graphics g)
                super.paintComponent(g);
                if (myImage != null)
                    g.drawImage(myImage, 0, 0, this);
        public TransformFault()
              timerListener = new ActionListener()
               public void actionPerformed(ActionEvent actionEvent)
                        transformFault = false;
                        timer.stop();
              timer = new Timer(4000, timerListener);
              timer.setRepeats(false);
              animateBtn = new ImageIcon(getClass().getResource("img/animate.gif"));
              animateOption = new JButton(animateBtn);
              animateOption.setBorder(null);
              animateOption.setContentAreaFilled(false);
              animateOption.setSize(164,66);
              animateOption.setLocation(500,500);
              animateOption.addActionListener(this);
              animateOption.setActionCommand("animate");
              boundsBtn = new ImageIcon(getClass().getResource("img/boundaries.gif"));
              boundsOption = new JButton(boundsBtn);
              boundsOption.setBorder(null);
              boundsOption.setContentAreaFilled(false);
              boundsOption.setSize(164,66);
              boundsOption.setLocation(200,500);
              boundsOption.addActionListener(this);
              boundsOption.setActionCommand("boundaries");
              plate1img = new ImageIcon(getClass().getResource("img/transform_plate1.gif"));
              plate1 = new JLabel(plate1img);
              plate1.setBorder(null);
              plate1.setOpaque(false);
              plate1.setLocation(x_1, y_1);
              plate2img = new ImageIcon(getClass().getResource("img/transform_plate2.gif"));
              plate2 = new JLabel(plate2img);
              plate2.setBorder(null);
              plate2.setOpaque(false);
              plate2.setLocation(x_2, y_2);
            imagePanel.setPreferredSize(new Dimension(800, 600));
            imagePanel.add(animateOption);
              imagePanel.add(boundsOption);
              imagePanel.add(plate1);
              imagePanel.add(plate2);
              imagePanel.setBackground(Color.WHITE);
            try
                myImage = createImage(IMAGE_PATH);
            catch (IOException e)
                e.printStackTrace();
            catch (URISyntaxException e)
                e.printStackTrace();
         public void actionPerformed(ActionEvent e)
          if(e.getActionCommand().equals("animate")) 
                   timer.start();
                   animateTransform();
         else if(e.getActionCommand().equals("boundaries")) 
             WOT2.contentCardLayout.show(WOT2.contentCard, "Boundaries Screen");
        private BufferedImage createImage(String path) throws IOException,
                URISyntaxException
            URL imageURL = getClass().getResource(path);
            if (imageURL != null)
                return ImageIO.read(new File(imageURL.toURI()));
            else
                return null;
        public JPanel getImagePanel()
            return imagePanel;
         public void animateTransform()
                   do
                             x_1 = +1;
                             y_1 = +1;
                             x_2 = -1;
                             y_2 = -1;
                   while (transformFault = true);
                   imagePanel.repaint();     
                   try
                        Thread.sleep(4000);
                   catch (InterruptedException e)
    }

  • How to animate imported images?

    Hi, I'm new to Premiere. I've imported a PSD file with full alpha transparency. It shows a mobile phone being held, as if from a first-person perspective and is being used in a scene that is filmed in first-person.
    On the phone, I want the screen's image to change, perhaps at certain specified keyframes. I know for an animated image I could import a GIF, but that format does not support alpha.
    In short, how can I make an imported image - that's used in Video 2 on top of Video 1 - change itself to an image of the exact same resolution at specified times?

    Change the image on the phone in Photoshop instead. Ohotoshop Extended has a timeline, or you could just import multiple copies of the phone image into Premiere Pro and use them as you need them.

  • How to animate from a png tile based image file

    Hi all,
    I would like to know is there any way to animate from a tile based .png image file? I have multiple images in 1 png file having slight changes in each image, which if cropped and put into layers one over the other, will give the feel of animation or a character moving or walking etc...
    I want to know can we do that kind of animation in flash as we do it in C++ or Java and how can we do it.
    Any help will be highly appreciated.
    Thank you
    Shanz - Iceheros

    I want to use action script to externally call/access  the png file with url request and url loader and animate the images from the tile based png image file.
    Anybody know how to do this in flash with as3.
    Here is the image for example:
    i want to animate this images and call it externally and access each tile 1 after another.
    Any Help???
    Thanks,
    Shanz - Iceheros

  • Firefox 4.0: Improper handling of Animated Gif background-image

    FF 4.0 is giving erratic and incorrect displays of an animated gif on a project I am working on. I have prepared a very small sample that demonstrates the problem.
    The problem occurs when an animated gif is used as the background-image for a div (it may also be true when used as a background-image for the body, but I have not tested that).
    When a page is first loaded, the animated gif displays properly.
    I would expect that the animation be displayed as animated either:
    # On each page load
    # On a page load with new session or when the image is removed from cache prior to loading the page. Otherwise the last frame of the image would show
    The sample page is designed to test this.
    IE: Behaved as in #1, i.e. the image was animated on each and every page load. (IE 8: 8.0.6001....)
    Google Chrome: Behaved as in #2, i.e. the image is animated only when there is a new session or when the image is no longer in cache. (Version 10.0.648.204)
    FF 3.6.8: Slightly strange, but acceptable.
    * The image is animated on new session and on any reload button.
    * The last frame is displayed if the location is reentered in the URL bar.
    * The last frame is displayed if the back/forward navigation buttons are used.
    * SOMETIMES the image is animated and sometimes the last frame is displayed when the change page button is pressed (i.e. Javascript change page).
    FF 4.0: Just plain NOT acceptable
    * Correctly animates the image on page load for new session
    * Correctly animates the image on reload button following clearing the image from cache.
    * INCORRECTLY shows the FIRST gif frame if the reload button is pressed.
    * INCORRECTLY shows the FIRST gif frame if the URL is reentered from the URL bar.
    * INCORRECTLY shows the FIRST gif frame if the page change button is pressed (i.e. Javascript change page).
    * INCORRECTLY shows the FIRST gif frame if theURL is reentered from the URL bar after clearing the image from cache.
    * INCORRECTLY shows the FIRST gif frame if the page change button is pressed (i.e. Javascript change page) after clearing the item from cache.
    All of these tests were run with Windows XP-Pro (all service packs and updates applied).
    I can find no clear specification as to what ''should'' happen with pages using animated gifs that are already loaded.
    * I can conceive of rationales for always displaying with animation.
    * I can also conceive of rationales for sometimes displaying the last frame, especially if the same page is being reloaded since many sites reload the same page in response to user form submissions.
    # '''I can see no rationale for displaying the first frame of the gif and would suggest that this is a bug. '''

    Can be this bug:
    * [https://bugzilla.mozilla.org/show_bug.cgi?id=641198 Bug 641198] – Rollover animated gif show only one frame.
    You can try these nightly test builds to see if they behave better:
    Fx5.0 ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-aurora
    Fx6.0 ftp://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central
    Create a new profile exclusively for each Firefox version and create a desktop shortcut with -P "profile" appended to the target to launch each Firefox version with its own profile.
    See these mozillaZine KB articles for information:
    * http://kb.mozillazine.org/Testing_pre-release_versions
    * http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    * http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    * http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • Stationary layer mask with moving image in iWeb?

    Hi everyone,
    I have a an image that I only want 1/4 of revealed. I want to animate the image so that it moves across the opening of the mask (like someone passing by a window).
    Is this possible in iWeb?
    Have a great summer everyone,
    Joe

    Thank You for the links- this is a real education!- and after you rewrite the code where do you put it in iWeb? Do you paste it into a text box? Is the code embedded into the iWeb file or is it a link to a server outside the file?
    Sorry about all the questions- I'm just trying to understand the technology so I can make a decision of where to start learning. I am looking for the simplest path to follow.
    J

  • Best practice for displaying an image

    Hello everybody,
    I have an application that displays and animates several
    images and I was wondering what was the best way to improve
    performance.
    Is it better:
    - to create a Bitmap object, put it in the display list and
    then move it around
    - create a Sprite, do a graphics.beginBitmapFill and a
    drawRect, and then animate this Sprite.
    Using one method or the other doesn't make a big difference
    for me, but I was wondering if there is a difference in terms of
    performance and memory usage.
    Does anyone know ?
    Thank you.
    Yann Martel
    Aquafadas

    I don't think there is currently a way to do this in Catalyst (unless you create multipe text fields). I'd suggest setting it up in Flash Builder.

  • Moving background images horizontally as a loop?

    I was wondering, if anybody knew a way to get a Background-image moving horizontally and without interruption as a steady loop.
    I tried using animated Gifs, but that takes too much ressources, as the file size grows too large.
    I was wondering whether or not I should have the Background Image replaced by a div with a flash in it, that is being looped. This alternative looks kinda dodgy to me, though and I don't want this to be integrated.
    I saw some sites using Javascript for almost similar effects vertically, but these effects didn't really work on various browsers (Seamonkey/Firefox), although they worked fine on IE and Opera.
    This issue is really driving me nuts right now. thanks

    Do the end users really want this would be the first question I'd be asking! Just because one can put a plastic pink flamingo lawn ornament in their yard doesn't mean one should.
    1) The simplest, most sure-fire way is with an animated GIF. I'm not sure I understand your filesize concern - how many frames of animation are you using?
    2) Javascript - take a look at jQuery and it's associated plugins for ways to create sliding effects. This approach will not use css background images but rather fake it using different divs carefully positioned via Javascript DOM manipulation. Animation would also be provided by Javascript.
    3) Flash. Again not really using background images because Flash doesn't work that way. The downsides are 1) it's Flash, 2) Will need to use wmodewith all the issues that entails 3) will likely require absolutely positioning elements to create a background effect with all the issues that *that* entails.
    I'd suggest rethinking whether you really need animates background images and then taking a look at jQuery though and some of the jQuery "animation" plugins that are available.
    Oh and one final approach would be to do this all in Flash.
    Hope this helps.

  • Captivate integration with Edge Animate or Photoshop

    Hello everyone,
    I’m an Adobe CC premium member and I’m interesting to buy Adobe Captivate but I'm not sure it can be really what I need.
    How can I customize the graphical interface of the Adobe Captivate slides with others Adobe softwares?
    I mean, can I integrate this software with adobe Edge Animate for example? In particular within Javascript and jQuery code snippets I would know.
    Thanks in advance for your help

    >> I didnt understand this. <<
    i'm not surprised.  i'm so far down the learning curve i don't know what question to ask.
    i am willing to invest time and energy to learn Animate or DW.  i have never used either and it sounds like Animate might be simpler for my simple task.  what i meant by that question relates to what is the output of Animate or DW?  i know how to upload "images" to a web site (jpg, TIF, GIF).  is the output of animate an "image" or is it some code snippet i have to learn how to integrate into the webite i want to publish to?
    did that make sense?

  • How to create scroll controlled svg animations in Edge animate cc

    Since I am a beginner in Edge animate, I am very confused about svg animations in Edge animate. I want to create an effect like this http://tympanus.net/Development/SVGDrawingAnimation/index.html. In this page the animation is set to autoplay, I will controll my animation using scroller bar in adobe muse cc. Please tell me how to animate svg images like this.
    Thanks in advance

    Hi bhardwajaralhul517,
    Found something that could help you get started
    Using parallax scrolling in Animate with a single line of code | EdgeDocks.com
    How To Create A Parallax Scrolling Website | Web Design Principles
    Thanks,
    Preran

  • Shifting and moving images on a canvass

    I have to prgramm a little board game, where different images have to shift and move. I created a 2-dimensional array [j] as a surface and i want to shift the images around (when clicked) by changing their array-index. This doesnt work so far... can anybody give me hints how to move images around on a canvass with a method like that? everything helps!

    Hi.
    I don't know what you tried to do, but here is what I suggest:
    1. Make an array that represents the board.
    2. Mark each cell in the array where an image exists.
    3. repaint the canvas within a loop on the array.
    On each iteration u decide whether to draw an empty cell or a cell with an image.
    This won't animate the image (dragging it on the board), but rather make it disappear from its original cell and pop in its new position.
    Hope it helped.

Maybe you are looking for

  • Upgrade Project - 4.7 to ECC 6.0

    Hello Gurus, I am HR Functional consultant and assigned to work on upgrade project (4.7 to ECC 6.0) for the first time. I am new to this environment. Can any one help me with suitable documents to start with. My mail id: [email protected] Points assu

  • Customizing for WIP calculation: maintain status DLV and TECO

    Hi Team, I m a getting the above error while doing the WIP Calaculation . I am going to the transaction OKGC for maitaining the new valutions methods for controlling area  there . system is not allowing to enter the new value. Could you plaese help m

  • Space Impact of string Accounts

    Hi, I am considering adding 4 -5 Accounts of type string in a Planning Application (System 9). Each cell in a data block is 8 bytes but is this also true for string Accounts? Can anyone please tell the storage impact of having string Accounts in plan

  • Maps tells me I'm in England

    Friday Apr 25 while traveling south between Eckert and Fredricksburg TX on 16 I asked Google Maps to locate me. Three time over about ten minutes it told me I was in England. Where I was: http://maps.google.com/?ie=UTF8&ll=30.347695,-98.787346&spn=0.

  • ITunes keep opening after I closed it...

    I need help as iTunes keeps re-openeing after I manually closed it.  mY iPhone is not conected