SyntaxTerror
Content Creator
- Joined
- Jul 24, 2014
Hello
This tutorial shows artists/modders how to use any RGB slider to change the colour of any part (layer) of a SWF costume mod, or even of an SWF hair mod.
It can be useful if you want to have more RGB sliders than available for a specific piece of clothing (eg. 3 sliders for a Top), several parts of a costume to be modified with the same RGB slider (eg. modify Top and Bottoms colours altogether), or even to make a static or dynamic hair RGB adjustable (eg. use the Headwear sliders to change hair colours).
It is even possible to make a Vanilla mod using sliders usually not available for Vanilla, such as Legwear or Cuffs ones.
The code as been written by ModGuy and is very versatile, though a bit complex if you're not experienced in ActionScript (but don't worry, adapting it to your needs is quite simple).
It has been improved by sby to add preset colours, which is a nice feature for hair mods. This code is shown in the second post.
Another code from Iago is a bit simpler, but doesn't allow to use sliders usually not available in Vanilla if you are making a Vanilla mod, or creating an RGB adjustable hair. This code is shown in the third post.
This example shows how to use the Collar RGB sliders to modify the colours of a piece of costume located in the Back layer of the Top template.
import SDTMods.*;
import flash.system.ApplicationDomain;
import flash.geom.ColorTransform;
registerMod(top);
charData = "";
modName = "";
modCreator = "";
var SDT = ApplicationDomain.currentDomain;
try
{
var g = SDT.getDefinition("g"); //Vanilla
copyRGB(g);
}
catch(ex)
{
//We're in loader, wait.
}
function initl(l) : void
{
copyRGB(l.g); //Loader
}
function copyRGB(g_ref) : void
{
var cc = g.characterControl;
top.addEventListener(Event.ENTER_FRAME, tick);
}
function tick(e)
{
var fills = g.characterControl.collarControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
top.back.rgbFill.transform.colorTransform = rgbFill;
if(fills.length < 9) return; //Check for rgbFill2
var rgbFill2 = new ColorTransform(1, 1, 1, fills[8], fills[5], fills[6], fills[7]);
top.back.rgbFill2.transform.colorTransform = rgbFill2;
}
This example shows how to use the Headwear RGB sliders to modify the colours of hair located in the Hair Under, Dynamic Hair Under and Dynamic Hair Over templates, as well as the Tongue Piercing slider to modify the colour of a knot located in both of these Dynamic Hair templates.
This code was used for the RGB Dynamic Braids (01) version 1.1 (without preset colours, available here).
import SDTMods.*;
import flash.system.ApplicationDomain;
import flash.geom.ColorTransform;
registerMod(under); //registers the HAIR_UNDER
registerMod(dunder); //registers the DYNAMIC_HAIR_UNDER (back braid)
registerMod(dover); //registers the DYNAMIC_HAIR_OVER (front braid)
charData = "";
modName = "RGB Braids 01";
modCreator = "SyntaxTerror"; //using Dante's Small Braids.
var SDT = ApplicationDomain.currentDomain;
try
{
//Vanilla
var g = SDT.getDefinition("g");
copyRGB(g);
}
catch(ex)
{
//We're in loader, wait.
}
function initl(l) : void
{
//Loader
copyRGB(l.g);
}
function copyRGB(g_ref) : void
{
var cc = g.characterControl;
under.addEventListener(Event.ENTER_FRAME, tick);
under.addEventListener(Event.ENTER_FRAME, tick2);
}
function tick(e)
{
var fills = g.characterControl.headwearControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
under.rgbFill.transform.colorTransform = rgbFill;
dover.segment0.rgbFill.transform.colorTransform = rgbFill;
dover.segment1.rgbFill.transform.colorTransform = rgbFill;
dover.segment2.rgbFill.transform.colorTransform = rgbFill;
dunder.segment0.rgbFill.transform.colorTransform = rgbFill;
dunder.segment1.rgbFill.transform.colorTransform = rgbFill;
dunder.segment2.rgbFill.transform.colorTransform = rgbFill;
if(fills.length < 9) return; //Check for rgbFill2
var rgbFill2 = new ColorTransform(1, 1, 1, fills[8], fills[5], fills[6], fills[7]);
under.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment0.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment1.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment2.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment0.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment1.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment2.rgbFill2.transform.colorTransform = rgbFill2;
}
function tick2(e)
{
var fills = g.characterControl.tonguePiercingControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
dover.segment2.knot.rgbFill3.transform.colorTransform = rgbFill;
dunder.segment2.knot.rgbFill3.transform.colorTransform = rgbFill;
}
This tutorial shows artists/modders how to use any RGB slider to change the colour of any part (layer) of a SWF costume mod, or even of an SWF hair mod.
It can be useful if you want to have more RGB sliders than available for a specific piece of clothing (eg. 3 sliders for a Top), several parts of a costume to be modified with the same RGB slider (eg. modify Top and Bottoms colours altogether), or even to make a static or dynamic hair RGB adjustable (eg. use the Headwear sliders to change hair colours).
It is even possible to make a Vanilla mod using sliders usually not available for Vanilla, such as Legwear or Cuffs ones.
The code as been written by ModGuy and is very versatile, though a bit complex if you're not experienced in ActionScript (but don't worry, adapting it to your needs is quite simple).
It has been improved by sby to add preset colours, which is a nice feature for hair mods. This code is shown in the second post.
Another code from Iago is a bit simpler, but doesn't allow to use sliders usually not available in Vanilla if you are making a Vanilla mod, or creating an RGB adjustable hair. This code is shown in the third post.
Method
- Create your rgbFill symbols as usual.
- Go in the Action window (F9), then open the Settings: Frame 1 actions (the place where templates are registered) and add one of the codes shown in examples below, adapted to you needs.
1st example
This example shows how to use the Collar RGB sliders to modify the colours of a piece of costume located in the Back layer of the Top template.
import SDTMods.*;
import flash.system.ApplicationDomain;
import flash.geom.ColorTransform;
registerMod(top);
charData = "";
modName = "";
modCreator = "";
var SDT = ApplicationDomain.currentDomain;
try
{
var g = SDT.getDefinition("g"); //Vanilla
copyRGB(g);
}
catch(ex)
{
//We're in loader, wait.
}
function initl(l) : void
{
copyRGB(l.g); //Loader
}
function copyRGB(g_ref) : void
{
var cc = g.characterControl;
top.addEventListener(Event.ENTER_FRAME, tick);
}
function tick(e)
{
var fills = g.characterControl.collarControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
top.back.rgbFill.transform.colorTransform = rgbFill;
if(fills.length < 9) return; //Check for rgbFill2
var rgbFill2 = new ColorTransform(1, 1, 1, fills[8], fills[5], fills[6], fills[7]);
top.back.rgbFill2.transform.colorTransform = rgbFill2;
}
- The name in orange needs to be the instance name of the symbol containing the rgbFill to be affected.
- To change the costume RGB slider, modify the name in pink (you can use "collar", "gag", "cuffs", "ankleCuffs", "eyewear", "panties", "armwear", "legwear", "legwearB", "bottoms", "footwear", "top", "bra", "tonguePiercing", "nipplePiercing", "bellyPiercing", "earring", "headwear").
Keep in mind that in Vanilla and the basic Loader, only "headwear", "bottoms", "legwear", "legwearB", "footwear", "collar", "cuffs" and "ankleCuffs" have two RGB sliders. - To add other layers, duplicate the parts in green/blue and modify the layer instances names in green (e.g. "top.chest").
2nd example
This example shows how to use the Headwear RGB sliders to modify the colours of hair located in the Hair Under, Dynamic Hair Under and Dynamic Hair Over templates, as well as the Tongue Piercing slider to modify the colour of a knot located in both of these Dynamic Hair templates.
import SDTMods.*;
import flash.system.ApplicationDomain;
import flash.geom.ColorTransform;
registerMod(under); //registers the HAIR_UNDER
registerMod(dunder); //registers the DYNAMIC_HAIR_UNDER (back braid)
registerMod(dover); //registers the DYNAMIC_HAIR_OVER (front braid)
charData = "";
modName = "RGB Braids 01";
modCreator = "SyntaxTerror"; //using Dante's Small Braids.
var SDT = ApplicationDomain.currentDomain;
try
{
//Vanilla
var g = SDT.getDefinition("g");
copyRGB(g);
}
catch(ex)
{
//We're in loader, wait.
}
function initl(l) : void
{
//Loader
copyRGB(l.g);
}
function copyRGB(g_ref) : void
{
var cc = g.characterControl;
under.addEventListener(Event.ENTER_FRAME, tick);
under.addEventListener(Event.ENTER_FRAME, tick2);
}
function tick(e)
{
var fills = g.characterControl.headwearControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
under.rgbFill.transform.colorTransform = rgbFill;
dover.segment0.rgbFill.transform.colorTransform = rgbFill;
dover.segment1.rgbFill.transform.colorTransform = rgbFill;
dover.segment2.rgbFill.transform.colorTransform = rgbFill;
dunder.segment0.rgbFill.transform.colorTransform = rgbFill;
dunder.segment1.rgbFill.transform.colorTransform = rgbFill;
dunder.segment2.rgbFill.transform.colorTransform = rgbFill;
if(fills.length < 9) return; //Check for rgbFill2
var rgbFill2 = new ColorTransform(1, 1, 1, fills[8], fills[5], fills[6], fills[7]);
under.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment0.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment1.rgbFill2.transform.colorTransform = rgbFill2;
dover.segment2.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment0.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment1.rgbFill2.transform.colorTransform = rgbFill2;
dunder.segment2.rgbFill2.transform.colorTransform = rgbFill2;
}
function tick2(e)
{
var fills = g.characterControl.tonguePiercingControl.getDataString().split(",");
if(fills.length < 5) return; //Check for rgbFill1
var rgbFill = new ColorTransform(1, 1, 1, fills[4], fills[1], fills[2], fills[3]);
dover.segment2.knot.rgbFill3.transform.colorTransform = rgbFill;
dunder.segment2.knot.rgbFill3.transform.colorTransform = rgbFill;
}
- This example uses the function tick for the hair colours and tick2 for the knots one. A line needs to be added in the function copyRGB.
- As the knots only have one colour to be adjustable, the check for rgbFill2 is useless.
- The method to change the RGB sliders and to add other layers is explained in the 1st example.
Troubleshooting
- If several sliders are to be used, they need to each have a specific instance name, eg. rgbFill, rgbFill2, rgbFill3, etc. (these names don't need to be the same as actual RGB fills of templates, ie. rgbFill and rgbFill2, as they are only used to identify the different symbols in your mod and will be replaced by the RGB fill names used by SDT).
- Case is important in the symbols instance names: "rgbFill" is different from "RGBfill", "top" is different from "Top", etc.
- If code is added for inexistant symbols, an issue will occur and the next symbols in the settings will not be modified and stay black.
Last edited: