Change images

Hey.  I have an xml which basically has a structure as follows

<image title="Mike from Camden" src="images/5.jpg"/>

In as3, I load in the xml file and then manipulated by the practice

private function handleXML(e:Event):void
{ 
xml = new XML(e.target.data);

     for (var i:int = 0; i < xml.children().length(); i++)
     {
          var loader:Loader = new Loader();

          loader.load(new URLRequest(String(xml.children()[i].@src)));

          images.push(loader);
          imagesTitle.push(xml.children()[i].@title);

          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
     }
     }

I have then essentially create a container and display each image in that container and view the text where appropriate.  If you click on an image, it zooms in to help

tween = new Tween(e.target.parent,"scaleX",Strong.easeOut,e.target.parent.scaleX,0.6,0.8,true);
tween = new Tween(e.target.parent,"scaleY",Strong.easeOut,e.target.parent.scaleY,0.6,0.8,true);

tween = new Tween(e.target.parent,"x",Strong.easeOut,e.target.parent.x,stage.stageWidth / 2 - e.target.parent.width + 15,0.8,true);
tween = new Tween(e.target.parent,"y",Strong.easeOut,e.target.parent.y,stage.stageHeight / 2 - e.target.parent.height + 15,0.8,true);

Now instead of zooming in on the image original and do expand, I would now like to change the image.  I add another url in my xml that points to another picture.  I can so this load and manipulate.  I then have to perform in the Tween to change to the new image?  I'll add the code in the class below, so you can see everything I do.

Thank you much for the help

package classes
{
     import flash.display.Sprite;
     import flash.display.MovieClip;
     import flash.net.URLLoader;
     import flash.net.URLRequest;
     import flash.display.Loader;
     import flash.events.Event;
     import flash.filters.BitmapFilter;
     import flash.filters.DropShadowFilter;
     import flash.text.TextFormat;
     import flash.text.TextField;
     import flash.text.AntiAliasType;
     import flash.events.MouseEvent;
     import fl.transitions.Tween;
     import fl.transitions.easing.Strong;
     import fl.transitions.TweenEvent;

     public class Main extends MovieClip
     {
          var xml:XML;
          var images:Array = new Array();
          var imagesLoaded:int = 0;
          var imagesTitle:Array = new Array();
          var tween:Tween;
          var zoomed:Boolean = false;
          var canClick:Boolean = true;
          var lastX:int;
          var lastY:int;

          var textformat:TextFormat = new TextFormat();
          var formatFont:Avenir = new Avenir();

          var screen:Sprite = new Sprite();

          public function Main():void
          {
               textformat.color = 0xFFFFFF;
               textformat.font = formatFont.fontName;
               textformat.size = 17;

               screen.graphics.beginFill(0x111111, .75);
               screen.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
               screen.graphics.endFill();

               loadXML("xml/images.xml");
          }

          private function loadXML(file:String):void
          {
               var urlLoader:URLLoader = new URLLoader();
               var urlReq:URLRequest = new URLRequest(file);

               urlLoader.load(urlReq);
               urlLoader.addEventListener(Event.COMPLETE, handleXML);
          }

          private function handleXML(e:Event):void
          {
               xml = new XML(e.target.data);

               for (var i:int = 0; i < xml.children().length(); i++)
               {
                    var loader:Loader = new Loader();

                    loader.load(new URLRequest(String(xml.children()[i].@src)));

                    images.push(loader);
                    imagesTitle.push(xml.children()[i].@title);

                    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
               }
          }

          private function loaded(e:Event):void
          {
               imagesLoaded++;

               if (xml.children().length() == imagesLoaded)
               {
                    removeChild(preloader);
                    prepareImages();
               }
          }

          private function prepareImages():void
          {
               for (var i:int = 0; i < images.length; i++)
               {
                    var container:Sprite = new Sprite();
                    var frame:Sprite = new Sprite();
                    var infoArea:Sprite = new Sprite();
                    var infoField:TextField = new TextField();

                    frame.graphics.beginFill(0xFFFFFF);
                    frame.graphics.drawRect(-20, -20, images[i].width + 40, images[i].height + 80);
                    frame.graphics.endFill();

                    /* Info Area  */

                    infoArea.graphics.beginFill(0x111111, 0.75);
                    infoArea.graphics.drawRect(0, 0, images[i].width, 60);
                    infoArea.graphics.endFill();
                    infoArea.y = images[i].height - 60;

                    infoField.defaultTextFormat = textformat;
                    infoField.embedFonts = true;
                    infoField.antiAliasType = AntiAliasType.ADVANCED;
                    infoField.width = images[i].width - 5;
                    infoField.height = 20;

                    infoField.text = imagesTitle[i];

                    // Resize

                    container.scaleX = 0.3;
                    container.scaleY = 0.3;
                    
                    // Position

                    container.x = stage.stageWidth / 3 + Math.floor(Math.random() * (stage.stageWidth / 4));
                    container.y = stage.stageHeight / 5 + Math.floor(Math.random() * (stage.stageHeight / 5));

                    /* Filter */

                    var shadowFilter:BitmapFilter = new DropShadowFilter(3,90,0x252525,1,2,2,1,15);
                    var filterArray:Array = [shadowFilter];

                    container.filters = filterArray;
                    
                    infoArea.addChild(infoField);

                    container.addChild(frame);
                    container.addChild(images[i]);

                    infoArea.visible = false;
                    container.addChild(infoArea);

                    container.getChildAt(1).addEventListener(MouseEvent.MOUSE_UP, zoomHandler);
                    container.getChildAt(0).addEventListener(MouseEvent.MOUSE_DOWN, dragImage);
                    container.getChildAt(0).addEventListener(MouseEvent.MOUSE_UP, stopDragImage);

                    addChild(container);
               }
          }

          private function dragImage(e:MouseEvent):void
          {
               e.target.parent.startDrag();
          }

          private function stopDragImage(e:MouseEvent):void
          {
               e.target.parent.stopDrag();
          }

          private function zoomHandler(e:MouseEvent):void
          {
               if (! zoomed && canClick)
               {
                    /* Avoid unwanted clicks */

                    canClick = false;
                    addChild(screen);
                    /* Cant drag when zoomed or zooming */

                    e.target.parent.getChildAt(0).removeEventListener(MouseEvent.MOUSE_DOWN, dragImage);

                    /* Get next highest depth */

                    setChildIndex(e.target.parent as Sprite, (numChildren - 1));

                    /* Get position */

                    lastX = e.target.parent.x;
                    lastY = e.target.parent.y;

                    tween = new Tween(e.target.parent,"scaleX",Strong.easeOut,e.target.parent.scaleX,0.6,0.8,true);
                    tween = new Tween(e.target.parent,"scaleY",Strong.easeOut,e.target.parent.scaleY,0.6,0.8,true);

                    tween = new Tween(e.target.parent,"x",Strong.easeOut,e.target.parent.x,stage.stageWidth / 2 - e.target.parent.width + 15,0.8,true);
                    tween = new Tween(e.target.parent,"y",Strong.easeOut,e.target.parent.y,stage.stageHeight / 2 - e.target.parent.height + 15,0.8,true);

                    tween.addEventListener(TweenEvent.MOTION_FINISH, zoomInFinished);
               }
               else if (zoomed && canClick)
               {
                    e.target.parent.getChildAt(2).visible = false;

                    tween = new Tween(e.target.parent,"scaleX",Strong.easeOut,e.target.parent.scaleX,0.3,0.3,true);
                    tween = new Tween(e.target.parent,"scaleY",Strong.easeOut,e.target.parent.scaleY,0.3,0.3,true);

                    tween = new Tween(e.target.parent,"x",Strong.easeOut,e.target.parent.x,lastX,0.3,true);
                    tween = new Tween(e.target.parent,"y",Strong.easeOut,e.target.parent.y,lastY,0.3,true);

                    tween.addEventListener(TweenEvent.MOTION_FINISH, zoomOutFinished);
               }
          }

          private function zoomInFinished(e:TweenEvent):void
          {
               zoomed = true;
               canClick = true;
               tween.obj.getChildAt(2).visible = true;
          }

          private function zoomOutFinished(e:TweenEvent):void
          {
               zoomed = false;
               removeChild(screen);

               tween.obj.getChildAt(0).addEventListener(MouseEvent.MOUSE_DOWN, dragImage);
          }
     }
}

addChild() takes only a DisplayObject instance as an argument, then you must do something like:

container.addChild(images[i]);
container.addChild(images2[i]);
images2[i].alpha = 0;

Tags: Adobe Animate

Similar Questions

  • I use Origami as my screensaver and changing images quickly, is there a way to slow the progression from one slide to another?

    I use Origami as my screensaver and changing images quickly, is there a way to slow the progression from one slide to another?

    Check in system preferences > Desk Top & screensaver:

    Ciao.

  • iOS10 Photos - change image 'people '.

    Are we able to change the poster image by default selected for each person in the new 'People' in Photos section on iOS 10?

    It is set by default to a particularly horrible photo of my daughter I would change if possible.

    Thank you

    Yes, I just found it.  When you go into the people album, tap the person you want to change to display the photos.  Press Select in the upper right, select the photo that you want to use and then press the Share button at the bottom left.  Scroll to the right in the bottom row, and there should be an option called "Set Key Face."

  • How do I change images from the album LIVE always prior to importation and after batch in Photos

    Help

    I have 1000 photos that are in LIVE format from my Iphone 6s.  I need to change this format forever I need to create slide shows and other changes.  Is this possible?  I know how to change each one individually, but obviously prefer a batch processing option.

    Thank you

    JO

    The best way to keep your original Photos to live and create a lot of JPEGs from your Live Photos would be to select all Photos live and use the file > export to export as JPEG files in a folder on your desktop. Set it the JPEG quality and the format of subfolder 'None '.

    Then import this file with JPEG files and use them for your slide show and delete them once again, when you don't need them more.  I find it safer to change the Live pictures to separate the still image video. There is a lot of work to do to revive again.

  • How to change images in microsoft word to jpeq

    I'm e-m with image and open Microsoft word.

    I want to make the same improvement by adobe photoshop but cannot open it in adobe photoshop.

    How do I?

    Hi rafaelTK,

    Unable to open images using Microsoft Word.

    You will first need to save the images sent in email on the computer and then right click on the image and click Open with, in adobe Photoshop select list. This would open the images using adobe Photoshop.

    How to change or choose the program that starts when you double-click a file in Windows XP

    http://support.Microsoft.com/kb/307859

  • Legal notice - change image of banner XP classic logon screen?

    I recently discovered how to change the banner of "the classic logon screen" XP up to the top of a logo of my choice, however, before you deploy this change to all clients in my network, I would like to know if there are legal issues with the removal of the existing "Windows XP" banner. Someone at - it any information on that? Thanks in advance.

    If you don't know what banner I'm talking about, see this image: http://yfrog.com/5nwindowsxpctrlaltdeletelj

    All what you need to do is replace msgina.dll in the folder system32 with a program like reshack (it is safe to use and is free)

    Matt

  • Change image Document image

    Hello, I am trying to create my own calculation by inserting a picture, but it must be in an image format. How can I change this document into an image?

    If you use MS Word select what you want as an image. Copy, then edit menu-
    Paste Special and select picture. Copy the just inserted image and Edit.
    Paste Special - Device Independent Bitmap. Copy and it will be on the
    the Clipboard as a picture.
     
    --
    ..
    --
    "Die Oma" wrote in message news: 61141b8d-5e5a-4c1f-b4da-80b3b58a4adf...
    > Hello, I am creating my own bill by inserting a picture, but it
    > must be in an image format. How can I modify this document in one
    > image?
    >
    >
    >
     
     
  • custom bitmaps field not change image when click on

    I created a custom bitmap field and I change the image on the center of my field of custom bitmaps and unfocus

    but when I implement the method of navigation click to change the image when you click on this image does not change...

    my custom bitmap field filed only to focus or unfocus on the image does not change my field of custom bitmaps.

    Bitmap onfocus = Bitmap.getBitmapResource("111.png");
                    Bitmap onunfocus = Bitmap.getBitmapResource("666.png");
                    mybutton1 = new CustomBitmapField(0,"",onunfocus,onfocus,Field.FOCUSABLE){
                         protected boolean navigationClick(int status, int time) {
    
                             mybutton1.setBitmap(Bitmap.getBitmapResource("favu.png"));
    
                             return true;
    
                         }
    
                    };
    add(mybutton1);
    

    and my class of field customBitmap is

    public class CustomBitmapField extends BitmapField {
    
        Bitmap Unfocus_img, Focus_img, current_pic;
        int width;
        String text;
        Font font; 
    
        public CustomBitmapField(int width, String text, Bitmap onFocus, Bitmap onUnfocus, long style) {
            // TODO Auto-generated constructor stub
            super();
            Unfocus_img = onUnfocus;
            Focus_img = onFocus;
            current_pic = onFocus;
            this.text = text;
            this.width = width;
    
        }
        protected void layout(int width, int height)
        {
            setExtent(current_pic.getWidth(), current_pic.getHeight());
        }
        protected void paint(Graphics graphics)
        {
            /*try
            {
                    FontFamily fntFamily = FontFamily.forName("BBAlpha Sans");
                    font = fntFamily.getFont(Font.BOLD,14);
            }
            catch(Exception e)
            {
                font = Font.getDefault();
    
            }
            graphics.setFont(font);
            graphics.setColor(Color.WHITE); */
            graphics.drawBitmap(0, 0, current_pic.getWidth(), current_pic.getHeight(), current_pic, 0, 0);
    
            //graphics.drawText(text, width, 7);
        }
        protected void onFocus(int direction)
        {
            super.onFocus(direction);
            current_pic = Unfocus_img;
    
            this.invalidate();
        }
      protected void drawFocus(Graphics graphics, boolean on)
      {
    
        }
        protected void onUnfocus()
        {
            super.onUnfocus();
            current_pic = Focus_img;
            invalidate();
        }
        public boolean isFocusable() {
            return true;
        }
        protected boolean navigationClick(int status, int time) {
    
            fieldChangeNotify(0);
            return true;
        }
    
    }
    

    When you debug this code, which of your methods of navigationClick, is actually used?

    When you expect the bitmap change, the code should lead object so that to happen.  Paint running?  This is the correct Bitmap painting?

    If you answer these questions, I think that you figure to yourself what is the problem.

    While you're there, you can also watch the following Threads that you have started or contributed to.  Can you solve or continue to contribute to these?

    http://supportforums.BlackBerry.com/T5/Java-development/gif-animation-not-displaying-properlly/m-p/2...

    http://supportforums.BlackBerry.com/T5/Java-development/timepicker-issue/m-p/2387819

    http://supportforums.BlackBerry.com/T5/Java-development/ListField-focus-color-problem/m-p/2407881#m2...

  • How to change image in a Signature block

    We have the signature blocks that are on all of our email correspondence.  Some of the photos on the blocks.  I know how to change the text on the blocks, but I don't know how to swap the images of people.  Need basic directions easy to please.

    (1) take your original and with the rectangular selection tool, make a selection around photography

    (2) hold the alt or option key and apply a layer mask and this will create a transparent area

    (3) create a new layer above the original and copy is a new photo. To adjust the precise size, use ctrl-T Transform or Cmd - T.

    (4) apply a layer race effect helps to put a margin around photography

    (5) Finally, select the layer of the photo and he Desaturate.  Shift-Ctrl-U or shift-cmd-U

    And that's all.

    Hope this has helped

    Terri

  • Change image 2500 pixels on the long side

    I posted earlier but just found out how to change my dpi of an image from 300 to 72 dpi. (Could not find my post above).

    Now I would like, if possible, in order to publish them, it's like a book on the Kindle cover, change the number of pixels on the longest side of the image on the recommended 2500 Pixels. (Right now the image I am interested is slightly more than that on the long side.).

    1. Go to image > resize > resize the image. It would launch a dialog box resize image.
    2. In the bottom of the dialog box, choose "resampling". in the drop down menu below, you can choose the resampling algorithm. Since you said that the image that you are interested in is a little more than 2,500, you should choose Bicubic Sharper. To learn more about the resampling algorithms, refer to https://helpx.adobe.com/photoshop-elements/using/resizing.html#resample_an_image
    3. Once you choose the option "resample image", it would allow the dimensions of pixel of the dialog box.
    4. change the height (or width) at 2500 depending on which side is the longest side.
    5. Click ok
  • Acrobat 9 Pro - change Image Compression/quality w / Javascript?

    Hello

    I have a script to the folder level that will merge PDF files using "insertPages" to add a list of PDF files to a new document. The file size is too large, and I noticed that if I go in the PDF Optimization manually and change the Image settings, so the quality of compression is 'low' for images in color and grayscale images, it brings the size of the file where I need it to be.

    My question is, can I do this in my script somehow? I see nothing in the Javascript reference or Acrobat SDK to update the images in the document. I really want to automate this optimization in my script.

    Has anyone ever done this before?

    Thanks in advance!

    Why not first to merge all files into a single PDF file and then crop and

    optimize only one file?

    Then you'll only process a single batch (to collect the paths of the files),

    and a manuscript of level the record to combine the selected tracks, and then crop

    and optimize the merged file.

  • Impression change image?  How to stop...

    Hi all...

    Okay, I confess... I probably get more irritated that this topic deserves, but heck...   WHY?

    Why open a file, printing it cause me save/exit when the window is closed, and how do I get to stop this?  I have looked through the help, configuration, etc, but can't find anything about her...

    Scenario: I have a few hundred images to print.

    I open an image.

    Press print (accept the default values of what was there before)

    hit close

    Wait while he decides that I "modified" the image

    then answer no do not save.

    go to the next image

    Did I say PS I don't like yet, not to save something, I haven't changed?

    Thank you!

    (You probably already know this) This happens because you print the file, if you open and close without feeling that you would not get prompted to save.

    I have shared your irritation on this topic for a very long time and wish they would change that. I understand that Adobe allows you to save your printing options in a file, but I often get this prompt and think to myself, ' did I save before printing or not? Well, I better save just to be sure, but it of the big avery file and will take some time. WHY Adobe WHY! »

    So the answer is no, you just have to wait this out and close without saving the changes.

    An action can help relieve your pain on a few hundred images that you can save closing after printing no save.

  • Change images dynamically in Repeater

    Hello

    I have an image of control inside Repeater.  I need to change the image mouseover and mouseout/mouseouthandler() dynmically.

    Kind regards

    Roman.

    I guess for each image, you also have an another "over" image. If yes I would use this approach:

             
                
                
               
    
              private function onMouseOver(event:Event):void
                {
                    var image:Image = event.currentTarget as Image;
                    image.source = image.getRepeaterItem().label1;
                }
                private function  onMouseOut(event:Event):void
                {
                    var image:Image = event.currentTarget as Image;
                    image.source = image.getRepeaterItem().label;
                }
    

    Let me know if that helps

  • Mass change Image in RoboHelp 7 HTML

    I am a new user to RoboHelp and recently inherited a form of draft someone else.

    The project was created using RoboHelp 7 HTML

    In this project of great help there are over 700 images each named Image1, Image2, Imange3... Image700.

    Now, many of these images needs to be edited, modified or all together again. Is there a way to find Image365 and replace it with an image called Img_BetterDescriptiveName update?

    Locate the image in the project manager, then press F2 to rename. Change throughout the project.

    The name of file and project name is highlighted, but you only have to type the new name. HR will automatically add the same extension.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • Change image color in black and white.

    Hello

    I have a color image. I want to change the half-portion of the image in black and white. Can someone gice me the idea to do.

    Thank you and best regards,

    Sreelash

    I just do the conversion to black and white in Photoshop and import the image.  If the intention is to tarnsition of black and white to color (or vice versa), then I would have melted the _alpha of a movieclip taking the image.

Maybe you are looking for