Share
The Share object can bring up the system share feature, allowing the user to share something via another app.
Scripting
This object has no script interface, because when using JavaScript or TypeScript coding you can use the browser built-in Web Share API.
Sharing files
The Share plugin can add files to a share, such as images or videos, if Is sharing files supported is true. The contents of the file is taken from a Binary Data object. Often Construct can provide a screenshot or video as a local URL. The process to share this as a file is as follows:
- Use the AJAX object to load the URL in to a Binary Data object. This works like any other AJAX request, except using the Set response binary action before the request action.
- Once the AJAX request completes successfully, the data from the URL is in the Binary Data object.
- Now you can use the Add file action to attach the contents of the Binary Data object to the next share. Use the Add file action immediately before the Share action to attach the file to the next share.
For an example of this, open the 'Taking screenshots' example which demonstrates taking a canvas snapshot and sharing it as a file.
Share conditions
- Is supported
- Check whether sharing is supported on the current platform. Sharing will only work if this is true.
- Is sharing files supported
- Check whether sharing files with the Add file action is supported on the current platform. The Add file action will only work if this is true. If it is false but Is supported is still true, then the Share action can still be used to share text and a URL.
- On share completed
- Triggered after a share action once the user completes the share process.
- On share failed
- Triggered if a share action is not successfully completed or an error otherwise occurs.
Share actions
- Add file
- Attach a file to the next share using the contents of a Binary Data object, with a given filename. This can be used multiple times before a Share action to attach multiple files to be shared, such as a series of screenshots. The type of the data must also be specified, which is normally
"image/png"
for a screenshot, or "video/webm"
for a video, but can also be other types (see MIME Types). For more information see Sharing files above.
- Share
- Use the system share feature to share some text via another app. Text is the text to share; Title is an optional title to use (which can be used for other fields, such as the subject of an email if shared to an email app); and URL is a link to share. All three fields are optional, but at least one must be provided. If Is sharing files supported is true and any Add file actions were used before this action, those files are attached to the share.
Share expressions
The Share object has no expressions.
Construct Animate Manual
Construct.net
2018-11-16
2024-02-16
You are here:
Search this manual:
This manual entry was last updated on 16 Feb, 2024 at 16:54