Aligning an object to the center...

I'm trying to load an image for displaying in a container
which have been loaded from the Library and placed on the stage.
Loading the image for which to use is no problem but algning
it to the center of the stage is a problem.
Now, keeping in mind that loaded images usually are placed at
the top-left corner of the stage I tried to solve the problem like
this...:
a = stage.stageWidth/2 (finding the center of the stage)
b = image.width/2
c = a-b (giving us the result of which to place the image)
image.x = c;
The formulas above make sence... in theory. In real life (at
least on my computer) it doesn't work.
Now, there might be some factors to consider when doing
simple math like this...:
- Can it be that the container is not the same size as the
image loaded?
- Can it be that I have to keep the x and y of the container
(although I have aligned it so it's placed at the center of the
stage)?
Any advice are helpfull...
Thanks in advance...
AceOfFlash

That should pretty much do it. So there are three things that
jump to mind.
1. You've moved the zero point of the movie clip that
contains the container. (of some parent of the parent, etc.)
2. You aren't waiting until the external content is
completely loaded. So consequently you aren't getting the proper c.
3. You are loading into a container more than once and you
need to set the scaleX and scaleY back to 1 before loading.
Okay I kind of lied a bit. There are more things that come to
mind. You say "container" but since this is the AS3 forum you mean
"Loader instance" right?
And yes NedWebs is right, some actual specific code would be
more helpful.
PS: You can shorten the math by just doing this:
image.x=(stage.stageWidth-image.width)/2

Similar Messages

  • Using Captivate 8, is it possible to animate the movement of an object from the center of the slide to the top?

    I have an object in the center of the slide.  As the narration continues, I want the object to move up toward the top of the slide so that I can "fade in" a related (new) object just below it.  How can I do that using Captivate 8?  I tried using the Effect features and Motion Path, but there are no motion paths going up.

    You probably missed that you can edit a motion path (not very easily, has to be done by dragging). This is an old article, but still the same work flow:
    Editing Motion Paths and Reusing Customized Effects - Captivate blog
    Lilybiri

  • How can I align a text object by the visible text and NOT by its bounding box?

    Illustrator CS4.
    I am trying to align some text to the center of the artboard. The bounding box is bigger than the text, so when I try to align it to the artboard it doesn't actually center align the artwork as I need it to. The text is needing to be aligned with another text object, so I can't just center align the text and then align to the artboard (which would eliminate the bounding box problem, I think). To make matters worse, the text I want to align has a stroke.
    The only way I know to currently align the text properly is to convert it to outlines. This is what I've done, but I need something better. I want to be able to have my illustrator file that has all editable text and then be able to make a separate identical file with all text converted to outlined paths. The only thing holding me back right now is that I can't get the exact alignment while everything is still as text.

    The solution is to simple to believe and probably why you over looked it.
    You make two text frames to exactly the height and width of the text. You position the text in the relative location and then group the text frames  then center that group on the artboard.
    Like such:
    If you ever want to add text that should be no problem but you have to re center.

  • Align TransparentContainer  to the center position of the browser

    Hi there,
    i would like to align my TransparentContainer to the center position of the horizontal point of view and to the the middle poition of the vertical point of view. I tried everything but nothing really worked. Maybe anybody of you has a good advice for me.
    Thanks,
    Albert

    Albert,
    There is a button on the toolbar using which you can center the entire BPM config.
    I don't remeber the icon and I am not infront of the system. But you should be able figure that out.
    I think its the 5th one from the left hand side, the one on the left hand side of 1:1 icon.
    Regards,
    Ravi
    Message was edited by: Ravikumar Allampallam

  • How do I position my layer/table for my header in the center and up top?

    I have designed a site before on my dreamweaver 4 site and
    decided to design a new one. I just tried to insert my header into
    the website and it worked fine. However, how to I align it directly
    in the center and all the way to the top so their is no space from
    the top of my site and header? My header is about 960 pixels wide
    and was hoping to have it centered when viewed with a few inches of
    background on each side. My last sight it just worked out when I
    did but not this time.
    Just so you know, I set a header layer down first, then put
    in a single row and column table, then inserted my Gif header.
    Header looks great but placement is wrong. Thanks

    Good grief - DW3? It's not there. You will have to do it in
    code view.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "dontsettle22" <[email protected]> wrote in
    message
    news:fm1p83$pql$[email protected]..
    > Darn it, this is what I was looking for, however, I am
    on dreamweaver 3.
    > I can't find an insert ....layout....div. Any other
    ideas where I find
    > div?

  • Why does Vertical Align Center align objects along the horizontal?

    And why does Horizontal Align Center align objects along the vertical?
    -g-
    P.S. Please please please make the Eydropper tool available by function key so I can toggle to it while using the Text tool. Please!

    g,
    but when I select two objects and click the vertical align button they snap to an invisible horizontal line
    This is (almost) identical to:
    Because (the centres of) vertically aligned objects will be on the same horizontal level/line.
    And that is just one way of expressing what vertical alignment means. Here are a few others:
    Their centres have the same height,
    Their centres have the same Y value on the Artboard/Workspace,
    In all cases, you can draw a horizontal line through their centres.
    Mathematically, Y = C (Y is a constant value C) is the equation for a horizontal line.

  • UI element in Webdynpro to align the content area at the center of the page

    Hi Experts,
    I am looking for a UI element in webdynpro which can keep the entire content area aligned to the center of the page as well as can provide the borders along the content area.
    Please suggest if there exists any such UI element in webdynpro.
    P.S. We are using NWDS Version: 7.01.00
    Thanks in advance for the replies.
    Regards,
    Anurag

    Hi Anurag,
    What you can try is to put all of your UI elements in Group and then do the alignment. Set the visibility property of the group header to invisible. This will give you a border.
    Hope this solves your problem.
    Regards
    Abhinav Sharma

  • How to get my_text in the CENTER aligned on my_form?

    Hello
    I put  a text field (say, its name is 'my_field' 80 characters length) WITH OUT caption and NONE appearence (not Solid box, no Sunken box).
    And i am populating/filling this field with some value PROGRAMATICALLY. Pre-Populating value is vary in its lenght.
    For example in 1st case,  i am pre-populating this my_field with 'AAAAAAAAAAAAA'
    In some other case,  i am pre-populating this my_field with 'AAAA'
    In some other case,  i am pre-populating this my_field with 'AAAAAAAAAAAAAAAAAAAAAAAAAAA'
    Fine.
    But i want print this text/value IN THE CENTER all the time / all cases, no matter How much lenghts's value i am populating, i mean, it shuld come CENTER in the micro soft word
    Pls. let me know how to get this formatting as CENTER ALIGNMENT
    Thank you

    You probably need to set the Align property of the Text field at design time..
    Select the Text Field and then in the Text formatting toolbar, choose the Align Center option to have the text displayed always in the center.
    Thanks
    Srini

  • How to align text in Panel Box to the center

    Hi,
    I would like to align the text in the Panel Box to the center. Here is my code snipplet:
    +<af:panelBox text="22" id="pb8"+
    titleHalign="center" ramp="highlight"
    background="dark"
    icon="/images/warningind_active.gif"
    showDisclosure="false"
    contentStyle="height: 50px; width: 100%; horizontal-align:center;">
    +<f:facet name="toolbar"/>+
    +<af:outputText value="Update RFC with Approval Info"+
    id="ot8"
    inlineStyle="font-size:medium; font-weight:bold;"/>
    +</af:panelBox>+
    But it didn't work. The text "Update RFC with Approval Info" is still align to the left by default.
    Any ideas?
    Thanks.
    -Mina

    You can't do it without panelGroupLayout. Try this way...
            <af:panelBox text="PanelBox1" id="pb1" titleHalign="center" ramp="highlight"
                background="dark">
                <f:facet name="toolbar"/>
               <af:panelGroupLayout id="pgl1" layout="horizontal" halign="center" valign="top">
                <af:outputText value="***centered***" id="ot1"/>
               </af:panelGroupLayout>
            </af:panelBox>

  • How to align object in the report layout

    Hello,
    I find it very difficult to aligin objects in the report editor or in the template editor. I know there are some alignment options, like aligning to the grid or aligning a group of objects, but they seem to work on the bounding rectangle for the object. For my text objects, those rectangles are arbitrarily sized. So aligning those rectangles does not correctly align the text baseline, for example.
    Does anyone have a tip on how you can align objects? I there maybe a way to alter the size of objects by changing a number in a property sheet somewhere?
    Regards,
    Frans

    The problems I am having now occur when I am editing the margin in the template editor. For some reason, the flex and confine options can not be turned off in the template editor. I believe they are turned on in this mode, at least in tools:options: paper layout they are turned on. But anyway, this really does not matter because I don't have nested objects in the margin. The objects that will go flying off are completely unrelated to the object I want to move or resize.
    Update: I have just tried editing the layout of a report that was based on the template I am working on. Turning flex off there had a positive effect. It seems indeed the 'flex' setting is to blame for the problems I am experiencing. Thanks for the tip!
    So now I would really like to know how to turn of flex in the template editor..

  • How to align the JLabel to the center

    Hi,
    I made a JFrame and a JLabel, I want to put the JLabel to the center of the North position. But it doesn't work, it's just placed in the upper left corner. I tried to use html code, such as:
    JLabel l = new JLabel("<html><h1><center>Hello</h1></html>");
    And then put it in the JFrame's north position, but it doesn't work either. What should I do?
    Thx
    Adrian

    Oh, sorry,
    I just found out the function on how to align it to the center, it's
    JLable.setHorizontalAlignment(JLabel.CENTER);
    Please forget about this question.

  • How to center a JFrame object on the screen?

    Does somebody know how to center a JFrame object on the screen. Please write an example because I'm new with java.
    Thank you.

    //this will set the size of the frame
    frame.setSize(frameWidth,frameHeigth);
    //get screen size
    Toolkit kit=Toolkit.getDefaultToolkit();
    //calculate location for frame
    int x=(kit.getScreenSize().width/2)-(frameWidth/2);
    int y=(kit.getScreenSize().height/2)-(frameHeigth/2);
    //set location of frame at center of screen
    frame.setLocation(x,y);

  • What is the objective of Web Center in fusion middle ware

    Hi,
    I want to know what is the objective of Web Center
    Is it is must to deploy OFM 11g with SOA support
    regards
    Amir

    Please refer -
    http://blogs.oracle.com/webcenter/entry/what_is_oracle_webcenter_part
    http://wiki.oracle.com/page/Oracle+WebCenter
    http://www.oracle.com/technetwork/middleware/webcenter/overview/index.html
    Is it is must to deploy OFM 11g with SOA supportNo, it's not mandatory. You may deploy the products/suites as per your requirement.
    Regards,
    Anuj

  • In Yosemite, pasted objects in Photoshop Elements 12 automatically snap to the center of a new window. How do I stop this from happening?

    I installed Yosemite yesterday. Now, when I paste an image into a new window to combine it with another image, the layer or layers automatically snap back to the center of the new window. How do I stop this from happening?

    Thanks, Barbara. I don't use a trackpad on my iMac, just a mouse. However, I DID discover yesterday that if I press COMMAND-T (the command to Free Transform an image) I can then move the image where I want in the window. I need to use the command every time I move the image, which is annoying--in Mavericks, that Free Transform command was somehow the default.

  • I need to add the values stored in the session object into the html textbox

    Dear Sir,
    i have been trying to create an edit employee details page
    What i have done till now is as follow:
    1. Got employee id from HTML page.
    2. Compared it with the id stored in the database.
    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
    4. Dispatched the session values to another servlet EditEmpDetails2.java
    what i need to do now
    5. Now i need to set the session values in the text field of the html form
    6. I also need to be able to edit those vales and store the edited values in the database.
    Please help me as i have tried doing it for 1 week without any clues
    i have tried to create a html page which is something like this:
    <html>
    <head>
    <title>Edit Employee Details Page</title>
    <body BGCOLOR="red" text="black">
    <h1 ><font color="black">Edit Employee Details Page</font></h1>
    <form action = "EditEmpDetails" method="Get">
    <table width="50% align="center"
    <tr><td>Employee ID: </td>
    <td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
    <tr><td><center><input type="submit" value="submit"></center></td></tr>
    <tr><td><center><input type="reset" value="reset" ></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    design of my servlet EditEmpDetails.java
    public void EditEmpDetails1 extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    HttpSession session = request.getSession();
    String employeeid;
    String X = request.getParameter("employeeid");
    System.out.println("Employee iD:" + X);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
    String query = "Select * from users where employeeid=?";
    PreparedStatement stat = con.prepareStatement(query);
    System.out.println(stat);
    stat.setString(1,X);
    ResultSet rs = stat.executeQuery();
    while(rs.next())
    String Z = rs.getString(password);
    if(Z.equals(X))
    String A = rs.getString(1);
    session.setAttribute("employeeid", A);
    String B = rs.getString(2);
    session.setAttribute("firstname", B);
    String C = rs.getString(3);
    session.setAttribute("lastname", C);
    String D = rs.getString(4);
    session.setAttribute("gender", D);
    String E = rs.getString(5);
    session.setAttribute("dateofbirth", E);
    String F = rs.getString(6);
    session.setAttribute("address", F);
    String G = rs.getString(7);
    session.setAttribute("postalcode", G);
    String H = rs.getString(8);
    session.setAttribute("phone", H);
    String I = rs.getString(9);
    session.setAttribute("mobile", I);
    String J = rs.getString(10);
    String url = "/EditEmpDetao;s.java";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
    dispatcher.forward(request,response);
    catch (Exception e)
    system.out.println(e)
    I do not know how to put the values stored in the session object into the html text box

    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
    5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
    In your JSP page use JSP expression tags to put the session attributes.
    it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
    I think i m clear enough.
    if you need more clarifications. just try it and then post your problem.
    Diablo

Maybe you are looking for

  • Software Component in Integration Design

    Hello, I have just imported a software component for our IS-U system. Then I have created a namespace as well as a message interface. But when I try to locate this software component in the transaction "sproxy", I can't see it. The CPA cache causes s

  • Loss of "Edit in Photoshop" button functionality with Photoshop CC

    First, I must say I am highly dissapponted in Adobe's decision to stop developing Encore. I know that streaming and cloud access to video projects is the fture, but DVD and BluRay is still the standard for a majority. I film events, weddings, trainin

  • Embedding gallery in PDF only displaying first image?

    Hi, I am embedding a web gallery made in Bridge as a PDF through Acrobat. The gallery works fine when opening the index.html that Bridge creates with the resources file. However when I embed everything as a PDF, the gallery opens and will only displa

  • Continuation of aborted change run failed in BW 3.5

    Hello experts, everytime when an attribute / hierarchy change run has been aborted (by means of unexpected runtime errors) I failed in starting it next time. Error RSENQ 2 ("Lock not set for: activation of hierarchy") occured in this case. I found a

  • Absolutely can't publish to .mac

    like the title says, I just can't publish to .mac, I tried almost everything, and every time I get the following error: An error occurred while publishing file "/Web/Sites". Try publishing again later. I tried publishing from another user, new site f