Error 1034

12 posts

Flag Post

Hey guys, I have trouble with error 1034.

I have a class I use for all my buttons, called ExButton (extends SimpleButton), and I have a button in the library linked for actionscript as PhaseTest. In the properties section, I set ExButton to be the base class instead of SimpleButton.

I also have a movieclip called “CreateCharacter” in the library, linked for AS. Inside that movieclip, there are a few PhaseTest buttons. I have another movieclip called Inventory. This movieclip does also contain instances of PhaseTest. This movieclip is not linked for scripting.

Everything works fine, the button inherits the properties from ExButton etc. The problem comes when I link Inventory for AS. When I create a instance of CreateCharacter and add it to stage, I get this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@5175f0f9 to PhaseTest.

It bugs out even before Inventory is used for the first time. The fact that I link Inventory for scripting makes the error come.

Can someone please explain me exactly what this error is?

Ps. My stage is empty, everything is added to stage by scripts, and all scripts are placed in classes.

 
Flag Post

https://support.trionworlds.com/app/answers/detail/a_id/915/~/how-to-fix-error-1034

 
Flag Post
Originally posted by claytronweber:

https://support.trionworlds.com/app/answers/detail/a_id/915/~/how-to-fix-error-1034

I use Mac, I don’t have any Anti-Virus or Firewall applications.

Anyway, how does this affect my code?

 
Flag Post

Sounds like you’re attaching the wrong AS class to the wrong movie clip, so your AS is looking for a PhaseTest and there is a clip of the same name of a different type (SimpleButton) in the clip you actually attached it to.

 
Flag Post

Sounds reasonable, but why would would it not give error when the Inventory Class is not in use?

 
Flag Post

Originally posted by ehaugw:

Sounds reasonable, but why would would it not give error when the Inventory Class is not in use?

why would it? not using something is not wrong (otherwise it’d complain about the thousands of unused built-in classes). you just need to start compiling in debug mode to find out what line is throwing the error so you can see what’s going wrong where.

 
Flag Post

code or it didn’t happen.

No but on a more serious note, it would be more helpful to us to see what line of code you are using that is trying to retrieve this beast. Its looking for the wrong kind or returning the wrong kind of beast attempting to convert it to another type and failing to do us, throwing the error.

So… Run. In. Debug. Mode.
I daresay I never run in anything but debug mode until the very end where I ready it for publishing.

 
Flag Post
Originally posted by alecz127:

code or it didn’t happen.



//Inventorty class:

package  {
	
	import flash.display.MovieClip;
	
	
	public class Inventory extends ExMovieClip {
		
		
		public function Inventory() {
			
		}
		
	}
	
}


//ExButton class:

package  {
	
	import flash.display.SimpleButton;
	
	
	public class ExButton extends SimpleButton {
		
		public function ExButton() {
		}
		
		var registeredevents:Array = [];
		public function registerEvent(eventID, functionID):void {
			registeredevents.push([eventID, functionID])
			addEventListener(eventID, functionID)
		}
	}
}


//Phase test class:

package  {
	
	import flash.display.SimpleButton;
	
	
	public class PhaseTest extends ExButton {
		
		
		public function PhaseTest() {
			// constructor code
		}
	}
	
}


// Create character class:

package  {
	
	import flash.display.MovieClip;
	import flash.events.*
	
	public class CreateCharacter extends ExMovieClip {
		
		public function CreateCharacter() {
			onload()
			portrait.gotoAndStop(5);
			portrait.gender.gotoAndStop(1);
			portrait.gender.char.gotoAndStop(10);
		}
	}	
}

 
Flag Post

Most likely your buttons on Inventory are not of PhaseTest but of SimpleButton class. Maybe reattach them to that Inventory?

 
Flag Post

They are added to the inventory movieclip before compiling, so it should be of PhaseTest class automatically.

The cool question is how does the inventory affect the CreateCharacter stuff even when it’s not loaded?

 
Flag Post

I solved it by putting the buttons inside a movieclip, and linking this movieclip for AS instead of the button. This 1034 error is so damn unpredictable!

 
Flag Post

Well, I don’t have the luxury to put assets on stage by graphics design utility, so I lack this unpredictability of Adobe Flash, because I then have complete control over everything via code.

var someAsset:INeedThisAssetNow=new INeedThisAssetNow(theParams);
someAsset.x=the_X;
someAsset.y=the_Y;
someAsset.otherParams=whateverOtherParamsINeedThisAssetToHave;
someAssetsDesignedParent.addChild(someAsset);

That’s it, simple and elegant. Complete control at the cost of several lines of code.