Forum Topic: AS2 coding in frames related prob

(99 views • 10 replies)

This topic is 1 page long.

<< < > >>
None

Buster60

Reply To Post Reply & Quote

Posted at: 10/2/09 02:55 PM

Buster60 NEUTRAL LEVEL 08

Sign-Up: 04/02/08

Posts: 134

Before I explain more about my problem:
The Fla
The SWF

Now, I am making an adventure point and click game with flash AS2, using code written in the frames.
I wanted it to be arranged like that: some of the code will be only on one keyframe, which is the player/main code and will not change, and some of the code, the objects/frames code written in a special layer frames, will change every frame (every frame will represent different room with different objects). I wanted it to be arranged like that because In that way the player code isnt needed to be rewritten every frame.

It is all good on the first frame, but when the player goes over to the next frame, it gets messed up. (You can check it out in the .swf file, just right click>forward to see what happening).
In the second frame, whan the movement gets messed up, I have only erased some of the first room object related code so I dont know what the problem is.

Any ideas?
Thanks alot!

No time to make a signature yet.


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/2/09 04:03 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

I cant get access to the fla file, i need some kind of code. But your problem 'MAY' lie in the fact that the onEnterFrame () functions are overlapping, which has happened to me once or twice before. Make sure all your onEnterFrame functions are all in once single layer, and that there arent 2 in a single frame. Also, if its still a problem, just to make sure make a variable like this:

var curFrame:Number = _currentframe()

And then around everything inside your onEnterFrame just have a if statement looking like this:
if(curFrame == _currentframe()){
//code
}

cant remember if its _currentframe() or _currentFrame()

Good luck thou

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

UnknownFury

Reply To Post Reply & Quote

Posted at: 10/2/09 04:15 PM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,027

At 10/2/09 04:03 PM, Yambanshee wrote:
cant remember if its _currentframe() or _currentFrame()

_currentframe - It's a property; not a function.

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


None

tomdeaap

Reply To Post Reply & Quote

Posted at: 10/2/09 04:51 PM

tomdeaap LIGHT LEVEL 12

Sign-Up: 03/27/09

Posts: 88

<spam>

OMG, There's a dick on the wall !!

</spam>

"Insert deep, brain twisting sentence here"


None

Buster60

Reply To Post Reply & Quote

Posted at: 10/3/09 02:15 AM

Buster60 NEUTRAL LEVEL 08

Sign-Up: 04/02/08

Posts: 134

Sorry, here is the fla file: the fla
I can't find the problem from what youve told me.

and here is the code:
on the first player frame:

stop();
function onLoad() 
{
	playerDir = true;//true=right, false=left
	gotThere = true;//if the player got to the mouse
	lvrWaitForRes = false;//wait for respond for the lever
	butWaitForRes = false;//wait for respond for the button
	leverPulls = 0;
	buttonClicked=false;
	butClickChk=false;
	pComingToButFromRight=false;
	viewing=false;
}
_root.onMouseUp = function() 
{
	if(_root.treesPic._currentframe==1)
	{
		viewing=false;
	}
	storedX = _xmouse;
	gotThere = false;
	lvrWaitForRes=false;
	butWaitForRes=false;
	if(viewing==false)
  {
	if (storedX>player._x) 
	{
		playerDir = true;
	}
	if (storedX<player._x) 
	{
		playerDir = false;
	}
  }
};
_root.onEnterFrame = function() 
{  
  if(viewing==false)
  {
	if (gotThere == false) 
	{
		if (storedX>player._x) 
		{
			player._x += 5;
			if(treesPic._currentframe==1)
			{
				player.gotoAndStop(4);
			}
			if (storedX<player._x+5) 
			{
				gotThere = true;
			}
		}
		if (storedX<player._x) 
		{
			player._x -= 5;
			if(treesPic._currentframe==1)
			{
				player.gotoAndStop(3);
			}
			if (storedX>player._x-5) 
			{
				gotThere = true;
			}
		}
		if (storedX == player._x) 
		{
			gotThere = true;
		}
	}
	if (gotThere == true) 
	{
		if (playerDir == true) 
		{
				player.gotoAndStop(2);
		}
		if (playerDir == false) 
		{
			player.gotoAndStop(1);
		}
	}
	if (player._x<120) 
	{
		player._x = 120;
		gotThere = true;
	}
	if (player._x>480) 
	{
		if(ham._currentframe>3)
		{
			_root.nextFrame();
		}
		player._x = 480;
		gotThere = true;
	}
	if(player._x>button._x)
	{
		pComingToButFromRight=true;
	}
	else { pComingToButFromRight=false; 
	}
	if (_root.treesPic._currentframe==2)
	{
		viewing=true;
	}
  }
};

on the first object frame:

lever.onRelease = function() 
{
	lvrWaitForRes = true;
};
lever.onEnterFrame = function() 
{
	if (lvrWaitForRes == true) 
	{
		if (gotThere == true) 
		{
			//pulling the lever
			this.gotoAndPlay(2);
			leverPulls += 1;
			lvrWaitForRes = false;
		}
	}
};
belBut.onRelease = function() 
{
	butWaitForRes = true;
	if(pComingToButFromRight == true)
	{
		storedX+=64;
	}
	if(pComingToButFromRight == false)
	{
		storedX-=64;
	}
};
belBut.onEnterFrame = function() 
{
	if (butWaitForRes == true) 
	{
		if (gotThere == true) 
		{
			//pushing the button
			//player.swapDepths(this)
			if(pComingToButFromRight == true)
			{
				_root.button.gotoAndStop(3);
			}
			if(pComingToButFromRight == false)
			{
				_root.button.gotoAndStop(2);
			}
			if(buttonClicked==true)
			{
				buttonClicked=false;
				_root.wind.gotoAndPlay(36);
				_root.button.windInBut.gotoAndPlay(36);
			}
			else if(buttonClicked==false)
			{
				buttonClicked=true;
				_root.wind.gotoAndPlay(2);
				_root.button.windInBut.gotoAndPlay(2);
			}
			butWaitForRes = false;
		}
	}
};
wind.onRelease = function()
{
	if (buttonClicked==true)
	{
		_root.treesPic.gotoAndStop(2);
	}
}
treesPic.onRelease = function()
{
	this.gotoAndStop(1);
}
ham.onEnterFrame = function()
{
	this.gotoAndStop(leverPulls+1);
	if(leverPulls>3)
	{
		this.gotoAndStop(4);
	}
}

on the second player frame:

function onLoad() 
{
	playerDir = true;//true=right, false=left
	gotThere = true;//if the player got to the mouse;
}
_root.onMouseUp = function() 
{
	storedX = _xmouse;
	gotThere = false;
	if (storedX>player._x) 
	{
		playerDir = true;
	}
	if (storedX<player._x) 
	{
		playerDir = false;
	}
};
_root.onEnterFrame = function() 
{  
	if (gotThere == false) 
	{
		if (storedX>player._x) 
		{
			player._x += 5;
			if(treesPic._currentframe==1)
			{
				player.gotoAndStop(4);
			}
			if (storedX<player._x+5) 
			{
				gotThere = true;
			}
		}
		if (storedX<player._x) 
		{
			player._x -= 5;
			if(treesPic._currentframe==1)
			{
				player.gotoAndStop(3);
			}
			if (storedX>player._x-5) 
			{
				gotThere = true;
			}
		}
		if (storedX == player._x) 
		{
			gotThere = true;
		}
	}
	if (gotThere == true) 
	{
		if (playerDir == true) 
		{
				player.gotoAndStop(2);
		}
		if (playerDir == false) 
		{
			player.gotoAndStop(1);
		}
	}
	if (player._x<120) 
	{
		player._x = 120;
		gotThere = true;
	}
	if (player._x>480) 
	{
		player._x = 480;
		gotThere = true;
	}
};

Thank you.
Please ignore the spam on this page.

No time to make a signature yet.


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/3/09 02:53 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

Sorry, could you save the fla as a earlier flash version? ive got flash 8 and its giving me a "Unkown file format" error

At 10/2/09 04:51 PM, tomdeaap wrote:
<spam>
OMG, There's a dick on the wall !!

</spam>

OMG, theres a 3 year old on the forum

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Buster60

Reply To Post Reply & Quote

Posted at: 10/3/09 03:03 AM

Buster60 NEUTRAL LEVEL 08

Sign-Up: 04/02/08

Posts: 134

here: the fla 8
Lol, I had to compile it from flash cs4 to flash cs3 and from cs3 to flash 8.
Thanks for your time

No time to make a signature yet.


None

Buster60

Reply To Post Reply & Quote

Posted at: 10/3/09 09:36 AM

Buster60 NEUTRAL LEVEL 08

Sign-Up: 04/02/08

Posts: 134

help?

No time to make a signature yet.


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/3/09 10:24 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

got it:
Your still checking the treespic's currentframe on frame 2, and as it does int exists its always false. just remove the if(treespic._currentframe == 1) on the left and right movement of the second frame.

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Buster60

Reply To Post Reply & Quote

Posted at: 10/3/09 11:51 AM

Buster60 NEUTRAL LEVEL 08

Sign-Up: 04/02/08

Posts: 134

Thanks a lot!!!
I have removed it from one place but forgot to remove it from another.
I owe you one :)

No time to make a signature yet.


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 10/4/09 06:56 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

no problem. Another tip is that you can use the _xscale property to make him apear to be facing left or right. Just a little tip on saving frames and coding work :]

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 07:46 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!