# Moving a single image across the screen with a reference value

**URL:** <https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101>\
**Category:** Ignition\
**Created:** [December 14, 2021, 2:58pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101 "2021-12-14T14:58:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 14, 2021, 2:58pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/1 "2021-12-14T14:58:56Z")

</div>

I need to move an image across my Main Window but I am unable to find the property for the x or y positions. How would I express this in the scripting. It is a PNG file. I am told that the x and y positions are read only, but I can move images on a Siemens or AB HMI so i believe there should be a way to do it in Ignition.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 3:28pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/2 "2021-12-14T15:28:54Z")

</div>

In Vision, you move or resize components with system.gui.transform().

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 14, 2021, 4:01pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/3 "2021-12-14T16:01:41Z")

</div>

Thank you yet again Phil. I have it working.

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 14, 2021, 7:32pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/4 "2021-12-14T19:32:58Z")

</div>

Phil,

I was able to get it to move but only if there is an action on the component or something else on the screen. I want to move it with a gateway script but I have never had to point to an object on the screens root container in the gateway or client scripts. How can it do this to keep something moving to a location with a value that will be changing dynamically without any action happening on the screen.

Thank you

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 7:44pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/5 "2021-12-14T19:44:51Z")

</div>

You can’t move it with a gateway script. (Scripts are confined to work with the process they are in.) Whatever you are using as input/trigger for your gateway script, implement it instead in a client script. If following tag values, bind the tag(s) to custom properties (of the component itself or maybe in the container) and use propertyChange events.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 7:46pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/6 "2021-12-14T19:46:20Z")

</div>

_Psst!_ Did you mean to publish your contact info?

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 14, 2021, 8:25pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/8 "2021-12-14T20:25:15Z")

</div>

Phil,

I am sorry for my ignorance but I have never had to move an image around on a screen before. The X and Y properties don’t exist for me to access and bind to a tag. The only thing I can write a script for is the EVENTS which is what I am trying to get away from. I only see ‘Rotation’ among other things as a choice. I am also not familiar with how to access something in the root container of a window in a Client Script.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 8:39pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/10 "2021-12-14T20:39:10Z")

</div>

You can edit your own posts. But prior versions will still be accessible. IA staff would have to make such an edit.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 8:42pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/11 "2021-12-14T20:42:11Z")

</div>

> [@christopher.raphael](#):
>
> The X and Y properties don’t exist for me to access and bind to a tag.

I wasn't suggesting that. I presume you are _ **computing** _ your desired x and y from _ **something** _. Other tags, I would expect. Make custom properties in your window and bind those _ **somethings** _ to them. That makes their data easily available in your window. Then use a propertyChange event where you bound those properties. In that event script, compute your desired x and y, and call system.gui.transform().

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2021, 9:56pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/12 "2021-12-14T21:56:36Z")

</div>

RE: Contact info, I pushed a button that said ‘hide revision’ and that seems to have done the thing.

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 15, 2021, 3:41pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/13 "2021-12-15T15:41:50Z")

</div>

Sorry, again not sure how to do this. I have worked on it but no luck. I tried adding custom properties to both the root container and the image on the screen but the image does not give me an option to bind the x and y to the custom property. I may need crayons for this.

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 15, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/14 "2021-12-15T15:51:07Z")

</div>

Just to be clear I know how to bind the custom properties but not how to tie them to the x, y positions of the image. Where would I use the transform script?

---

<div class="post-metadata">

**Author:** ![Tim](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim/32/3361_2.png) [@Tim](https://forum.inductiveautomation.com/u/Tim)\
**Post date:** [December 15, 2021, 4:14pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/15 "2021-12-15T16:14:10Z")

</div>

After you have the x and y added as custom properties on your image component you would add this propertyChange script on the component.

```auto
if event.propertyName == 'X' or event.propertyName == 'Y':
	system.gui.transform(event.source, event.source.X, event.source.Y)

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 15, 2021, 4:50pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/16 "2021-12-15T16:50:29Z")

</div>

You can’t bind to the x and y properties as far as I know. Create custom properties on the image that will hold the original x and y coordinates. However you initiate the image move script, first write the current x and y coordinates to the custom properties, then make the adjustment.

```auto
image = event.source.parent.getComponent('Image')

if image.isHome:
// Save Original position
	image.initialX = image.x   
	image.initialY = image.y
// Some kind of calculation 
	newX = image.x + 500      
	newY = image.y + 100
// Move Image
	system.gui.transform(image,newX, newY, duration=250)
// Image is not in original location anymore
	image.isHome = 0
else:
// Go back to original position	
system.gui.transform(image,image.initialX, image.initialY, duration=250)
	image.isHome = 1

```

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [December 15, 2021, 6:13pm UTC](https://forum.inductiveautomation.com/t/moving-a-single-image-across-the-screen-with-a-reference-value/54101/17 "2021-12-15T18:13:17Z")

</div>

That was the answer I needed. Thanks Tim I got it working. I work in Unity also and struggle with the transform function but I am learning.
