Recent posts by Mond on Kongregate

Subscribe to Recent posts by Mond on Kongregate

avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Do Events depend on the target being on the Display List?

Gotta go cut a tree down. Thanks for the help. Good point Sene…just add something to that while loop that looks out for any special objects that require housekeeping.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Do Events depend on the target being on the Display List?

I considered weak reference. It seems like this arrow flashing routine is an excellent example of where to use it. But if it is added as a weak reference, it might be removed while running if the object is removed from the stage. In that case, any code I was expecting to run (in my example the if (myMC.parent) myMC.parent.removeChild(myMC); statement might not be executed…I realize it wouldn’t matter in my example, but there might be other code expected to run which might not run) might not run.

What other Events are independent of the Display List? EXIT_FRAME? ADDED_TO_STAGE? Is there a list somewhere in the manual?

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Do Events depend on the target being on the Display List?

A while ago I asked about these arrows I was using…

private function AddArrowForMissingData(xPos:Number, yPos:Number, type:int = 0):void
{
	var arrow:MovieClip = new RedArrowForMissingData();
	arrow.x = xPos;
	arrow.y = yPos;
	if (type) arrow.rotation = -45;
	arrow.counter = 0;	//dynamic attribute
	addChild(arrow);
	arrow.addEventListener(Event.ENTER_FRAME, FlashArrow);
}
		
private function FlashArrow(e:Event):void
{
	var myMC:MovieClip = MovieClip(e.target);
	
	if (!(++myMC.counter % 10)) myMC.visible = !myMC.visible;
	if (myMC.counter > 251)
	{
		myMC.removeEventListener(Event.ENTER_FRAME, FlashArrow);
		if (myMC.parent) myMC.parent.removeChild(myMC);
	}
}

And they work great..But during alpha testing I was wondering why they work great. While the arrows are flashing the player can leave the page where they are flashing. If that happens, this is called…

private function RemoveEverything():void
{
	stageRef.removeEventListener(Event.MOUSE_LEAVE, MouseHasLeftTheStage);
	stageRef.removeEventListener(Event.MOUSE_LEAVE, MouseExit);
			
	while (numChildren != 0) removeChildAt(0);
	if (parent) parent.removeChild(this);
}

Which removes the arrow(s) from the Display List. But if they are removed, how can they receive the ENTER_FRAME Event? Traces show that myMC.counter does become greater than 251 and the listener gets removed even though the arrow(s) is not on the Display List.

I’m glad it works, but it seems like there is something about the Event System I don’t understand.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Simple Timed Flashing Arrow and SharedObjectManager Class [AS3]

So, I may have a problem with my SharedObjectManager Class if I return from the function with…

public function OpenSO(fileName:String, definedPath:String = null, security:Boolean = false):SharedObject
{
	try
	{
		mySO = SharedObject.getLocal(fileName, definedPath, security);
	}
	catch (e:Error)
	{
		lastErrorThrown = e;
		status = "inoperable";
		status2 = "getLocal error";
		//if (mySO) mySO.clear(); if the file already exists on the hard drive this might delete it...I'm not sure though...
		
		mess =  "ERROR...";
		if (systemTest) mess += "Your Data Storage System has been tested. There is a problem. ";
		mess += "Your Operating System has thrown a ";
		mess += "GetLocal Access Error (Shared Object). ";
		mess += "This is a VERY unusual error.\n";
		mess += "You can still play the game, but the game will not be able to save your progress. ";
		mess += "You can try refreshing the WebPage ";
		if (systemTest) mess += "which will cause the Data Storage test to be performed again.";
		else mess += "and the Data Storage System will be tested.";
		WG_GameController.stageRef.addChild(new MessageBox(mess, 0x000000, 395.0, 321.0, 450, 147.0, 280.0, 1));
				
		systemTest = false;
		return null;
	}
	return mySO;
}

If I try to open two SOLs won’t I have problems. For instance,

var currentRankSO:SharedObject = SOM.OpenSO(“CurrrentRanking”);
var savedGamesSO:SharedObject = SOM.OpenSO(“SavedGames”);

because the return value (SharedObject) is pass by reference?

Edit:SOM is the only instance of my SharedObjectManager Class and mySO is a private property of that class.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Simple Timed Flashing Arrow and SharedObjectManager Class [AS3]

Thanks ya’ll. Just in case anyone is interested…

private function AddArrowForMissingData(xPos:Number, yPos:Number, type:int = 0):void
{
	var arrow:MovieClip = new RedArrowForMissingData();
	arrow.x = xPos;
	arrow.y = yPos;
	if (type) arrow.rotation = -45;
	arrow.counter = 0;	//dynamic attribute
	addChild(arrow);
	arrow.addEventListener(Event.ENTER_FRAME, FlashArrow);
}
		
private function FlashArrow(e:Event):void
{
	if (!(++e.target.counter % 10)) e.target.visible = !e.target.visible;
	if (e.target.counter > 191)
	{
		e.target.removeEventListener(Event.ENTER_FRAME, FlashArrow);
		removeChild(MovieClip(e.target));
	}
}
 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Simple Timed Flashing Arrow and SharedObjectManager Class [AS3]

There is so much to have to remember…couldn’t remember which class could have attributes/properties assigned dynamically.

While I got you reading…if a function returns a non-primitive value does it do so by reference or by value? I’m almost positive it is by reference.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Simple Timed Flashing Arrow and SharedObjectManager Class [AS3]

I want to add an arrow on the stage to show the player where he has left some inputs unspecified. But this doesn’t work because e.target is the Sprite, not the Object…

private function AddArrowForMissingData(xPos:Number, yPos:Number, type:int = 0):void
{
	var arrow:Object = new Object();
	arrow.Arrow = new RedArrowForMissingData();
	arrow.Arrow.x = xPos;
	arrow.Arrow.y = yPos;
	if (type) arrow.Arrow.rotation = -Math.PI/4;
	arrow.Counter = 0;
	addChild(arrow.Arrow);
	arrow.Arrow.addEventListener(Event.ENTER_FRAME, FlashArrow);
}
		
private function FlashArrow(e:Event):void
{
	if (!(++e.target.Counter % 5)) e.target.Arrow.visible = !e.target.Arrow.visible;
	if (e.target.Counter > 50)
	{
		e.target.Arrow.removeEventListener(Event.ENTER_FRAME, FlashArrow);
		removeChild(Sprite(e.target.Arrow));
	}
}

I get a run-time error since e.target.Counter is wrong. But how do I get to the Counter property of the Object in FlashArrow. As far as I know I can’t add dynamic properties to a Sprite (or I would put the Counter property on the Sprite and not have to create the Object at all). So other than creating a class with a counter property just for these simple arrows….

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / AS3 #1009 when i try to call a function in annother class

Most excellent…No prob.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Settings Manager Focus [AS3]...solved

Clicking on something else does remove the highlighting(?).
I always set selectable to false on TextFields. Having the cursor change to a i-beam is sooo tacky in a game. Redirecting the focus worked great. Thanks.

Highlighting takes on the alpha value of the thing being highlighted? I never noticed that before.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / AS3 #1009 when i try to call a function in annother class

If that’s the way you want to handle upgrades, that’s fine. I think with more experience you will see why the Ship Class should contain everything relevant to a ship.

As far as the error is concerned I have never seen that one before so I am not sure. But I think the problem could be solved by making the SammoLaserRed var public and static. Then the Ship Class could access it with the syntax Engine.SammoLaserRed. So from the Ship Class you would say…

ammoLaserRed = Engine.SammoLaserRed;  //Notice I use the Class name (Engine), not the var name (engine)

Using public and static in this way your getter (shipGetAmmoLaserRed) wouldn’t be necessary and your engine var in the Ship Class wouldn’t be necessary. The var would be defined in the Engine Class as…

public class Engine extends MovieClip
	{
		public static var SammoLaserRed:int = 5;
                ...
 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / AS3 #1009 when i try to call a function in annother class

It is the ship that needs to know how much ammo it has. So I am wondering why the Engine Class has the SammoLaserRed property?

However…it is probably engine that is null (a trace(engine); would have showed you that it was null). Just defining a var doesn’t mean it exists. It is necessary to instantiate. How did you instantiate the engine var in your Ship Class?

EDIT:you’re not wasting anyone’s time moller…we all started somewhere!

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / What should I learn after AS2?

If you want to develop for the Flash market, AS3. If you want to develop for the console market, C++ and OpenGL (or C++ and DirectX).

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Settings Manager Focus [AS3]...solved

Bump.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Settings Manager Focus [AS3]...solved

I have a Save button in my game which, when clicked, flushes the SO. However, when there isn’t enough space allocated on the player’s hard disk, FP invokes the Settings Manager to request more space be allocated. All fine and good…but when I click on Allow or Deny, my Save button gets an ugly black background.

I seem to recall a way to stop that background from being displayed, but I can’t find it now. Can someone point me to the right package or Class? I thought it was stage.showFocusRect = false; but that’s not it….Thanks.

EDIT:I have tried stage.stageFocusRect = false; but that didn’t stop the effect.
I have tried setting the background property to false (the button is actually a TextField) even though it was already false by default at instantiation. That didn’t help either.

I did notice that the background has the same alpha value as the TextField. When I click on Deny, my SharedObjectManager Class becomes disabled, so I disable the Save button (listeners removed and its alpha set to 0.5). That ugly background is also at 0.5.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / FlashDevelop 4.0.0 RC1 Released

On Wednesday, September 28, 2011 FlashDevelop.org released FD4.

http://www.flashdevelop.org/community/viewforum.php?f=11

Comments?
Discussion?
Opinions?

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Event Cloning Compile-Time Error [AS3]

Thanks

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Event Cloning Compile-Time Error [AS3]

Having problems compiling (FD 3.3.4 / Flex 4) this code…

		private function NetStatusEventHandlerForSystemTest(e:NetStatusEvent):void
		{
			
trace("In the testing handler");

			lastEventHandled = e.clone();
			lastCode = 1;
									
trace("&&&" + e);
trace("***" + lastEventHandled);

			if (e.info.code == " ") trace("5"); else trace("6");
			//if (lastEventHandled.info.code == " ") trace("7"); else trace("8");
		}

When I uncomment the last line I get a compile-time error of
“C:\Program Files\FlashDevelop3.3.4\Work\SharedObjectManagerDevelopment\src\SharedObjectManager.as(176): col: 25 Error: Access of possibly undefined property info through a reference with static type flash.events:Event.”

Even though the values of e and lastEventHandled trace out exactly the same (with the last line commented out it compiles and runs and traces out a “6” just like I expected it to). lastEventHandled is of type Event.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / FP Settings Access

Can my .SWF get to the FP Settings Dialog Box so I can put my game’s name in the TextField? When I am testing locally it says “local”.

When I play a game on Kong it says “chat.kongregate.com”.

Also, should I just assume that a mySO.flush() failure is due to inadequate space being provided? Has anyone ever seen any other error situations except inadequate space?

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Progress Check

Tweaking the art/alpha testing/final polish on a soon to be released game. Thanks again to saybox for beta testing it.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / [AS3] SharedObject - Am I doing this right?

If that’s how you want to handle it, that’s fine. I wouldn’t make a separate SO for each value I wanted to store, rather I would add properties to the SO’s data property…

mySO.data.goldSaved….mySO.data.currentLevel….mySO.data.currentScore….etc.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Relating RGB to ColorTransforms [AS3]

I didn’t think of setting the multipliers to 0. Thanks Draco.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Relating RGB to ColorTransforms [AS3]

I have an object which when rolled over needs to change color from 0xFFFFFF to 0×0FA4A3. So I created these CTs for this purpose, but they don’t seem to work…

public static var WhiteCT:ColorTransform = new ColorTransform(1.0, 1.0, 1.0);
public static var YellowCT:ColorTransform = new ColorTransform(15.0, 164.0, 163.0);

Even though 0F = 15, A4 = 164 and A3 = 163. The object starts out white, so when I roll over it don’t I just multiply the existing RGB values by the YellowCT values?

(BTW, I called it YellowCT because it used to turn yellow, but I’m changing the color.) They are applied with this code (simple rollover/rollout handlers)…

private function ChangeArrow(e:MouseEvent):void
{
	SoundEffects.PlaySFX("Button Rolled Over");
	e.target.transform.colorTransform = YellowCT;
	e.target.scaleX = 1.2;
	e.target.scaleY = 1.2;
}

private function ChangeArrowBack(e:MouseEvent):void
{
	e.target.transform.colorTransform = WhiteCT;
	e.target.scaleX = 1.0;
	e.target.scaleY = 1.0;
}

EDIT: oh ok, it is easier to use the offsets in this simple application…I got it. Feel free to take this thread wherever if anyone else wants to talk about it. Or the mod can delete…whatever…I must need a break…lol…

public static var YellowCT:ColorTransform = new ColorTransform(1.0, 1.0, 1.0, 1.0, -240.0, -86.0, -92.0);
 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / As3GameGears - find tools, libs and engines

Excellent repository Dovy.

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Making a game that uses scroll wheel? Read this!

When a Flash app has focus, couldn’t Kong reject any mousewheel Events..or dispatch the same Event in reverse canceling any movement in the browser?

 
avatar for Mond Mond 699 posts
Flag Post

Topic: Game Programming / Opinion On A Game

I don’t think so…but I have only loaded 2 games onto FGL so I’m not sure. I loaded it onto FGL to get First Impressions. But FIs are from players, not Developers.

EDIT: Thank you saybox…excellent ideas for improvement.

EDIT EDIT: Now I have opened up the game for Developer viewing if you have at least 1 approved game on FGL. I am Mond on FGL and the name of the game is WairGun.