This is an automated email from the ASF dual-hosted git repository. greg-dove pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit e63022143e7576b1cc9a2f16ea433d54fc6bd934 Author: greg-dove <[email protected]> AuthorDate: Mon Jun 15 16:26:29 2026 +0200 Add static fromHex support to RGBColor, alongside existing from HSV method --- .../src/main/royale/org/apache/royale/core/RGBColor.as | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/RGBColor.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/RGBColor.as index b5614c31d8..db63f8b248 100644 --- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/RGBColor.as +++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/RGBColor.as @@ -155,5 +155,21 @@ package org.apache.royale.core } return true; } + + /** + * Parse a 6-digit hex color string (with or without leading <code>#</code>) + * into a new <code>RGBColor</code>. Returns a color with NaN channels + * (i.e. <code>isValid == false</code>) if the input is malformed. + */ + public static function fromHex(hex:String):RGBColor{ + var c:RGBColor = new RGBColor(); + if(!hex) return c; + var v:String = hex.charAt(0) == "#" ? hex.substr(1) : hex; + if(v.length != 6) return c; + var n:Number = parseInt(v, 16); + if(isNaN(n)) return c; + c.colorValue = uint(n); + return c; + } } } \ No newline at end of file
