How to get correct coordinate & size of components in scaled swf

I use canvas (I set it to fit whole screen size) to enclose a swfloader which loads a swf with width & height set to 100%. This swf has a movieclip. How can I get the correct coordinates of its position and its size after scaled in Flex?
In the Flash CS4, the movielip has x=40, y=700. In Flex, the swf is scaled 100% but when I get the x value of this movieclip, it's still 40. I try to get the scale ratio of x-axis by refering to swf's scaleX. But its 1, weird enough.
How can I get correct coordinates of movieclip?

I do try the localToGlobal but it seems its 1:1 ratio, the codes I use:
// swf is loaded by swfloader, there's a movieclip child named 'child_mc' in it, I want to locate its postion and size. It's top-left coordinates in flash cs4 is 4,740
var swf_obj:MovieClip = MovieClip(swf.content);
var mymc:MovieClip = swf_obj.child_mc;
child_before:Point = new Point(mymc.x, mymc.y);
child_after:Point = swf.localToGlobal(child_before);
Alert.show(
     "before:"+child_before.x+","+child_before."y"+"\n"
     + "after:"+child_after.x+","+child_after."y"+"\n"
the dump result is:
before:4,740
after:4,740
dump screenshot is here: http://img198.imageshack.us/img198/2396/image2ew.png
I use values of child_after to draw green box. The white box is child_mc's actual position after scaled to fit canvas size (in turn the screen size). You can see they are far from each other. Why?
Do you mean I have to multiply the transform matrix myself to get the correct position?

Similar Messages

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to get the coordinate of a cell in the jtable?

    How to get the coordinate of a cell in the jtable?
    How to get the point of a cell in the jtable?
    Thanks for help!

    getCellRect(...);

  • How to get the byte[] size dynamically from the StreamMessage object

    Hi all,
    Using JMS, I am receiving the FDF file as StreamMessage from the queue and attaching it to the PDF file which is present in the local system.
    For that, I have written the code as follows:
    {color:#0000ff} Message msg = jmsTemplate.receive();
    if(msg !=null && msg instanceof StreamMessage)
    StreamMessage message = (StreamMessage) msg;{color}
    {color:#ff6600}//hardcoded the byte array size value
    {color}{color:#0000ff} byte[] bytes = new byte[{color:#ff0000}856{color}];
    System.out.println("read msg="+message.readBytes(bytes));{color}
    {color:#0000ff}PdfReader pdfreader = new PdfReader("D:\\Managing_Workflows_No_Comment.pdf");
    PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("D:\\12345.pdf"));
    FdfReader fdfreader = new FdfReader(bytes);
    stamp.addComments(fdfreader);
    {color} {color:#0000ff} stamp.close();
    {color}{color:#000000}The above code is working fine except with the hardcoded of {color:#ff0000}byte array{color}{color:#ff0000} size value{color} which is given in {color:#ff0000}RED{color} in color.
    Can anybody know, {color:#000000}*how to get the byte[] size dynamically from the StreamMessage*{color} object ?
    Any help would be highly beneficial for me !!!!
    Thanks and Regards,
    Ganesh Kumar{color}

    When you create your stream message you could add an property to your message, something like streamSize that would contain the number of bytes in your stream message. Then you could get this property from the message before declaring your array.
    Tom

  • How do I get correct text size in MM

    Hi all
    (Illustrator CS4)
    One thing has been puzzling me while using Illustrator. If I am given a job and it says the text needs to be 2mm high how do I do this? If I type 2mm into the character tool the size of the text when turned into paths is actually 1.444 mm?! Is there any way of getting text in exact mm without guess work!
    Regards
    Matthew

    Hi everyone,
    this topic has already been answered, but I didn't find the method I've come to use mentioned.
    There are two ways I use to do this, both with the same results in sizing.
    #1:
    If I don't need editable type at all, I just create outlines out of everything and change the height.
    This works if you don't need the font-size and want every letter to fit into a rectangle with the same height.
    #2:
    By adding a Live Effect in the Appearance-panel, you can achieve the same results as you do with create outlines, but with the added bonus of getting the font-size and you can even choose just one letter to set the height by.
    I choose Path > Outline Object in the Appearance-panel, followed by typing in whatever mm I want in the transform panel, not the font size. Then I clear the appearance.
    By turning on the bounding box you can also see what's happening. When you create outlines from type, the bounding box
    will "hug" the letters tightly and not use the usual upper/lower-case bounding box.
    If the customer knows what letter he wants to be exactly measured, I use this method first and save the font-size that comes up and write with it.
    Hope this helps someone out there, it works for me.
    -Asbjørn

  • Help ...how to get the file size on a server

    Hi.I use this code to parse a file that is on a server.
    The question is: how can i get the file size (bytes size)?
    Thanks.
    //Open the file for reading:
    URL u = new URL(entry);
    InputStream inputXML = u.openStream();
    //Build document:
    DocumentBuilder builder = factory.newDocumentBuilder();
    doc = builder.parse(inputXML);

    Try this instead:
    URL u = new URL(entry);
    URLConnection conn = u.openConnection();
    // get the file size
    int size = conn.getContentLength();
    // open the input stream from the URLConnection (which is functionally the same as opening it directly from the URL)
    InputStream inputXML = conn.getInputStream();
    Shaun

  • How to get the Frame size in H.263 by JMF ?

    Dear all,
    How to get the individual frame size in H.263 format if the H.263 file is a format of InputStream ???

    VideoFormat.getSize() returns a Dimension of a frame. H263Format is a subclass of VideoFormat. Guess you could get that object from getFormat() in your stream if it's a PullBufferStream. Or, with a Processor, you could do getTrackControls() and iterate through the TrackControl.getFormat()s until you find the VideoFormat.
    Suppose you could also get a FrameGrabbingControl, grab a frame and get the Dimension from him.
    --invalidname

  • How to get Systemstate Backup size using PowerShell command in Windows 2008 R2

    Hi,
    We using WBSummary command to get completed backup status.
    I need to find how much data is backed up  using powerShell command .
    Is there any way to get the details , i can see the GUI but no in command.
    Please advise
    Regards Gopi K

    Hi,
    You mentioned that you can see the system state backup size in the GUI. Does the backup size mean the amount of date transferred?
    It seems that there is no such a PowerShell to get Systemstate Backup size. You may need to you need a PowerShell scripts to do this work.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=ITCG
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to get correct format in file at Application server

    Hi,
    I am retrieving data MATNR,MAKTX,VENDOR,VENDOR NAME,PRODUCT HIERARCHY,QUANTITY(LABST),BUDAT.
    I am downloading the data into .xls file in both presentation and application server.
    In presentation I am getting correct format.
    Where as in application server I am not getting proper format.
    Quantity(MARD-LABST) is not coming proprely.(###6## instead of 36)
    How to get it in correct forma?I

    symbol means  Space
    Before transfer the data to File..
    condense MARD-LABST and then transfer it.
    I guess you are using charcter field LABST while transferring the data to file.
    Do not use quantity field directly,please move it to charcter field then condense it.
    Thanks
    Seshu

  • How to get correct node in JTree with DISCONTIGUOUS_TREE_SELECTION mode?

    The following code creats a JTree with DISCONTIGUOUS_TREE_SELECTION mode. When select a single node, the node's name is printed correctly as expected. However, in Window environment, after select one node, if holding the ctrl key and select a different node, the program still prints out the name of the first selected node although both nodes are highlighted. Can some one tell me how to get the name of the second (i.e. the last) selected node printed?
    Thank you very much!
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.io.*;
    public class TestTree extends JFrame {
    JTree tree;
    public TestTree() {
    super();
    setBounds(0,0,500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tree = new JTree();
    getContentPane().add(tree);
    TreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setSelectionModel(model);
    tree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
    Object obj = tree.getLastSelectedPathComponent();
    System.out.println(obj.toString());
    public static void main(String [] args) {
    TestTree test = new TestTree();
    test.show();

    Hi!
    Try this, maybe it's what you want?
    /Smedman
    public void valueChanged(TreeSelectionEvent e)
        TreePath[] paths = tree.getSelectionPaths();
        for (int i = 0; i < paths.length; i++)
            System.out.println(paths.getLastPathComponent());

  • How to get the disk size

    Hi, everyone, does anyone know how to get the size of the disk, say hard disk? In the Writing Device Driver it says that the block device driver must create an 'nblocks' property for each minor block device. I want to get the size of the block device in another driver. Is there any DDI/DKI kernel function for this?
    How to get the same thing in a user mode application? Is there any API to do this?
    Thank you very much.

    I just found a function in include/sys/conf.h. The prototype is:
    extern int bdev_size(dev_t);
    Can I use this function to get the disk size of the device dev_t? I couldn't find the documentation of this function.
    Thanks

  • How to get Panel coordinates

    Hi All,
                i have a panel in canvas layout.
               if want to add one more panel immediate  next to the first panel i need to know  x, y coordinate of the first panel.
                How can i know i the coordinates.
    Can any help me?
    thanks
    Raghu

    You can get the coordinates by:
    panelOne.x and panelOne.y
    panelOne is the id of your panel. e.g. <mx:Panel id="panelOne" ...>...</Panel>
    To add a new panel right next to it you have to set the x and y for the new panel like this:
    newPanel.x=panelOne.x+panelOne.width;
    newPanel.y=panelOne.y+panelOne.height;
    Hope this helps.

  • How to get tables the size should be based on 3 months history.

    Hi,
    I am junior DBA, Actually, I want to get the details of columns D,E,F and G. For employee and dept tables the size should be based on 3 months history.
    How to get pls suggest me.
    Regards,
    Venkat.
    Junior DBA

    Venkat wrote:
    Hi,
    I am junior DBA, Actually, I want to get the details of columns D,E,F and G. For employee and dept tables the size should be based on 3 months history.
    How to get pls suggest me.
    Regards,
    Venkat.
    Junior DBAWhat are columns D,E,F, and G? Size of what is based on three months history of what?? How does this size of an unknown entity relate to columns D,E,F and G?

  • How to get correct voltage reading?

    Currently I am using PCL-818 DAS card from Advantech. Advantech's test program shows value correctly and I compare it with the multimeter. Problem is that I cannot get them correctly. For eg. The actual reads 5V but the indicator on front panel reads 0.09V instead. I used Advantech's AIVoltageIn.vi. What are the right adjustments I should apply on the Numeric Indicator's properties?

    astroboy wrote:
    > Currently I am using PCL-818 DAS card from Advantech. Advantech's test
    > program shows value correctly and I compare it with the multimeter.
    > Problem is that I cannot get them correctly. For eg. The actual reads
    > 5V but the indicator on front panel reads 0.09V instead. I used
    > Advantech's AIVoltageIn.vi. What are the right adjustments I should
    > apply on the Numeric Indicator's properties?
    I had to deal once with an Advantech card and I think you had to first
    configure it for a certain input range, which depends on the card you
    are using, or maybe jumbers on it :-(. Your problem looks very much like
    the card is configured to read for instance 0 - 10 V but the software
    believes the card is set to -5 - +5 V.
    Of course the configuration param
    eter on that VI was just a number 0, 1,
    2, 3, 4, etc so it was not very user friendly and in that particular
    case I just played around a bit until I got the correct measurements.
    I told however the guy asking me to show him how to get the card
    running, that I didn't very much like this driver and that I feel a LOT
    more comfortable to program with NI-DAQ than this quite user unfriendly
    library. Not sure if he did buy his next card from NI though.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to get Absolute Coordinates of a Field.

    I know that the properties "x" and "y" of any field of PDF Form will give me the coordinates relative to the parent object.
    How to get the absolute coordinates of any object (or any field) on a PDF Form?
    My objective is to make a Subform Visible or Hidden and reposition it close to any other field in order to display some extra text to show more info about the required field.
    How I can do that?
    Tarek.

    Hi,
    I wrote a recursive function that will go up in the forms hierarchy and summarizes the x and y coordinates of the parent objects.
    var vX = 0
    var vY = 0;
    function findCoordinates(vNode) {
        if (vNode !== null) {
            if (vNode.className === "field" || vNode.className === "subform") {
                console.println(vNode.name + " > " + vNode.x);
                var xUnit = vNode.x.match(/(mm|cm|pt|in)/g);
                var xValue = parseFloat(vNode.x.replace(xUnit, ""));
                if (xUnit === "mm") {
                    vX += xValue / parseFloat("25.4");
                } else if (xUnit === "cm") {
                    vX += xValue / parseFloat("2.54");
                } else if (xUnit === "pt") {
                    vX += xValue / 72;
                } else {
                    vX += xValue;
                var yUnit = vNode.y.match(/(mm|cm|pt|in)/g);
                var yValue = parseFloat(vNode.y.replace(yUnit, ""));
                if (yUnit === "mm") {
                    vY += yValue / parseFloat("25.4");
                } else if (yUnit === "cm") {
                    vY += yValue / parseFloat("2.54");
                } else if (yUnit === "pt") {
                    vY += yValue / 72;
                } else {
                    vY += yValue;
            findCoordinates(vNode.parent);
        var vCoordinates = (Math.round(vX * 2) / 2) + "mm " + (Math.round(vY * 2) / 2) + "mm";
        return vCoordinates;
    Textfeld2.rawValue = findCoordinates(xfa.resolveNode("Teilformular1.Teilformular2.Textfeld1"));

Maybe you are looking for