[Solved] Convert "rgb(0,64,255)" to use it as a variable

  • Hi,

    I have a string coming from a server I want to use as an expression :

    [TEXT] Set font color to : "rgb(0,64,255)"

    The problem is C2 refuse my string, asking me a number. I could'nt find answser in the actual posts (found answers with string concatenation but it is still a string).

    Is there something like eval("rgb(0,64,255)") ?

    Thanks.

  • The problem is because you're trying to send an expression as a string - you should just send the numbers.

    [TEXT] Set font color to : rgb(servervalue1, servervalue2, servervalue3)

    Or store the result of rgb(0,64,255) (you can check it at runtime) to the server and retrieve that instead.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok I see. I will go on the second option (result of color), but cant see it at runtime. I have the free version of C2, in the debug panel color does not appear. Or do I have to look elsewhere ?

    Thanks

    EDIT : found this topic, diggin it scirra.com/forum/viewtopic.php

    PS : coming from AS and PHP, the "eval()" function is useful although it is sometimes a bad practice, perhaps that's why C2 doesn't provide it ^^

  • C2 does provide JS execution in the Browser object, but you certainly should not use it in this case.

  • I found the color formula here : scirra.com/forum/viewtopic.php and submitted it in the "How do I..." page (where I looked first ^^).

    Can you give an example of JS execution in the browser ? (just for information).

    Thanks

    Amazing community and software

  • Here's an example why it is useful to know the color formula (where wsColor is a number value) :

  • C2 does provide JS execution in the Browser object, but you certainly should not use it in this case.

    Can you give an example of JS execution in the browser ? (just for information).

    RTFM ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)