Travis Bobier
 · Professional Nerd

Ceros SDK: Component-level Commands Glossary

About this Guide

This article contains a glossary of Ceros SDK component-level commands to use when writing your own SDK code. Please note that all listed commands are as is, and we cannot guarantee all functionality to work across all experiences and devices.

Methods Inherited from CerosLayer:

  • findAllComponents()

    • If the component is a group, returns all components in the group, otherwise returns an empty CerosComponentCollection

  • getPayload()

  • getTags()

  • getPage()

  • isComponent()

  • isSyncedObject()

  • isGroup()

  • isFolder()

  • show()

    • Please note: Any components that are configured in the Studio to be initially hidden will not be able to be shown via this command. However, you can use show() and hide() on a folder that contains the component to make it visible.

  • hide()

  • on

  • Methods Inherited from CerosLayerCollection:

    • show()

    • hide()

    • on()

    • merge()

click()

called on: CerosComponent or CerosComponentCollection arguments: none

Simulates a click event on the component(s) that this is called on. This is equivalent to the user clicking the component(s), and all events/animations that would be triggered by a user clicking the component(s) will also be triggered by calling this method.

var myComponent = experience.findComponentById('a-component-id');
myComponent.click();

getFullResolutionUrl()

called on: CerosComponent arguments: none

If the CerosComponent is a scalar image, returns the URL of the full-resolution version of the image. If it is not an image, returns undefined.

var myImage = experience.findComponentById('an-image-id');
var url = myComponent.getFullResolutionUrl();

getWidth()

called on: CerosComponent arguments: none

Retrieves the unscaled width of the component (the width as configured in the Studio).

var componentWidth = experience.findComponentById('a-component-id').getWidth();

getHeight()

called on: CerosComponent arguments: none

Retrieves the unscaled height of the component (the height as configured in the Studio).

var componentHeight = experience.findComponentById('a-component-id').getHeight();

getX()

called on: CerosComponent arguments: none

Retrieves the x position of the component after any entry animations have finished playing.

var componentX = experience.findComponentById('a-component-id').getX();

getY()

called on: CerosComponent arguments: none

Retrieves the y position of the component after any entry animations have finished playing.

var componentY = experience.findComponentById('a-component-id').getY();

reset()

called on: CerosComponent or CerosComponentCollection arguments: none

If called on a text component, resets the text content of that component back to the original text content provided in the studio. If called on an image component, resets the src of the image back to the original URL provided in the studio. If called on a CerosComponentCollection, will reset any text or image components in the collection.

experience.findComponentById('a-component-id').reset();

setUrl()

called on: CerosComponent arguments: url – The url of the new image useNewImageSize – Weather to load the new image in at its full size or to scale it to the size of the old image.

If the component is an image, sets the src of the image to the url provided. Has no effect if called on a component that is not an image.

experience.findComponentById('an-image-component-id').setUrl('www.example.com/example.jpg', true);

on(eventName, callback)

called on: CerosComponent or CerosComponentCollection arguments: eventName – The name of the event to callback – The function to run when this event is received

 

See Events

findComponentsByTag( tag )

called on: CerosComponentCollection arguments: tag – a string

Returns a CerosComponentCollection containing all components in the collection that have been tagged with tag in the Studio

var taggedComponents = componentCollection.findComponentsByTag("foo");

startVideo()

called on: CerosComponent or CerosComponentCollection arguments: none

Starts video playback on the video component(s). Calling this on a component that is not a video will have no effect. Calling this on a video that is already playing will restart it from the beginning.

var myVideoComponent = experience.findComponentById('a-video-component-id');
myVideoComponent.startVideo();

stopVideo()

called on: CerosComponent or CerosComponentCollection arguments: none

Pauses video playback on the video component(s). Calling this on a component that is not a video will have no effect. Calling this on a video that is not already playing will have no effect.

var myVideoComponent = experience.findComponentById('a-video-component-id');
myVideoComponent.stopVideo();

setText()

called on: CerosComponent or CerosComponentCollection arguments: textContext – The new text to display in the text component

Sets the displayed text content on the text component(s). Calling this on a component that is not a text component will have no effect.

Please note: This will not cause the text component to resize. Components will need to be sized properly to fit any text set on them or the text will be cut off.

var myTextComponent = experience.findComponentById('a-text-component-id');
myTextComponent.setText("I like tacos!");
1