Jojash Posted February 16, 2018 Share Posted February 16, 2018 (edited) So lately I've been playing around with making some UI elements for the HUD, which has been going pretty well except that these elements seem somewhat sluggish when I re-send messages to them (via HUDFramework). To give an example, I have an icon that pops up when the player presses a key and should then disappear if the player presses that key again. To achieve this I simply send a message to said icon and check its visibility - on the initial keypress (when the message is first sent) the icon appears promptly. However, upon subsequent keypresses there seems to be a considerable delay before the icon will disappear and reappear. Is there any way to fix this? Here's my Actionscript: package { import flash.display.MovieClip; import flash.text.TextField; import hudframework.IHUDWidget; public class CILHUD extends MovieClip implements IHUDWidget{ private static const WIDGET_IDENTIFIER:String = "CILHud.swf"; public var LeftLegSymbol:MovieClip; public var LeftArmSymbol:MovieClip; public var RightLegSymbol:MovieClip; public var RightArmSymbol:MovieClip; public var Torso01Symbol:MovieClip; public var Torso02Symbol:MovieClip; public var HeadSymbol:MovieClip; public var EmptySymbol:MovieClip; public var TeleporterLocation:MovieClip; public var ArmourLocation:MovieClip; public var HologramLocation:MovieClip; public var ShieldLocation:MovieClip; public var PsidisrupterLocation:MovieClip; public var VampiricLocation:MovieClip; public var TeleporterName:TextField; public var ArmourName:TextField; public var HologramName:TextField; public var ShieldName:TextField; public var VampiricName:TextField; public var PsidisrupterName:TextField; public var TeleporterNumber:TextField; public var ArmourNumber:TextField; public var HologramNumber:TextField; public var ShieldNumber:TextField; public var VampiricNumber:TextField; public var PsidisrupterNumber:TextField; public var ShieldSymbol:MovieClip; public var ShieldBar:MovieClip; public var ShieldContainer:MovieClip; public var Hologram01Symbol:MovieClip; public var Hologram02Symbol:MovieClip; public var PsidisrupterSymbol:MovieClip; private static const Command_Initialize:int = 100; private static const Command_AssignLocations:int = 110; private static const Command_UpdateImplantHealthTeleporter:int = 200; private static const Command_UpdateImplantHealthArmour:int = 210; private static const Command_UpdateImplantHealthHologram:int = 220; private static const Command_UpdateImplantHealthShield:int = 230; private static const Command_UpdateImplantHealthVampiric:int = 240; private static const Command_UpdateImplantHealthPsidisrupter:int = 250; private static const Command_ShowPsidisrupter:int = 300; private static const Command_HidePsidisrupter:int = 310; private static const Command_UpdateShield:int = 400; public function Main() {} public function processMessage(command:String, params:Array):void { switch(command) { case String(Command_Initialize): LeftLegSymbol.visible = false; LeftArmSymbol.visible = false; RightLegSymbol.visible = false; RightArmSymbol.visible = false; Torso01Symbol.visible = false; Torso02Symbol.visible = false; HeadSymbol.visible = false; TeleporterName.visible = false; ArmourName.visible = false; HologramName.visible = false; VampiricName.visible = false; ShieldName.visible = false; PsidisrupterName.visible = false; TeleporterNumber.visible = false; ArmourNumber.visible = false; HologramNumber.visible = false; VampiricNumber.visible = false; ShieldNumber.visible = false; PsidisrupterNumber.visible = false; ShieldSymbol.visible = false; ShieldBar.visible = false; ShieldBar.stop(); ShieldContainer.visible = false; Hologram01Symbol.visible = false; Hologram02Symbol.visible = false; PsidisrupterSymbol.visible = false; break; case String(Command_AssignLocations): switch(int(params[0])) { case int(0): switch(int(params[1])) { case int(-1): TeleporterLocation = EmptySymbol; break; case int(0): TeleporterLocation = HeadSymbol; break; case int(1): TeleporterLocation = LeftArmSymbol; break; case int(2): TeleporterLocation = LeftLegSymbol; break; case int(3): TeleporterLocation = RightArmSymbol; break; case int(4): TeleporterLocation = RightLegSymbol; break; case int(5): TeleporterLocation = Torso01Symbol; break; case int(6): TeleporterLocation = Torso02Symbol; break; } break; case int(1): switch(int(params[1])) { case int(-1): ArmourLocation = EmptySymbol; break; case int(0): ArmourLocation = HeadSymbol; break; case int(1): ArmourLocation = LeftArmSymbol; break; case int(2): ArmourLocation = LeftLegSymbol; break; case int(3): ArmourLocation = RightArmSymbol; break; case int(4): ArmourLocation = RightLegSymbol; break; case int(5): ArmourLocation = Torso01Symbol; break; case int(6): ArmourLocation = Torso02Symbol; break; } break; case int(2): switch(int(params[1])) { case int(-1): HologramLocation = EmptySymbol; break; case int(0): HologramLocation = HeadSymbol; break; case int(1): HologramLocation = LeftArmSymbol; break; case int(2): HologramLocation = LeftLegSymbol; break; case int(3): HologramLocation = RightArmSymbol; break; case int(4): HologramLocation = RightLegSymbol; break; case int(5): HologramLocation = Torso01Symbol; break; case int(6): HologramLocation = Torso02Symbol; break; } break; case int(3): switch(int(params[1])) { case int(-1): VampiricLocation = EmptySymbol; break; case int(0): VampiricLocation = HeadSymbol; break; case int(1): VampiricLocation = LeftArmSymbol; break; case int(2): VampiricLocation = LeftLegSymbol; break; case int(3): VampiricLocation = RightArmSymbol; break; case int(4): VampiricLocation = RightLegSymbol; break; case int(5): VampiricLocation = Torso01Symbol; break; case int(6): VampiricLocation = Torso02Symbol; break; } break; case int(4): switch(int(params[1])) { case int(-1): ShieldLocation = EmptySymbol; break; case int(0): ShieldLocation = HeadSymbol; break; case int(1): ShieldLocation = LeftArmSymbol; break; case int(2): ShieldLocation = LeftLegSymbol; break; case int(3): ShieldLocation = RightArmSymbol; break; case int(4): ShieldLocation = RightLegSymbol; break; case int(5): ShieldLocation = Torso01Symbol; break; case int(6): ShieldLocation = Torso02Symbol; break; } break; case int(5): switch(int(params[1])) { case int(-1): PsidisrupterLocation = EmptySymbol; break; case int(0): PsidisrupterLocation = HeadSymbol; break; case int(1): PsidisrupterLocation = LeftArmSymbol; break; case int(2): PsidisrupterLocation = LeftLegSymbol; break; case int(3): PsidisrupterLocation = RightArmSymbol; break; case int(4): PsidisrupterLocation = RightLegSymbol; break; case int(5): PsidisrupterLocation = Torso01Symbol; break; case int(6): PsidisrupterLocation = Torso02Symbol; break; } break; } break; case String(Command_UpdateImplantHealthTeleporter): if((params[1]) == 0) { TeleporterLocation.visible = true; TeleporterName.visible = true; TeleporterNumber.visible = true; TeleporterNumber.text = String(int(params[0])) + "%"; } else { TeleporterLocation.visible = false; TeleporterName.visible = false; TeleporterNumber.visible = false; } break; case String(Command_UpdateImplantHealthArmour): if((params[1]) == 0) { ArmourLocation.visible = true; ArmourName.visible = true; ArmourNumber.visible = true; ArmourNumber.text = String(int(params[0])) + "%"; } else { ArmourLocation.visible = false; ArmourName.visible = false; ArmourNumber.visible = false; } break; case String(Command_UpdateImplantHealthHologram): if((params[1]) == 0) { HologramLocation.visible = true; HologramName.visible = true; HologramNumber.visible = true; HologramNumber.text = String(int(params[0])) + "%"; } else { HologramLocation.visible = false; HologramName.visible = false; HologramNumber.visible = false; } break; case String(Command_UpdateImplantHealthVampiric): if((params[1]) == 0) { VampiricLocation.visible = true; VampiricName.visible = true; VampiricNumber.visible = true; VampiricNumber.text = String(int(params[0])) + "%"; } else { VampiricLocation.visible = false; VampiricName.visible = false; VampiricNumber.visible = false; } break; case String(Command_UpdateImplantHealthShield): if((params[1]) == 0) { ShieldLocation.visible = true; ShieldName.visible = true; ShieldNumber.visible = true; ShieldNumber.text = String(int(params[0])) + "%"; } else { ShieldLocation.visible = false; ShieldName.visible = false; ShieldNumber.visible = false; } break; case String(Command_UpdateImplantHealthPsidisrupter): if((params[1]) == 0) { PsidisrupterLocation.visible = true; PsidisrupterName.visible = true; PsidisrupterNumber.visible = true; PsidisrupterNumber.text = String(int(params[0])) + "%"; } else { PsidisrupterLocation.visible = false; PsidisrupterName.visible = false; PsidisrupterNumber.visible = false; } break; case String(Command_ShowPsidisrupter): PsidisrupterSymbol.visible = true; break; case String(Command_HidePsidisrupter): PsidisrupterSymbol.visible = false; break; case String(Command_UpdateShield): if((params[0]) < 0) { ShieldBar.width = 0; } else if((params[0]) > 199) { ShieldBar.width = 200; ShieldBar.visible = false; ShieldContainer.visible = false; ShieldSymbol.visible = false; } else { ShieldBar.width = int(params[0]); } if((params[1]) == 0) { ShieldBar.visible = true; ShieldContainer.visible = true; ShieldSymbol.visible = true; } else { ShieldBar.visible = false; ShieldContainer.visible = false; ShieldSymbol.visible = false; } break; } } } } Thanks in advance! :smile: Edited February 16, 2018 by Jojash Link to comment Share on other sites More sharing options...
Recommended Posts