Reply to thread

Yes, that will work.  I prefer to use PRE, because the incoming changes get passed in to your PRE method as parameters -- instead of needing to retrieve them within the body of your POST method (which feels a bit sloppy).  However, the difference is negligible in this case so use whatever fits your needs.


Here's an example which allows an arbitrary object (such as a bracelet, or a hairband, or a strand of hair) to be slaved to an arbitrary RGB slider.  Hence, adjusting the sliders for the bra (or pants, or whatever) will cause any RGBFill and RGBFill2 elements within the bracelet (or hairband, or whatever) to acquire the same coloration.


[code]

// Lookup the necessary SDT class (note: this only needs to be done once, e.g. during mod init)

var CharacterElementHelper:Class = main.eDOM.getDefinition("obj.CharacterElementHelper") as Class;


...


// Identify the target object which will be involved in the special ARGB activity

var target = TODO;    // you'll need to choose the appropriate object


// Identify the mod category whose ARGB sliders will be applied to the target

var elementHelperName:String = "braControl";    // or "topControl", "pantiesControl", "bottomsControl", etc

var elementHelper = (g.characterControl[elementHelperName] as CharacterElementHelper);


// Attach the proxy

if (elementHelper != null) {

    // Proxy the SetFill function so that we can react to any ARGB slider activity in the UI

    var setFill = (lProxy as Class).createProxy(elementHelper, "setFill");

    setFill.addPre(setFill_Special_Wrapper(target, elementHelper), false);

   

    // Perform an immediate "reaction" to ensure that the target object has the correct color-fill

    setFill_Special(target, elementHelper, elementHelper.rgb1, "rgbFill");

    setFill_Special(target, elementHelper, elementHelper.rgb2, "rgbFill2");

}


...


function setFill_Special(target:Object, elementHelper:Object, argb:Object, targetName:String = "rgbFill") : void {

    try {

        var argbTransform:ColorTransform = new ColorTransform(1, 1, 1, argb.a, argb.r, argb.g, argb.b);

        elementHelper.tryToSetFillChildren(target, targetName, argbTransform);

    } catch (myError:Error) { }

}


function setFill_Special_Wrapper(target:Object, elementHelper:Object) {

    return function(argb:Object, targetName:String = "rgbFill"):void {

        setFill_Special(target, elementHelper, argb, targetName);

    }

}

[/code]


Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.