-
problem calling function of a class
I have done this type of thing a million times before, but I cannot for the life of me figure out why it isn't working this time. As of now I have three classes: Main, UI, and Bear.
Main creates an instance of UI and puts it on the stage. UI has, among other stuff, 7 instances of the Bear class sitting on the stage. The Bear class has a public function:
Code:
public function setType(type:Number):Void
{
trace("here");
_type = type;
switch(_type)
{
case Main.NORMAL:
bear.gotoAndStop(NORMAL);
break;
case Main.BLOCKER:
bear.gotoAndStop(BLOCKER_IDLE)
break;
case Main.BOMBER:
bear.gotoAndStop(BOMBER_WALK);
break;
case Main.BOXER:
bear.gotoAndStop(BOXER_IDLE);
break;
case Main.FOIL:
bear.gotoAndStop(FOIL_WALK);
break;
case Main.GENIUS:
bear.gotoAndStop(GENIUS_WALK);
break;
case Main.JACKHAMMER:
bear.gotoAndStop(JACKHAMMER_IDLE);
break;
case Main.PARACHUTE:
bear.gotoAndStop(PARACHUTE_WALK);
break;
}
}
in an init() function of UI, I call setType on all 7 of the Bear instances so that the MovieClips associated with it will go to a frame and stop there. I get NO errors when I compile, but the setType function is never being called. I know that the class itself is being instantiated though because I can trace out from the constructor of Bear and that traces fine.
HELP... if you can please! haha
Thanks,
Kyle
-
and in case it will help, the classes
UI:
Code:
import com.teddybearfactory.*;
class com.teddybearfactory.UI extends MovieClip
{
public var bearClip0:Bear;
public var bearClip1:Bear;
public var bearClip2:Bear;
public var bearClip3:Bear;
public var bearClip4:Bear;
public var bearClip5:Bear;
public var bearClip6:Bear;
public function UI()
{
init();
}
private function init():Void
{
bearClip0.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip1.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip2.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip3.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip4.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip5.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
bearClip6.setType(Math.floor(Math.random() * Main.BEAR_TYPES.length));
}
}
and the Bear:
Code:
import com.teddybearfactory.*;
class com.teddybearfactory.Bear extends MovieClip
{
public static var NORMAL:Number = 1;
public static var PARACHUTE_WALK:Number = 25;
public static var PARACHUTE_FALL:Number = 49;
public static var BOMBER_WALK:Number = 55;
public static var BOXER_IDLE:Number = 79;
public static var BOXER_PUNCH:Number = 82;
public static var FOIL_WALK:Number = 91;
public static var BLOCKER_IDLE:Number = 115;
public static var BLOCKER_HIT:Number = 118;
public static var JACKHAMMER_IDLE:Number = 127;
public static var GENIUS_WALK:Number = 136;
public static var GENIUS_SWITCH:Number = 163;
public var bear:MovieClip;
private var _type:Number;
public function Bear()
{
}
public function test()
{
trace("test");
}
public function setType(type:Number)
{
trace("here");
_type = type;
trace(_type);
switch(_type)
{
case Main.NORMAL:
bear.gotoAndStop(NORMAL);
break;
case Main.BLOCKER:
bear.gotoAndStop(BLOCKER_IDLE)
break;
case Main.BOMBER:
bear.gotoAndStop(BOMBER_WALK);
break;
case Main.BOXER:
bear.gotoAndStop(BOXER_IDLE);
break;
case Main.FOIL:
bear.gotoAndStop(FOIL_WALK);
break;
case Main.GENIUS:
bear.gotoAndStop(GENIUS_WALK);
break;
case Main.JACKHAMMER:
bear.gotoAndStop(JACKHAMMER_IDLE);
break;
case Main.PARACHUTE:
bear.gotoAndStop(PARACHUTE_WALK);
break;
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|