ewolsing
asked on
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?
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];
trace(n);
var c:Clip = new Clip(n);
c.setFirst(i);
ary_clips.push(c);
}
}
// 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;
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.