Type mismatch error when calling a class

Posted on 2008-11-13
Last Modified: 2013-11-11
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 ""


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 ""


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

Question by:ewolsing
    1 Comment

    Accepted Solution

    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

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to how to record live broadcast.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now