Is there a simple way to center an image on a canvas?

I got an image inside a canvas and when I load the image I want to Center and scale by this painting, what is the best way to do it?

MyCode :(
< mx:Canvas x = "10" y = "10" width = "190" borderStyle = "none" backgroundColor = "#d0d0d0" height = "190" >
< mx:Image id = "SMCDadosImg" complete = "changeSMCDadosImg (event); "horizontalCenter = red '0' = '0' / >
< / mx:Canvas >

private void changeSMCDadosImg(event:Event):void
{
var pW_SMCDadosImg:Number;
var pH_SMCDadosImg:Number;

pW_SMCDadosImg = event.target.width;
pH_SMCDadosImg = event.target.height;

trace ("W =" + pW_SMCDadosImg);
trace ("H =" + pH_SMCDadosImg);

If (pW_SMCDadosImg > pH_SMCDadosImg)
{
SMCDadosImg.height = 190;
SMCDadosImg.width = pW_SMCDadosImg /(190*pH_SMCDadosImg);
SMCDadosImg.x = 190/2 - SMCDadosImg.width/2;
}
ElseIf (pW_SMCDadosImg < pH_SMCDadosImg)
{
SMCDadosImg.width = 190;
SMCDadosImg.height = pH_SMCDadosImg /(190*pW_SMCDadosImg);
SMCDadosImg.y = 190/2 - SMCDadosImg.height/2;
}
Else if (pW_SMCDadosImg == pH_SMCDadosImg)
{
SMCDadosImg.height = 190;
SMCDadosImg.width = 190;
}
}

seems the very simple way to do this is:



Width = "100%" height = "100%".
horizontalAlign = "center" verticalAlign = "middle" / >

Tags: Flex

Similar Questions

  • Is there a simple way to move an entire animation in the framework?

    Hi, I just set up my first film of simple animation in AE but have now realised it is off center in the frame. is there a simple way to reposition the entire animation?

    It is a layer that is off or it?

    There are a few ways.

    If it is a layer, place your time running on a keyframe position indicator. Select all the position keyframes. Drag the position values to move all keyframes at once.

    Or move the anchor point of your animated layers

    If it's several layers, parent your layers in a new layer and then move the parent.

    Or you need to precompose your animation and move the precomp.

  • Is there a simple way to transfer files from Windows 7 to Windows 10?

    Original title: want to transfer files on my Windows 7.  Help!

    Still trying to get my files from my Windows 7 laptop to my Windows 8.1.  Would it not easier that I have upgraded to Windows top 10?  Is there a simple way to transfer from Windows 7 to Windows 10?

    You look in Windows Explorer > Documents, photo, music, etc.

    If you don't know where you saved the files, you have a big problem.

    You are the only person who knows where you saved your files.

    See you soon.

  • I have created a prproj file and want to create a master DVD.  Is there a simple way to do this?

    I have created a prproj file and want to create a master DVD. Is there a simple way to do this?

    You need to export an MPEG2-DVD file for use in an application to create DVD (like Encore CS6)

    You can also create an ISO for mastering purposes image file.

  • Is there a simple way to determine if an operating system has been virtualized?

    Is there a simple way to inspect a linux system, perhaps by a hook / proc, to determine if an operating system has been virtualized?  More multi-vendor is the solution, the better.  I don't know that I could grep through my table and system process for various metrics file, but I need something very stable, well known, and Boolean.  (This question has overcome my google skills as it is too vague for the sentence)

    Hello

    Yes, it is called red pill and you can watch the material using the command lspci or RedPill to determine more information.

    Best regards

    Edward L. Haletky VMware communities user moderator, VMware vExpert 2009, url = http://www.virtualizationpractice.comvirtualization practical analyst [url]
    "Now available: url = http://www.astroarch.com/wiki/index.php/VMware_Virtual_Infrastructure_Security' VMware vSphere (TM) and Virtual Infrastructure Security: securing the virtual environment ' [url]
    Also available url = http://www.astroarch.com/wiki/index.php/VMWare_ESX_Server_in_the_Enterprise"VMWare ESX Server in the enterprise" [url]
    [url =http://www.astroarch.com/wiki/index.php/Blog_Roll] SearchVMware Pro [url] | URL = http://www.astroarch.com/blog Blue Gears [url] | URL = http://www.astroarch.com/wiki/index.php/Top_Virtualization_Security_Links Top security virtualization [url] links | URL = http://www.astroarch.com/wiki/index.php/Virtualization_Security_Round_Table_Podcast Virtualization Security Table round Podcast [url]

  • Is there a simple way to return 10 back to safari 9.1.3 safari

    Y at - it a simple way back safari10 back to safari 9.1.3 on an iMac with El Capitan.

    If you have a backup made before installing Safari 10, restore the backup.

    Other that that, there is no easy way. I'm sorry.

  • Is there a simple way to reduce/increase the two A / track V sizes in the CC timeline? [was: Adobe CC]

    Y at - it a simple way to reduce / increase the two A / track V sizes in scenario C C?

    There are keyboard shortcuts for expand/collapse the heights of the audio track and shortcuts to expand/collapse the heights of video tracks, but not both at the same time in increments (although you can quickly develop their all at the same time).

    If you are using Premiere Pro default keyboard:

    Opt + - / = collapses / develops audio tracks

    Cmnd + - / = collapses / expands the video tracks

    Shift += develops all the video AND audio tracks

    Shift + - collapses all the video AND audio tracks

  • Can you help me? Is there a simpler way to write this short code?

    Hi, I'm quite new to coding and EDGE and think there must be a simpler way to write this? :

    sym.getSymbol("USA_animation").play ();

    sym.getSymbol("World_map").play ();

    sym.getComposition () .getStage ().getSymbol("UK_animation").$("UK").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("UK_animation").$("Piechart").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("UK_animation").$("people").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("UK_animation").$("PeopleText").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("UK_animation").$("UKText").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("AUS_animation").$("AUSTRALIA").fadeOut ();

    sym.getComposition () .getStage ().getSymbol("USA_animation").$("USA").show ();

    sym.getComposition () .getStage ().getSymbol("USA_animation").$("USAText").show ();

    Can you help me?

    Obivious to increase efficiency is

    var USA_animation = sym.getSymbol ("USA_animation")

    USA_animation. Play();

    sym.getSymbol("World_map").play ();

    USA_animation.$("UK").fadeout ();

    USA_animation.$("PieChart").fadeout ();

    USA_animation.$("people"). fadeOut();

    USA_animation.$("PeopleText").fadeout ();

    USA_animation.$("UKText").fadeout ();

    USA_animation.$("AUSTRALI_A").fadeout ();

    USA_animation.$("USA"). Show();

    USA_animation.$("USAText"). Show();

    If you perform a single operation on all the symbols of the "USA_animation" child, you can also reduce somethinng as

    sym.getSymbol("World_map").play ();

    var USA_animation = sym.getSymbol ("USA_animation")

    USA_animation. Play();

    var childSymbols = USA_animation.getChildSymbols (); f

    for (var i = 0; i)

    childSymbols [i] .fadeOut ();

    I don't know if these are the best ways, but these are in a way that I could think of.

    Let us know if offer you a lot shorted way to write this

  • Is there a simple way to change a file in source Flex SDK and use?

    I never worked on the source and built.  I see an order here:

    http://opensource.Adobe.com/wiki/display/FlexSDK/get+source+code

    Y at - it a shortcut?  I'm literally lack something in a file available to the sparks that would allow me to present my flex mobile app for approval and a thing is not supposed to be addressed during the next generation.  Is there a quick way to simply build the spark.swc and replace in FB?

    In some cases can help to patch.

    If the solution is simple enough, you can just take the source file to fix, include it in your project of preservation of the original namespace, implement your correction and that's it.

    The runtime of your implementation will be loaded instead of the library.

    I hope this helps.

  • Is there a simple way to "upconvert" SD video HD in iMovie or FCP?

    I made a movie in 10 years (using the DVX 100) on SD.

    In order so that it can be published on Amazon Prime, it must be converted to HD.

    Anyone been a simple way to do this using iMovie or FCP?

    THX

    It is 4:3 or 16:9? Do not know iMovie but you can do FCP or compressor so you don't need to edit as well.

  • is there a simple way to get photos of Photos in Photoshop

    Have I missed a simple way to get my pictures from Photos in Photoshop?

    Yes - buyexternal for extension of photo editors in the App store and we PS as a Publisher directly from Photos

    for other extensions, see Extensions for Photos for Mac Photo editing

    LN

  • Is there a simple way to convert the bits to 16 bit depth?

    It seems there are specific methods PDF/BITMAP to convert 8-bit depth, but I can't find any documentation to make it easily the file as a whole. Is there a way to do this? I want to convert from 32 to 16 bit.

    I have the Image Processor Pro code that looks like this:

      // Bit Depth
      var bd = toNumber(task.@bitDepth) || 0;
      if (bd) {
        var bpc = doc.bitsPerChannel;
        try {
          if (bd == 8) {
            doc.bitsPerChannel = BitsPerChannelType.ONE;
          } else if (bd == 8) {
            doc.bitsPerChannel = BitsPerChannelType.EIGHT;
          } else if (bd == 16) {
            doc.bitsPerChannel = BitsPerChannelType.SIXTEEN;
          } else if (bd == 32) {
            doc.bitsPerChannel = BitsPerChannelType.THIRTYTWO;
          }
        } catch (e) {
          LogFile.logException(e, "Error selecting bit depth " + bd);
        }
      }
    

    Then, later, I have this code that modifies the document mode so that you can save it as a bmp file:

      if (ImageProcessorOptions.JDI && ext == "bmp") {
        // We need to make adjustments depending the number of
        // bmp save bits selected
        if (saveOpts.depth == BMPDepthType.ONE ||
            saveOpts.depth == BMPDepthType.SIXTEEN ||
            saveOpts.depth == BMPDepthType.TWENTYFOUR ||
            saveOpts.depth == BMPDepthType.THIRTYTWO) {
          saveOpts.rleCompression = false;
        }
        if (saveOpts.depth == BMPDepthType.FOUR ||
            saveOpts.depth == BMPDepthType.EIGHT) {
          doc.changeMode(ChangeMode.GRAYSCALE);
        }
        if (saveOpts.depth == BMPDepthType.ONE) {
          if (doc.mode != ChangeMode.BITMAP) {
            doc.changeMode(ChangeMode.GRAYSCALE);
          }
          var cnvtOpts = new BitmapConversionOptions();
          doc.changeMode(ChangeMode.BITMAP, cnvtOpts);
        }
      }
    

    I don't think I've tested with PDF files.

    I hope this helps.

  • Is there a simple way to check if a numeric key?

    I have a digital controls control array (and I want to keep it that way). I would check if the user presses a button increment/decrement.

    If none of the buttons is pressed, I do nothing; If no is pressed, I take the value zero.  The value doesn't matter much to me.

    How can I check if the increment / decrement is pushed down? Thank you

    LV2011 SP1


  • Is there a simple way to put Google in a new tab or OTHERWISE I'LL UNINSTALL FIREFOX despite I've used for years

    I don't mind a reason any set yahoo as search engine. However Firefox should give me one of the Dwarfs users a solution to ease back to Google. I have followed the discussion threads but still find the yahoo xxxxxxx in each new tab, I asked.

    For completeness, if someone stumbles across this thread in a search:

    Here's how you can change your new tab page:

    (1) in a new tab, type or paste Subject: config in the address bar and press enter/return. Click on the button promising to be careful.

    (2) in the search above the list box, type or paste newtab and make a pause so that the list is filtered

    (3) double-click the preference browser.newtab.url and enter your favorite page:

    • (Default) page thumbnails = > subject: newtab
    • Blank tab = > subject: empty
    • Built-in Firefox homepage = > topic: welcome
    • Any other page = > full URL of the page

    Press Ctrl + t to open a new tab and check that it worked. Fixed?

    If the problems persist, some potential diagnoses and remedies:

    If Firefox will not let you change this setting: you can have what is called SearchProtect on your system. This must be removed the control panel. If the status is 'locked' we'll need to help you investigate a configuration file "automatic".

    Firefox if allows you to save your changes, but he doesn't know: one of your extensions may be the substitution of her. You can consult, disable and/or remove extensions on page modules. Either:

    • CTRL + SHIFT + a (Mac: command + shift + a)
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click Extensions. Then, take a critical look on the list on the right and turn off (or remove) something unknown.

    If the modification works during your session, but during the next startup is return to the unwanted page: you could have a user.js file in your personal settings Firefox (your Firefox profile folder). This article describes how to track down and delete the file: How to fix preferences that will not save.

    A little luck?

  • is there a simple way to transfer to Att/Yahoo emails to documents on hard drive folder?

    I want to keep a copy on my PC - lost ATT a lot, so I don't want it to happen again

    Hello
    I suggest you post the question in the forums of yahoo and check if it helps:

    http://answers.Yahoo.com/

    It will be useful.

Maybe you are looking for

  • When I opened a new tab it now opens to the search engine of Yahoo! instead of the "Location bar autocomplete» How can I change this back?

    I like to use the 'Location bar before semi-automatic' feature when I opened a new tab; However, recently when I opened a new tab it goes to the Yahoo! search engine. I did not define this upward. How can I change to continue using 'Location bar auto

  • Turbo Boost

    Hi, I'm new to this forum and I just got a w700 i5. I heard a lot about the problem of limitation with technology turbo boost, but my question is if the turbo is active by default or whether it should be enabled in the Bios. And if it should be enabl

  • Update graphics card on HP Pavilion DV6920ea

    Hello world I was wondering if it is possible to replace the graphics card for my HP Pavilion DV6920ea. It comes with Nvidia 8400 m GS graphics card. I searched around, and I understand that it is difficult to update the graphics card on computers la

  • How to use cover pages in Windows Fax Scan &?

    I am trying to create a cover page for the Windows Fax & Scan that I use for my small business as well as I don't have to keep tapping all my details every time I send a fax I created a cover page using the tools of the editor, but when I open it to

  • Remove duplicates from the oracle table using 2 columns

    HelloI need to remove the duplicates of an oracle table based on 2 columns in the table.i tried to remove duplicates using the join, but get the error like sql error ora-00933Thank you