No announcement yet.

Problems loading assets into HUD

  • Filter
  • Time
  • Show
Clear All
new posts

    Problems loading assets into HUD

    Hi! I want to load an image into my HUD using actionscript only. For now I've been trying to do two things and having problems with both.

    First of all, I'm having an actionscript problem - When I try to use a formatter my text simply disappears. When I don't, I face the problem with UDK having to use imported fonts, which mean I can choose between no text and black boxes.

    Secondly, when trying to import my HUD with a custom crosshair I get the following error:

    Errors while importing 'MBHHudTest.swf':

    Warning: Can't find substitution image for 'Main_crosshairPistol'.
    NOTE: Using output of gfxexport for missing files!
    What am I doing wrong? As for the image file, I've been thinking it has to do with the img type. The image embedded into the swf is a .PNG file. According to the documentation I found, Unreal doesn't support .PNG, but on the other hand, actionscript won't load .TGA or .GIF files :S

    Here's my actionscript code:
    	import flash.display.Bitmap;
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.Font;
    	import flash.text.TextFormat
    	public class Main extends Sprite 
    		private var ammoText:TextField;
    		public var weaponText:TextField;
    		private var ammoCount:int;
    		public var weaponType:String;
    		public var font1:Font;
    		[Embed(source="..\\assets\\VeraMono.ttf", fontName="Vera")]
    		private static var veraFont:Class;
    		[Embed(source = "..\\assets\\crosshair_pistol.tga")]
    		private static var crosshairPistol:Class;
    		public var crosshairPistolBmp:Bitmap;
    		public function Main():void 
    			if (stage) init();
    			else addEventListener(Event.ADDED_TO_STAGE, init);
    			graphics.drawEllipse(0, 0, 50, 20)
    			var sprite:Sprite = new Sprite();
    			font1 = new veraFont();
    			var format :TextFormat = new TextFormat();
    			format.font = "Vera";
    			format.color = 0x555555;
    			format.size = 180;
    			ammoText = new TextField();
    			ammoText.autoSize = "left"
    			ammoText.embedFonts = true;
    			ammoText.antiAliasType = flash.text.AntiAliasType.ADVANCED;
    			ammoText.defaultTextFormat = format;
    			ammoText.text = "ammotext"
    			ammoText.y = 200;
    			ammoText.text = "" + ammoCount;
    			ammoCount = 0;
    			weaponText = new TextField();
    			weaponText.text = "";
    			weaponText.embedFonts = true;
    			weaponText.antiAliasType = flash.text.AntiAliasType.ADVANCED;
    			weaponText.defaultTextFormat = format;
    			weaponText.y = 220;
    			weaponType = "";
    			crosshairPistolBmp = new crosshairPistol();
    			crosshairPistolBmp.x = 300;
    			crosshairPistolBmp.y = 200;
    		private function onEnterFrame(e:Event):void
    			ammoText.text = "" + ammoCount;
    			weaponText.text = weaponType;
    		private function init(e:Event = null):void 
    			removeEventListener(Event.ADDED_TO_STAGE, init);

    Don't use Actionscript to do this. You should be importing it into the FLA. But in general, you don't have to worry about that warning.


      The problem is that I can't afford flash and don't want to pirate it (this is for a large school project where we work in teams). I've downloaded Giotto, but I'm not sure how to import images with it.
      Is it really not possible in actionscript? I wouldn't mind the warning, only the image doesn't show up in-game at all. It imports the texture, but then it just ignores its existence.

      In addition, I'm doing this in AS3 with Flashdevelop and I'm not sure how to inject code in the same manner as with AS2 :S


        Bump .


          Download the 30 day trial of flash... also Unreal imports png all day long no worries. That warning sometimes comes up when your images for your hud are not located in the flash folder for your hud under : UDKGame>Flash>(Name of GUI)>(Name of GUI) well I'm not sure all your actionscript issues but good luck resolving them


            Thanks for your responses. By now I've started working in Flash Professional, and I can actually display text!
            I've encountered another, Actionscript-related issue, however. For some reason, I can't get text to update using the script. I can set it directly in the textfield, but not through code. I'm positive the text field is dynamic:


            This is the code for updating my dynamic text field:
            var AmmoC = 0;
            var WeaponT = "";
            AmmoCount.focused = true;
            	AmmoC = AmmoC+1;


              Not sure the problem but looks like you're trying to add a string to an int @ AmmoCount.text=""+AmmoC; and possibly need to convert the int to a string first with AmmoC.toString(); As for .text looks fine... not sure cause I usually set things from unrealscript using SetText