Creeps Compilation's Recent Forum Activity

  • Hi again dop2000,

    The script creates a button, see script below..

    I am just not sure about how to control that script created button with a button

    created within a Contruct2 project.

    Can I give this script created button a "name" or UID, or something so I can generate

    a button in Construct2 to invoke this function?

     //let there be light!
    
     const btn = document.querySelector('.switch');
     btn.addEventListener('click', function(){
     track.applyConstraints({
     advanced: [{torch: true}]
    
     });
    
    
  • Hi dop2000,

    No, I have not tried that yet.

    I don't have a subscription for Construct 3, I paid for Construct 2 and would

    prefer to find a solution using software that I can actually "own" instead of "rent".

    The problem with "renting" software is that I won't be able to modify my work product

    code without endlessly paying a monthly fee.

    Thank you for helping dop2000..

    I am hoping to find a solution using my existing "paid for" Construct 2 software..

  • Hello,

    I need to be able to turn ON and OFF the camera FLASHLIGHT on the back of devices that have them.

    The Construct User Media Plug in does not include any functions for the camera FLASH..

    I found some example Java Script that WORKS !!!

    I am successfully able to control the camera FLASHLIGHT (ON and OFF) from within a web browser window.

    However, if you read my post, I cannot control the java script from a button click within my Construct project..

    I need to put a button or sprite button on my Construct project that can command the java script function..

    I would prefer a simple PLUGIN called TORCH or something which would use the java script as a source starting

    Point, and allow me to create On Clicked events.

    • Check if TORCH is PRESENT

    • TORCH ON

    • TORCH OFF

    Click here to view post..

    construct.net/en/forum/construct-3/scripting-51/construct-button-execute-157054

    Please let me know if you have a solution for my problem.

  • Hello,

    I need to be able to turn ON and OFF the camera FLASHLIGHT on the back of devices that have them.

    The Construct User Media Plug in does not include any functions for the camera FLASH..

    I found some example Java Script that WORKS !!!

    I am successfully able to control the camera FLASHLIGHT (ON and OFF) from within a web browser window.

    However, if you read my post, I cannot control the java script from a button click within my Construct project..

    I need to put a button or sprite button on my Construct project that can command the java script function..

    I would prefer a simple PLUGIN called TORCH or something which would use the java script as a source starting

    Point, and allow me to create On Clicked events.

    • Check if TORCH is PRESENT

    • TORCH ON

    • TORCH OFF

    Click here to view post..

    construct.net/en/forum/construct-3/scripting-51/construct-button-execute-157054

    Please let me know if you have a solution for my problem.

  • Hello,

    I need to be able to turn ON and OFF the camera FLASHLIGHT on the back of devices that have them.

    The Construct User Media Plug in does not include any functions for the camera FLASH..

    I found some example Java Script that WORKS !!!

    I am successfully able to control the camera FLASHLIGHT (ON and OFF) from within a web browser window.

    However, if you read my post, I cannot control the java script from a button click within my Construct project..

    I need to put a button or sprite button on my Construct project that can command the java script function..

    I would prefer a simple PLUGIN called TORCH or something which would use the java script as a source starting

    Point, and allow me to create On Clicked events.

    • Check if TORCH is PRESENT

    • TORCH ON

    • TORCH OFF

    Click here to view post..

    construct.net/en/forum/construct-3/scripting-51/construct-button-execute-157054

    Please let me know if you have a solution for my problem.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I found some java script example code that WORKS GREAT for me..

    It successfully turns ON the FLASHLIGHT on the back of an Android cell phone within a Chrome browser.

    The script creates a button function, then there is HTML code that DRAWS the button itself..

    Here is the HTML code that successfully EXECUTES the java script function..

    ================================================================================

    	<html>
    		<body>
    
    <button 
     class="switch" 
     style="width: 126px; height: 64px;" > 
    </button> 
    
    		</body>
    	</html>
    

    =================================================================================

    I can successfully RUN the java script using the BROWSER PLUGIN, however...

    QUESTION: How do I program a BUTTON within Construct to EXECTUE the button function within the java script?

    Below is the java script code..

    =======================================================================================

     //Test browser support
    const SUPPORTS_MEDIA_DEVICES = 'mediaDevices' in navigator;
    
    if (SUPPORTS_MEDIA_DEVICES) {
     //Get the environment camera (usually the second one)
     navigator.mediaDevices.enumerateDevices().then(devices => {
     
     const cameras = devices.filter((device) => device.kind === 'videoinput');
    
     if (cameras.length === 0) {
     throw 'No camera found on this device.';
     }
     const camera = cameras[cameras.length - 1];
    
     // Create stream and get video track
     navigator.mediaDevices.getUserMedia({
     video: {
     deviceId: camera.deviceId,
     facingMode: ['user', 'environment'],
     height: {ideal: 1080},
     width: {ideal: 1920}
     }
     }).then(stream => {
     const track = stream.getVideoTracks()[0];
    
     //Create image capture object and get camera capabilities
     const imageCapture = new ImageCapture(track)
     const photoCapabilities = imageCapture.getPhotoCapabilities().then(() => {
    
     //todo: check if camera has a torch
    
     //let there be light!
     const btn = document.querySelector('.switch');
     btn.addEventListener('click', function(){
     track.applyConstraints({
     advanced: [{torch: true}]
     });
     });
     });
     });
     });
     
     //The light will be on as long the track exists
     
    }
    

    ====================================================================================

  • In the example JAVA script I posted here, there is a BUTTON created that turns ON the TORCH Flashlight..

    After the JAVA script, there is HTML creating a BUTTON that shows up and executes the JAVA script command

    to turn ON the TORCH Flashlight..

    I can use the BROWSER Plugin to execute the java script code..

    QUESTION: How do I get a Construct BUTTON to execute the JAVA scripted button command?

  • The following code works to turn ON the camera FLASHLIGHT, if this helps.

    ==================================================================================

    	<html>
    		<body>
    //Test browser support
    const SUPPORTS_MEDIA_DEVICES = 'mediaDevices' in navigator;
    
    if (SUPPORTS_MEDIA_DEVICES) {
     //Get the environment camera (usually the second one)
     navigator.mediaDevices.enumerateDevices().then(devices => {
     
     const cameras = devices.filter((device) => device.kind === 'videoinput');
    
     if (cameras.length === 0) {
     throw 'No camera found on this device.';
     }
     const camera = cameras[cameras.length - 1];
    
     // Create stream and get video track
     navigator.mediaDevices.getUserMedia({
     video: {
     deviceId: camera.deviceId,
     facingMode: ['user', 'environment'],
     height: {ideal: 1080},
     width: {ideal: 1920}
     }
     }).then(stream => {
     const track = stream.getVideoTracks()[0];
    
     //Create image capture object and get camera capabilities
     const imageCapture = new ImageCapture(track)
     const photoCapabilities = imageCapture.getPhotoCapabilities().then(() => {
    
     //todo: check if camera has a torch
    
     //let there be light!
     const btn = document.querySelector('.switch');
     btn.addEventListener('click', function(){
     track.applyConstraints({
     advanced: [{torch: true}]
     });
     });
     });
     });
     });
     
     //The light will be on as long the track exists
     
     
    }
    <button class="switch">On / Off</button>
    		</body>
    	</html>
    
  • The User Media Plug in needs to support Camera FLASHLIGHT, or TORCH functions.

    There are many situations where poor lighting requires a camera FLASH to take a

    decent picture.

    TORCH ON

    TORCH OFF

    TORCH FLASH

  • I found this code, that works on Android..

    ==============================================================================================

    	<html>
    		<body>
    //Test browser support
    const SUPPORTS_MEDIA_DEVICES = 'mediaDevices' in navigator;
    
    if (SUPPORTS_MEDIA_DEVICES) {
     //Get the environment camera (usually the second one)
     navigator.mediaDevices.enumerateDevices().then(devices => {
     
     const cameras = devices.filter((device) => device.kind === 'videoinput');
    
     if (cameras.length === 0) {
     throw 'No camera found on this device.';
     }
     const camera = cameras[cameras.length - 1];
    
     // Create stream and get video track
     navigator.mediaDevices.getUserMedia({
     video: {
     deviceId: camera.deviceId,
     facingMode: ['user', 'environment'],
     height: {ideal: 1080},
     width: {ideal: 1920}
     }
     }).then(stream => {
     const track = stream.getVideoTracks()[0];
    
     //Create image capture object and get camera capabilities
     const imageCapture = new ImageCapture(track)
     const photoCapabilities = imageCapture.getPhotoCapabilities().then(() => {
    
     //todo: check if camera has a torch
    
     //let there be light!
     const btn = document.querySelector('.switch');
     btn.addEventListener('click', function(){
     track.applyConstraints({
     advanced: [{torch: true}]
     });
     });
     });
     });
     });
     
     //The light will be on as long the track exists
     
     
    }
    <button class="switch">On / Off</button>
    		</body>
    	</html>
    
  • WOW !!!

    Thank you MatrixReal..

    Will this run within a Chrome web browser?

    My application needs to run within a web browser and specifically NOT INSTALL

    as an APP on the phone devices, or tablets.

  • WOW !!!

    Thank you MatrixReal..

    Will this run within a Chrome web browser?

    My application needs to run within a web browser and specifically NOT INSTALL

    as an APP on the phone devices, or tablets.

Creeps Compilation's avatar

Creeps Compilation

Member since 13 Feb, 2014

None one is following Creeps Compilation yet!

Trophy Case

  • 10-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

12/44
How to earn trophies