Skip to main content
Known Participant
October 24, 2016
Question

Captivate scripting - change x & y position of object

  • October 24, 2016
  • 3 replies
  • 4614 views

Hi all,

I am asking this because I would like to know if this is technically possible in Captivate 9...

What I would like to do is to have a button with a script on it so that when you click it an object

on the screen (this could be an image or a flash SWF object etc) moves from one point of the

screen to another. For example, it could be in the top-left hand corner and when you click the button,

it moves to the bottom right hand corner.

I know you can make one object on one part of the screen invisible by hiding it and making an identical

object elsewhere visible by showing it to give the illusion that it has just "moved" but I am wondering if

a script is possible where I can just move the same object.

Thanks in advance.

Keith

Moderator: took out your personal email address, this is a public forum

    This topic has been closed for replies.

    3 replies

    tomc69945220
    Participant
    December 4, 2017

    Most of the time if you just use the element name (e.g "Image_1") it won't work the way you want it to, your best option is to check the object name within cp-frameset if you inspect on a browser while previewing it. Basically by adding the prefix "re-" and suffix "c" in your script, it works every time for me.

    As an example:

    document.getElementById("Image_1")

    would become:

    document.getElementById("re-Image_1c")

    Participant
    March 20, 2020

    TQ Very much...at last..itss work

    Participating Frequently
    May 18, 2020

    Hi Hashim, have you got a working sample of this? I´m struggling to move buttons around when a button is clicked but it doesn´t work at least in html5 preview mode with or without "re" and "c" (why is captivate so awfully undocumented?). I think I´m missing some javascript syntax like add "cp." somewhere. Thanks!

    Lilybiri
    Legend
    October 24, 2016

    You can trigger any effect, also a motion effect using either directly with that button, or with an advanced action. If you don't need to do anything else with that button, the first approach will do what you want. At least: if you know the exact location where the object has to end. Motion path can be edited on the stage.

    TLCMediaDesign
    Inspiring
    October 24, 2016

    This is a script I used to incrementally move an object by 10 pixels right and down. If you change the number (10) it should work for you.

    var obj = document.getElementById( 'Image_1c' );

    var posX = parseInt( obj.style.left );

    var posY = parseInt( obj.style.top );

    obj.style.left = ( posX + 10 ) + 'px';

    obj.style.top = ( posY + 10 ) + 'px';

    Participating Frequently
    April 20, 2022

    Hi, can we use Execute JavaScript in Shared Action? Or any solution for the case that I wanna make all of slides have this action.

     

    Participating Frequently
    April 21, 2022

    You may only need to have one instance of this object.  Just set it timed for Rest of Project.  Then it will appear on all slides from the one where it is first added and the Object Name will not change.


    Thanks so much RodWard!

    And do you have any idea if the same action for all slide but the objective will be change, for example: a square in slide 1, a triangle in slide 2,.....