2 images in layer, always move in sync

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default 2 images in layer, always move in sync

    I have been testing some javascript to move images within a layer. (<div> tag)
    I have 2 images in the layer and I change the hspace and vspace of only one,
    they both move as though stuck together,

    Can this behaviour be prevented.


    chuck145 Guest

  2. Similar Questions and Discussions

    1. Move layer to mouse location
      Has anyone used the Move layer to mouse location snippet? I cant seem to get it to work. Thanks in advance. Geo
    2. move objects to new layer
      Is there a quick way to move objects to a new layer in situ? Can make new layer and cut and paste, but objects move. Collecting in new layer seems...
    3. Move objects to current layer
      Is there a keyboard short cut to do this in FHMX?
    4. Move Object to Current Layer
      Here's another question. When I select an object, then click on another layer name in the layer panel (FH MX 11, Mac), sometimes the object is moved...
    5. Move and resize object in layer
      I have a round ball on a layer by itself and I want to make the ball smaller and then move it in relation to an object in another layer. I must be...
  3. #2

    Default Re: 2 images in layer, always move in sync

    I have no idea what you just said - why not post a link to the page?

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================


    "chuck145" <webforumsuser@macromedia.com> wrote in message
    news:elklck$jvh$1@forums.macromedia.com...
    >I have been testing some javascript to move images within a layer. (<div>
    >tag)
    > I have 2 images in the layer and I change the hspace and vspace of only
    > one,
    > they both move as though stuck together,
    >
    > Can this behaviour be prevented.
    >
    >

    Murray *ACE* Guest

  4. #3

    Default Re: 2 images in layer, always move in sync

    Sorry if I was not clear,

    I am attaching the code - the page is not on the web

    There are 2 images in the layer
    When the first image is clicked, the javascript code moves the first image -
    but why does the second image move ?
    :smile;

    <!--This page is for testing the movement of an image -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>test_images</title>

    <script type="text/javascript">

    var imgvar
    var y_jump = 6
    var x_jump = 6


    function checkmove()
    {
    imgvar = window.event.srcElement

    img_y_now = imgvar.vspace
    img_x_now = imgvar.hspace


    imgvar.vspace = img_y_now + y_jump
    imgvar.hspace = img_x_now + x_jump
    }


    </script>

    <style type="text/css">

    #Head_layer {
    position:absolute;
    left:71px;
    top:19px;
    width:732px;
    height:240px;
    z-index:2;
    border: thin inset #660033;
    }

    </style>
    </head>
    <body>


    <div id="Head_layer">

    <img src="a_basketball.gif" onclick="checkmove('ball_1')"
    hspace="20" vspace="30" name="ball_1" width="40" height="40" id="ball_1"/>

    <img src="a_basketball.gif" hspace="200" vspace="200" name="ball_2"
    width="40" height="40" id="ball_2"/>

    </div>

    </body>
    </html>

    chuck145 Guest

  5. #4

    Default Re: 2 images in layer, always move in sync

    Images are inline elements - this means that they will be placed
    horizontally adjacent on a line (provided the container is wide enough to
    accommodate this. Your layer is 732px wide, image1 is 40px wide +20*2
    spacing = 80px total width, and image2 is 40px wide + 200*2 spacing = 440px
    total width.

    Your javascript is directly altering the hspace assigned to image1, causing
    it to occupy less total effective width. As that happens, image2 moves left
    since it will always want to abut image1.

    Geddit?

    --
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================


    "chuck145" <webforumsuser@macromedia.com> wrote in message
    news:elkp3q$o44$1@forums.macromedia.com...
    > Sorry if I was not clear,
    >
    > I am attaching the code - the page is not on the web
    >
    > There are 2 images in the layer
    > When the first image is clicked, the javascript code moves the first
    > image -
    > but why does the second image move ?
    > :smile;
    >
    > <!--This page is for testing the movement of an image -->
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >
    > <html xmlns="http://www.w3.org/1999/xhtml">
    > <head>
    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    >
    > <title>test_images</title>
    >
    > <script type="text/javascript">
    >
    > var imgvar
    > var y_jump = 6
    > var x_jump = 6
    >
    >
    > function checkmove()
    > {
    > imgvar = window.event.srcElement
    >
    > img_y_now = imgvar.vspace
    > img_x_now = imgvar.hspace
    >
    >
    > imgvar.vspace = img_y_now + y_jump
    > imgvar.hspace = img_x_now + x_jump
    > }
    >
    >
    > </script>
    >
    > <style type="text/css">
    >
    > #Head_layer {
    > position:absolute;
    > left:71px;
    > top:19px;
    > width:732px;
    > height:240px;
    > z-index:2;
    > border: thin inset #660033;
    > }
    >
    > </style>
    > </head>
    > <body>
    >
    >
    > <div id="Head_layer">
    >
    > <img src="a_basketball.gif" onclick="checkmove('ball_1')"
    > hspace="20" vspace="30" name="ball_1" width="40" height="40"
    > id="ball_1"/>
    >
    > <img src="a_basketball.gif" hspace="200" vspace="200" name="ball_2"
    > width="40" height="40" id="ball_2"/>
    >
    > </div>
    >
    > </body>
    > </html>
    >

    Murray *ACE* Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139