Be a Supporter!

As3 Help!

  • 225 Views
  • 5 Replies
New Topic Respond to this Topic
MasterExploader
MasterExploader
  • Member since: Jun. 14, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
As3 Help! 2011-01-03 14:50:17 Reply

im trying to convert myself from AS2 to as3 .. and well im trying to make games ,but man,its haveing strange problems that I dont get :(
i wrote this:

this.addEventListener(Event.ENTER_FRAME, movesE);
function movesE(event:Event):void
{
	if (name != "enemy")
	{
		if(root.Yattack.hitTestObject(this))
		{
			removeChild(this);
		}
		if (y < 239)
		{
			y++;
		}
		if (y > 239)
		{
			y--;
		}
	}
}

root.Yattack,is the attack sprite of the main dude(dont ask why its like that)..and it just doesnt work..
this is what flash says:

Symbol 'Enemy', Layer 'Layer 2', Frame 1, Line 7 1119: Access of possibly undefined property Yattack through a reference with static type flash.display:DisplayObject.

any idea on how to make it work?

Tygerman
Tygerman
  • Member since: Aug. 16, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As3 Help! 2011-01-03 14:54:31 Reply

the "root." isn't used in AS3 it is now MovieClip(root).

also I don't think "root." was the right syntax in AS2 either, I thought it was "_root." but I could be remembering wrong


BBS Signature
MasterExploader
MasterExploader
  • Member since: Jun. 14, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to As3 Help! 2011-01-03 14:57:41 Reply

At 1/3/11 02:54 PM, Tygerman wrote: the "root." isn't used in AS3 it is now MovieClip(root).

also I don't think "root." was the right syntax in AS2 either, I thought it was "_root." but I could be remembering wrong

wow cool,(and yeah in as2 its _root,but i thought since everything in as3 is like as2 just without the "_" so it might work :P)
also for some reason the removeChild(this) line doesnt work,while im running the game and hitting the enemy this is what showes up:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/re moveChild()
at MyE/movesE()[MyE::frame1:9]

:S

Tygerman
Tygerman
  • Member since: Aug. 16, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As3 Help! 2011-01-03 15:07:54 Reply

I'm not positive about this because it's usually more complex than this but try putting MoiveClip(root). in front of removeChild(this)


BBS Signature
Innermike
Innermike
  • Member since: Sep. 11, 2009
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to As3 Help! 2011-01-03 17:03:27 Reply

Code properly, you're trying to turn AS3 into AS2, no point using AS3 if thats what you're going to do, set up a document class and shove your enemies in an array then test for your crap between the Player and them from a common parent instead of having your references all willy nilly.

it would be a start

nobody

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to As3 Help! 2011-01-03 19:11:07 Reply

The supplied DisplayObject must be a child of the caller.

parent.removeMoive(this)

Parent is the caller.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature