Hi All,
please can someone help me with this?
I'm creating a simple drag/drop face game, the drag/drop on the mc's is powered by an external .as file, the following code is on my main timeline.
Ok, the issue I have (apart from my hideous coding) are the first two event listeners and the way I'm setting those first three variables.
The first EventListener and function is getting the name of the current clicked movie clip and storing it in the variable currentClip.
I then want to use the mc name stored in the currentClip variable to use in the hit test on the next EventListener/function down.
I get the following error:
TypeError: Error #1006: value is not a function.
at dragDropTest2_fla::MainTimeline/myFunction().
It works if I just use the MC name but not when I insert the variable which I thought would hold the MC name.
Any ideas, I'm struggling!
cheers
ActionScript Code:
var eyesArray:Array = new Array("e_blank1_mc","e_blank2_mc","e_eyes1_mc", "e_eyes2_mc", "e_eyes3_mc");
var mouthArray:Array = new Array("m_blank_mc","m_mouth1_mc", "m_mouth2_mc", "m_mouth2_mc");
var whichArray = eyesArray;
var whichPart = eyesArea_mc;
var currentClip = e_eyes1_mc;
stage.addEventListener(MouseEvent.MOUSE_DOWN, findTarget);
function findTarget(e:MouseEvent):void
{
currentClip = e.target.name;
}
stage.addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
if(currentClip.hitTestObject(whichPart)) {
trace("hit")
}
}
function assignTargets():void
{
currentClip.target = whichPart;
}
assignTargets();
stage.addEventListener(MouseEvent.MOUSE_UP, whatArray);
function whatArray(e:MouseEvent):void
{
switch (e.target.name.charAt(0)){
case "e":
trace("eyesArray chosen");
whichArray = eyesArray;
whichPart = eyesArea_mc;
break;
case "t":
trace("teethArray chosen");
whichArray = mouthArray;
whichPart = mouth_mc;
break;
}
for (var i=0; i<whichArray.length; i++)
{
if( whichArray[i].toString() == e.target.name)
{
whichPart.gotoAndStop(i);
}
}
}