Zoom in and out the image

My teacher went to the bed, but I thought try and move forward.  I'm a bit stuck well.  I have an image gallery that loads the images on the media of miniature sizes.  When one of the images is enabled, I darken the background and Tween Lite allows you to zoom the image.  To do this, I essentially clone the bitmap of the original image, place it at the exact location of the original image and use it as my Zoom tool.  My method is

private function modelClicked(e:MouseEvent):void
        {
            stage.addChild(screen);
            var item:ModelsItem = e.currentTarget as ModelsItem;
            var originalBitmap:Bitmap = item.bitmap;
            clonedBitmap = new Bitmap(originalBitmap.bitmapData.clone());

            stage.addChild(clonedBitmap);

            var rect:Rectangle = originalBitmap.getBounds(stage);
            clonedBitmap.x = rect.x;
            clonedBitmap.y = rect.y;
            clonedBitmap.width = rect.width;
            clonedBitmap.height = rect.height;

            TweenLite.to(clonedBitmap, 2, { x: (stage.stageWidth - originalBitmap.width) / 4, y: (stage.stageHeight - originalBitmap.height) / 6, onComplete:zoomInFinished, scaleX: 1, scaleY: 1 });

        }

This works well.  I added an event for when the zoom is complete.  The reason is that if the user clicks on the mouse anywhere on the screen, the image should zoom out and all appropriate measures taken.  So I don't

private function zoomInFinished():void
        {
            trace("Zoom In Finished");
            stage.addEventListener(MouseEvent.CLICK, mouseClicked);
        }

And then

private function mouseClicked(e:MouseEvent):void
        {
            trace("Mouse Clicked");
            stage.removeChild(screen);
            stage.removeChild(clonedBitmap);
        }

I can't know what to remove and what to add.  I now remove the dark background (screen) and the clonedBitmap (which I don't want loads and loads of bitmaps if the user click on the small image several times).  I think I should also remove the MouseEvent.

What happens now, is that you click on the small image that zoom in to enlarge.  When you click on the larger image, it disappears and you return to the original gallery.  However, if you try to click on another small picture, nothing happens.  Is the method that I initially put a MouseEvent on small images

private function populateItems():void
        {
            for (var i:int = 0; i < Math.min(COLS * ROWS, data.picture.length()); i++)
            {
                var item:ModelsItem = new ModelsItem();
                item.data = data.picture[i];
                item.x = PADDING_LEFT + (i % COLS) * (ModelsItem.ITEM_WIDTH + GAP_HORIZONTAL);
                item.y = PADDING_TOP + Math.floor(i / COLS) * (ModelsItem.ITEM_HEIGHT + GAP_VERTICAL);
                item.addEventListener(MouseEvent.CLICK, modelClicked);
                itemsHolder.addChild(item);
                sp.source = itemsHolder;
                items.push(item);
            }
            sp.verticalScrollPolicy = "on";
            sp.horizontalScrollPolicy = "off";
            sp.update();
        }

So I don't know if I should somehow invoke this EventListener on all points again?

No matter what valued Advisor,

Nick

You must remove the eventListener in its handler function, so it triggers only once.

private function mouseClicked(e:MouseEvent):void
{
    stage.removeEventListener(MouseEvent.CLICK, mouseClicked);
    trace("Mouse Clicked");
    stage.removeChild(screen);
    stage.removeChild(clonedBitmap);
}

Tags: Adobe Animate

Similar Questions

  • clock appears, zoom in and out, the mouse not responding pluse

    Randomly, the clock will be displayed in the lower right of the screen, the scren performs a zoom in and zoom out and the mouse goes haywire.  What is going on?

    Have you tried to test with another mouse that your current mouse is perhaps faulty?

    On the keyboard if you press the Ctrl Key and spin the mouse wheel at the same time this causes the screen to zoom in and out in some windows, such as Internet Explorer or on the desktop (if an icon is highlighted or selected).

    As you mention that the fault is random it will be difficult to solve the problems in the usual way.  See if you can detect some rhyme or reason to explain why it is being implemented.

  • Hello! Anyone know why Flash when I apply a Code snippet (gesture) (Zoom IN and OUT), when I run the app on my device, distorts the image?

    Hello! I m trying to develop an application of miself. A kind of world Hello for now. All very well, but when I put the code (extract) to zoom in and out, I run the application and, Yes, it zooms in and out, but image of DEFORMATION. He doesn´t the scale ". What should I do? Thank you very much!

    Have you tried that?

    movieClip_10.scaleX * = event. scaleY;

    movieClip_10.scaleY * = event. scaleY;

  • Smooth zoom in and out of an image

    Hello


    I would like to make a zoom in and out of images like this


    http://www.sofasandstuff.com/


    any ideas?


    is it

    ActionScript and 1 or 3?

    See you soon

    Rick

    To zoom in and out of the images is placing them in movieclips and gradually adjust clips values x and y scale.

  • Zoom in and out on a picture when I only have a touch screen?

    Hi all

    I'll put up a request for inspection, taking a touch screen. However the user want to zoom in and out on images. Zoom is OK - just grab the magnifying glass lens and click - but I don't see how to zoom with no shift key.

    Anyone got any suggestions?

    Maybe keep a logical button/contol and connect it to enlarge the property indicator of the image factor.

    -When the operator presses the button/control, you can change the zoom level

  • Zoom in and out on the image

    Hello!

    I need a simple solution to the ability to zoom in and out in and out of the image.

    It is not a card, just an image of 6400 x 4800 with a few 4-5 levels of zoom max.

    The solutions/tips/tricks/what whether?

    Thank you!

    Discover «localToGlobal»

  • Able user to zoom in/out the image in real time the performance of façade?

    Well I have searched this and have developed empty. What I would do, is to have a picture of a diagram on the front panel and during execution of the VI user can somehow zoom in/out the image in real time.

    I know there is something that is called Zoomfactor that you instantiate a way in the block diagram, but that seems to zoom in on a picture of race prior to the program. The zoom is not in real time. There is no possibility of real user to zoom in/out with free will, using the Zoomfactor I see. (Sorry I forgot display name of the service). And I saw messages by a man named George Zou that seems to come with a VI which is closest to what I want, but I pulled the VI site seems not compatible with my computer (my rig is under XP with Labview 2013 currently). So, I was wondering if someone else had found other answers appropriate to my specifications?

    Use a structure of the event to change magnification during execution.

    You can even program your own shortcuts to the structure of the event, for example if the user clicks on a particular point on the picture and you read this coordinate on, and you zoom way at this point remains in the Center... There are many options to play with...

  • Zoom in and out of the Web site Windows no dependencies a mouse - windows 7 pc

    I do not use a mouse on my laptop. Each time the window zoom in or out because that weighs a finger on the touchpad. How do I Zoom in and out in order to control the size of the window?

    Hello JRStef, you can reset the level of zoom of a page by pressing CTRL + 0 ("zero"). CTRL + -/ + decreases / increases the zoom.

  • cannot zoom in and out in the content viewer

    I finished my ebook with indesign, but it can't zoom in and out in my ipad form adobe content viewer, it just show me can not Zoom icon on center to my ipad, please help, thanks a lot

    Pinch and zoom only works with PDF articles.

    Bob

  • Artifacts when zoomed in and out

    Hello

    I have a new MBP for a few days. I can not complain. Great machine to work with design/photography. However, I think the experience of this kind of problem, I'm not able to solve so far.

    When you zoom in and out, I get these blocks of solid color. Sometimes, it is white and it is sometimes black.

    I have Intel Iris Pro graphics.

    Here is a link to see what it looks like: Microsoft OneDrive - access to files anywhere. Create docs with Office free online.

    Does anyone know how to fix it or will there be an update to fix it?

    I'm lucky I've got Photoshop on a PC, but also a Mac and the problem is not present on the PC. I really like MACs, but I think the Achilles heel is not being able to easily add third-party hardware. I think a third graphics card might just solve the problem of the mysterious black squares but Apple likes to keep manufacturing in the House. Also, it does not help that Yosemite is such a new OS.

    Have you tried pressing cmd 3 followed by cmd 2 when this happens because some people report it clears. All you do is put in the Red layer and RGB so you don't make any changes to the image.

    Terri

  • How to cut and paste the image of the body of the received email

    I'm trying to cut and paste an image included in the bottom of an email and insert it into a Word document so that you can size and print. I can highlight, cut it with Ctrl C, paste it into the document Word with Ctrl V, but the image doesn't show, although the picture frame appears when I click on the place where the photo was pasted. Framework, but empty, no image. Any thoughts?

    Thanks to everyone for their help.

    The problem has been resolved - to try and finally understand everything.

    If you encounter this problem, it is perhaps because, unless you know the file format of the inserted picture, programs can not figure it out for you. Place your cursor on the image, right click and save the image under a .jpeg instead of simply copying. Then work with the file .jpeg in any photo management program you use normally - or even insert it in Word.

  • BlackBerry Smartphones zoom in and out on e-mails and sms

    Hello.  New user here and away from nokia.  Question: I have read the manual and see how to zoom in and out of photos and pages in the browser, but how do I Zoom in and out one opened by e-mail or sms?

    thnx

    You can't zoom in and out of an email or a text Message, but you can set a size larger font for your device, Options > keyboard/screen.

  • Script for Zoom In and Out at specific intervals

    I've dabbled with javascript in the past, but I'm a total newb to Photoshop scripts.

    What I need is a script I can use to zoom in at specific intervals and another to zoom out to the same frequency.  I intend to use these two scripts in conjunction with configurator to make some buttons to do the tasks.

    For example...

    Current zoom is 30%.  Zoom in Script has an array of zoom levels: 12.5%, 25%, 50%, 100%, 200%, 300%, 400%.  The script should detect the current level of zoom in and find the next higher zoom level, 50%, and then assign this new zoom window.

    Similarly, Zoom out would do the same operation by selecting the next zoom low, 25 percent.

    That's all in order to get back some of the features of CS5 CS6.  I used the menu to zoom at the top of the screen TO move preset zoom levels when you draw on my Wacom Cintiq. This Configurator Panel would give more this feature back.

    One of you gurus of coding can help me with this?  Or at least give me a hint on how to handle the zoom percentage in Photoshop using javascript?

    Thank you!!!

    Matt

    That should do it...

    
    main();function main(){/****************Use either zoomIn();zoomOut();**************/if(!documents.length) return;var zoomLevels=[12.5, 25, 50, 100, 200, 300, 400];zoomIn();//zoomOut();
    
    function zoomIn(){var zoomLevel = getZoomLevel();for(var z in zoomLevels){    if(Number(zoomLevels[z]) > Number(zoomLevel)){        setZoomLevel(zoomLevels[z]);        break;        }    }};function zoomOut(){var zoomLevel = getZoomLevel();zoomLevels.reverse();for(var z in zoomLevels){    if(Number(zoomLevels[z]) < zoomLevel){        setZoomLevel(zoomLevels[z]);        break;        }    }};function getZoomLevel(){var ref = new ActionReference();ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var desc = executeActionGet(ref);return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);};function setZoomLevel( zoom ) {     if(zoom < 1 ) zoom =1;   var ref = new ActionReference();    ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );    var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;    var docRes = activeDocument.resolution;    activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );    var desc = new ActionDescriptor();    ref = null;   ref = new ActionReference();    ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );    desc.putReference( charIDToTypeID( "null" ), ref );    executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );    activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE ); };};
    
    
    
  • Navigate in the photo when zoomed in and using the mask tool

    Hey guys, I tried to figure out how to move photo when I'm zooming in and using the mask and I can not understand. It's a pain to have clear the Brush tool can pan around, especially when I am trying to add a mask. If someone could help, it would be great. Thank you!

    Space bar.

  • Object to detect and record the image of the object

    Hello

    I'm trying to detect the object and save the image. However, the programming can sometimes do as request and sometimes impossible. Someone know how to ensure that this programming is stable? My programming is attached. It is using pixels to detect the object when he gets to the Center.


Maybe you are looking for