Be a Supporter!

Another actionscript problem...

  • 321 Views
  • 5 Replies
New Topic Respond to this Topic
kickassman1
kickassman1
  • Member since: Feb. 20, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Another actionscript problem... 2009-03-09 04:10:08 Reply

Ok basically, I have a major problem, but hopefully by solving this one I can solve the big big big problem...

function CheckForWeapon() {
	if (Xen.hitTest("Samurai_Sword") and Xen.crouch) {
		removeMovieClip("Samurai_Sword");
		Xen.attachMovie("Samurai_Sword","weapon",9);
		Xen.gotoAndStop("PickUp");
		Xen.pickup = true;
		Xen.weaponheld = true;
	}
}

Now firstly when Xen crouches over the sword, it should remove the sword, however it doesn't I am hoping someone on these forums can gimme a hand.

Thanks in advance.

Patcoola
Patcoola
  • Member since: Mar. 7, 2003
  • Offline.
Forum Stats
Member
Level 60
Animator
Response to Another actionscript problem... 2009-03-09 04:53:04 Reply

i dont think there anything wrong with the code, but do mine that object "Samurai_Sword" most have a assigned or positive depth in order for the removeclip function to work with this object.

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Another actionscript problem... 2009-03-09 06:27:37 Reply

At 3/9/09 04:10 AM, kickassman1 wrote: function CheckForWeapon() {
if (Xen.hitTest("Samurai_Sword") and Xen.crouch) {
removeMovieClip("Samurai_Sword");
Xen.attachMovie("Samurai_Sword","weapon"

,9);

Xen.gotoAndStop("PickUp");
Xen.pickup = true;
Xen.weaponheld = true;
}
}

The sword actually has the Instance Name "weapon" when you attach it, not "Samurai_Sword". So as far as I can see, you should be using

weapon.removeMovieClip();

rather than

removeMovieClip("Samurai_Sword");

Also, as Patcoola says, if the weapon wasn't attached with AS in the first place, you'll need to do a swapDepths(78910); first to make it accessible for the deletion


- - Flash - Music - Images - -

BBS Signature
kickassman1
kickassman1
  • Member since: Feb. 20, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Another actionscript problem... 2009-03-09 13:20:08 Reply

But i didn't place the sword inside the stage.

_root.attachMovie("Samurai_Sword","Samurai_Sword",9,{_x:250, _y:300});

And I have made sure that the sword is called Samurai_Sword.

Xen.attack = false;
Xen.step = 7;
Xen.step2 = 5;
Xen.stance = 1;
Xen.crouch = false;
keydown = false;
Xen.pickup = false;
Xen.weaponheld = false;
Xen.movement = false;
Xen.weapon = false;

These are my startup variables. Everything is done inside the frame.

kickassman1
kickassman1
  • Member since: Feb. 20, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Another actionscript problem... 2009-03-10 01:38:20 Reply

bump

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Another actionscript problem... 2009-03-10 05:20:21 Reply

Really not sure. Try

Samurai_Sword.removeMovieClip();


- - Flash - Music - Images - -

BBS Signature