abcpiano Posted January 24, 2022 Posted January 24, 2022 I have a widget mod that displays current health, stamina and magica with a swf file, it's always visible. In the widget script I have a snippet from SKI_WidgetBase function fadeOut(float a_alpha, float a_duration) float[] args = new float[2] args[0] = a_alpha args[1] = a_duration UI.InvokeFloatA(HUD_MENU, WidgetRoot + ".fadeOut", args) endFunction I need the widget icons to fade out when one of those 3 corresponding attributes is full, like with the vanilla meters. I tried doing it with PlayerRef.GetActorValuePercentage, but that means constant registering for updates, I couldn't figure out how to set it up properly. Is there a way to call directly on the vanilla meters like iHUD does it and then use FadeTo for it?
blank_v Posted January 24, 2022 Posted January 24, 2022 How ur AS Script looks? How fadeOut Function looks? Its hard to tell anything if u show so little of ur code... In AS u should do <Element>.Alpha = X Where X is value between 0.0 and 1.0 ( for full visible ) I'm not rly good with AS / Flash all im able to do is some simple pop in / out widgets What values u trying to send via a_alpha? if u trying between 100.0 and 0.0 or 255.0 to 0.0 maybe try 1.0 to 0.0 ? im nearly 100% sure its 1 - 0 range :x
abcpiano Posted January 24, 2022 Author Posted January 24, 2022 Thank you for the reply. Do you need the entire script or just specific part? this is the alpha function in AS Spoiler function fadeOut(a_alpha, a_duration) { var _loc2_ = Math.max(0,a_duration || 0); this.currTween.stop(); delete this.currTween; this.currTween = new mx.transitions.Tween(this,"_alpha",mx.transitions.easing.None.easeNone,this._alpha,a_alpha,_loc2_,true); } The fadeOut function is just Widget.FadeOut(0, 1.0) I'm sure that a_alpha value of 1 is full visibility and 0 is invisible, so it's on 0, then it takes 1 second to fade out. The thing is, I don't know how to trigger it when health/stamina/magicka is full. Should I put it OnUpdate event like this? Spoiler Bool bKeepUpdating = True Float Property fUpdateRate = 1.5 Auto Event OnInit() Debug.Notification("Initialized") If bKeepUpdating RegisterForSingleUpdate(fUpdateRate) endIf EndEvent Event OnUpdate() if PlayerRef.GetActorValuePercentage("Health") = 1.0 Debug.Notification("Player health is tracked") Widget.FadeOut(0, 1.0) endIf if PlayerRef.GetActorValuePercentage("Health") <= 0.99 Debug.Notification("No more updates") bKeepUpdating = False endIf If bKeepUpdating RegisterForSingleUpdate(fUpdateRate) endIf EndEvent If I don't add bKeepUpdating, it will just fire constantly when at max health, but when added it should turn the registering off when bellow 99 percent health.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.