• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

Type mismatch error when calling a class

I have written two classes for capturing XML data passed to my Flash movie.  The first class, "Clip", encapsulates data pertaining to a movie clip (path to a swf file, a url to use with the move, etc.).  The second class, "Clips", is intended to be a collection of Clip instances.  "Clips" uses an array to store individual instances of "Clip".

The class, "Clip", has been tested and works fine.
The class, "Clips", throws a Type Mismatch Error when it attempts to create a new instance of "Clip" and push it into the array.  "Clips" is acting like it doesn't understand "Clip", although I have made sure to import it.

Why is it throwing the Type Mismatch Error?  
// class "Clip"
// file "Clip.as"
class Clip {
	// Instance variables
	private var path:String;
	private var link:String;
	public var first:String;
	private var pf:String = "clp";
	// Constructor
	function Clip(node:XMLNode) {
		// Get the path to the swf file
		path = node.childNodes[0].firstChild;
		// Get the click-link from the file to the target destination
		link = node.childNodes[1].firstChild;
	// Getters
	function getPath():String {return path;}
	function getLink():String {return link;}
	// Setters
	function setFirst(index:Number):String {
		first = pf + index;
		return (first);
// class "Clips"
// file "Clips.as"
import Clip;
class Clips {
	// Instance variables
	private var ary_clips:Array = new Array();
	// Constructor
	function Clips(node:XMLNode) {
		// Loop through the clip objects
		var i:Number;
		for(i=0; i<node.childNodes.length; i++) {
			// Add a new clip instance to the array
			var n:XMLNode = node.childNodes[i];
			var c:Clip = new Clip(n);
	// Getters
	function Count():Number {
		return ary_clips.length;
	function HasClips():Boolean {
		if(Count > 0) {
			return true;
		} else {
			return false;
	function Clip(index:Number):Clip {
		if(index >=0 and index < Count) {
			return ary_clips[index];
		} else {
			return null;

Open in new window

1 Solution
ewolsingAuthor Commented:
I solved my own problem.

The class, "Clips", contained a method called "Clip".  When I changed the name of the "Clip" method to "Item", everything worked as expected.

The moral of the story -- don't give a method the same name as a class you're also trying to use...

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now