Orbit

Multiplayer , | 4 Comments

Orbit is a development framework to create real-time multi-user multi-device applications. Applications can be written with a platform-agnostic API which fits perfectly in your development environment.

Orbit is network-based, so you don’t necessarily need an internet connection, but you do need a way to reach your other devices though the IP protocol. Though it’s highly preferable that you can connect directly (like multiple computers on the same LAN), it was thought to allow complex network configurations. Each user that appears on the network is an object which emits/receives messages, following a classic Observer pattern.

Sample

package aerys.helloworld
{
    import aerys.orbit.Node;
    import aerys.orbit.Session;
    import aerys.orbit.log.ConsoleLogger;
    import aerys.orbit.log.LogLevel;
    import aerys.orbit.log.Logger;
    import aerys.orbit.scheme.AttachedMessage;

    import flash.display.Sprite;
    import flash.events.Event;

    public class HelloFlashClient extends Sprite
    {
        // Create a node, associated with our generated scheme.
        private var _node       : Node      = new Node(new HelloScheme);

        public function HelloFlashClient()
        {
            addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
        }

        public function addedToStageHandler(event : Event) : void
        {
            // Set up the default logger to standard output.
            Logger.backend = new ConsoleLogger();
            // Accept any log message. Verbose.
            Logger.level = LogLevel.ALL;

            // Add an endpoint. By default, a node has none.
            _node.addEndpoint("orbit://localhost:4242");

            // Create a session, to dispatch the messages.
            var session : Session = _node.create();

            // Add a handler to detect when the session is attached to the remote node.
            session.addEventListener(AttachedMessage.ATTACHED, attachedHandler);

            // Attach the session. Stops on the first successful endpoint. Asynchronous.
            session.attach();

            // Mark the node as ready.
            _node.start();
        }

        // Define the handler, ActionScript-style.
        public function attachedHandler(message : AttachedMessage) : void
        {
            // Retrieve the Session. There are three ways of doing it:
            //  - Session.current
            //  - (message.target as Session)
            //  - Keep the result of _node.create() in an instance variable
            var session : Session = Session.current;

            // Dispatch a custom message to the server.
            session.dispatchEvent(new HelloMessage("Hey!"));
        }
    }
}

Vizzy Flash Tracer

Debug , | 2 Comments

Vizzy Flash Tracer shows debug trace of SWF files without adding any extra code. It works in Firefox, Internet Explorer, Chrome, Safari, Flash IDE, Adobe AIR and other places where trace statements exist. Vizzy is cross-platform and has all features that a developer requires for a comfortable and fast debugging.

Vizzy runs out-of-the-box and configures your environment for you to start debugging your flash applications immediately (automatic mm.cfg file creation, determining location, debug flash player detection, etc.)

Features:

  • Clear search hotkey Ctrl+E
  • JSON formatter
  • Line numbers panel
  • Source code popup on stack trace mouse right click
  • Source file opening on stack trace double click
  • FlashDevelop integratoin
  • Search keywords can be selected from drop down list
  • Daily update check changed to weekly
  • Search, Filter and Highlight All modes
  • Automatic environment configuration (mm.cfg creation, flashlog.txt detection, etc)
  • Always on Top
  • Word-wrapping
  • Cross-platform
  • Configurable Flash Player debug information
  • Windows native executable
  • Log snapshots

Trazzle

Debug , | 1 Comment

Trazzle is a Flash debugging tool. The TrazzleLib contains the ActionScript connection classes needed to talk to Trazzle. It consists of two packages, one which contains barely the interface to the second, the core. This makes it easy to keep your logging statements for later or ongoing development, while removing unneeded code and unwanted insight into your app.

Some of Trazzle features:

  • Multiple Log Levels: use different log levels to distinguish your messages by severity.
  • Bitmap logging: send any BitmapData to Trazzle to have a quick look what’s in it.
  • Performance monitoring: keep an eye on your application’s memory consumption and framerate easily.
  • Powerful filters: create complex filters to see only the messages you’re interested in.
  • Custom system menus: create system menus from within your application which can call back.
  • TextMate support: messages link back to your code optionally.

Sample

//
//  TrazzleDemoApp.as
//
//  Created by Marc Bauer on 2010-02-26.
//  Copyright (c) 2010 nesiumdotcom. All rights reserved.
//

package com.nesium{

	import com.bit101.components.Label;
	import com.bit101.components.PushButton;
	import com.nesium.ui.Menu;
	import com.nesium.ui.MenuItem;
	import com.nesium.ui.StatusBar;

	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class TrazzleDemoApp extends Sprite{

		//*****************************************************************************************
		//*                                   Private Properties                                  *
		//*****************************************************************************************
		private var m_menuItem1:MenuItem;
		private var m_menuItem2:MenuItem;
		private var m_menuItemLabel:Label;

		//*****************************************************************************************
		//*                                     Public Methods                                    *
		//*****************************************************************************************
		public function TrazzleDemoApp(){
			addEventListener(Event.ADDED_TO_STAGE, self_addedToStage);
		}

		//*****************************************************************************************
		//*                                    Private Methods                                    *
		//*****************************************************************************************
		private function startApplication():void{
			// will be displayed in trazzle's tab title
			zz_init(stage, 'Trazzle DemoApp');
			createChildren();
		}

		private function createChildren():void{
			var x:int = 100;
			var y:int = 10;
			var w:int = 200;
			var sp:int = 30;

			var btn:PushButton = new PushButton(this, x, y, 'Log all supported types',
				logAllTypesButton_click);
			btn.width = w;
			y += sp;

			btn = new PushButton(this, x, y, 'Create log message with stacktrace',
				demoStackTraceButton_click);
			btn.width = w;
			y += sp;

			btn = new PushButton(this, x, y, 'Standard trace', standardTraceButton_click);
			btn.width = w;
			y += sp;

			btn = new PushButton(this, x, y, 'Toggle performance window',
				togglePerformanceWinButton_click);
			btn.width = w;
			btn.toggle = true;
			y += sp;

			btn = new PushButton(this, x, y, 'Beep', beepButton_click);
			btn.width = w;
			y += sp;

			btn = new PushButton(this, x, y, 'Toggle System Menu', toggleMenuButton_click);
			btn.width = w;
			btn.toggle = true;
			y += sp;

			m_menuItemLabel = new Label(this, x, y, '');
			m_menuItemLabel.width = w;
			y += sp;

			btn = new PushButton(this, x, y, 'Log BitmapData', logBmpDataButton_click);
			btn.width = w;
			y += sp;
		}

		//*****************************************************************************************
		//*                                         Events                                        *
		//*****************************************************************************************
		private function self_addedToStage(e:Event):void{
			startApplication();
		}

		private function logAllTypesButton_click(e:Event):void{
			log('normal');
			log('d debug');
			log('i info');
			log('n notice');
			log('w warning');
			log('e error');
			log('c critical');
			log('f fatal');
		}

		private function demoStackTraceButton_click(e:Event):void{
			method1();
		}

		private function method1():void{
			method2();
		}

		private function method2():void{
			method3();
		}

		private function method3():void{
			logFinally();
		}

		private function logFinally():void{
			log('Here we go. Click on the small arrow to the left.');
		}

		private function standardTraceButton_click(e:Event):void{
			trace('Standard trace');
		}

		private function togglePerformanceWinButton_click(e:Event):void{
			zz_monitor(PushButton(e.target).selected);
		}

		private function beepButton_click(e:Event):void{
			zz_beep();
		}

		private function toggleMenuButton_click(e:Event):void{
			if (PushButton(e.target).selected){
				m_menuItem1 = StatusBar.systemStatusBar().addItemWithTitle('MenuItem 1');
				m_menuItem2 = StatusBar.systemStatusBar().addItemWithTitle('MenuItem 2');
				m_menuItem1.addEventListener(MouseEvent.CLICK, menuItem_click);
				m_menuItem2.addEventListener(MouseEvent.CLICK, menuItem_click);

				var submenu:Menu = new Menu();
				m_menuItem2.submenu = submenu;
				submenu.addItemWithTitle('MenuItem 2.1').addEventListener(
					MouseEvent.CLICK, menuItem_click);
				submenu.addItemWithTitle('MenuItem 2.2').addEventListener(
					MouseEvent.CLICK, menuItem_click);
				submenu.addItemWithTitle('MenuItem 2.3').addEventListener(
					MouseEvent.CLICK, menuItem_click);
				submenu.addItemWithTitle('MenuItem 2.4').addEventListener(
					MouseEvent.CLICK, menuItem_click);
			}else{
				StatusBar.systemStatusBar().removeItem(m_menuItem1);
				StatusBar.systemStatusBar().removeItem(m_menuItem2);
			}
		}

		private function menuItem_click(e:Event):void{
			var item:MenuItem = MenuItem(e.target)
			m_menuItemLabel.text = 'MenuItem with title "' + item.title + '" was clicked.';
			item.selected = !item.selected;
		}

		private function logBmpDataButton_click(e:Event):void{
			var bmp:Bitmap = new Assets.Picture();
			log(bmp.bitmapData);
		}
	}
}

ANE-Game-Center

Air Native Extension, iOS , | 2 Comments

ANE-Game-Center is a Air Native Extension for Apple’s game center integration  on the iOS platform. Using this extension, your game will be able to perform the following actions:

  • Authenticate the local player
  • Get the local player info
  • Get the local player’s score
  • Report a score
  • Report an achievement
  • Show a leaderboard
  • Show the achievements
  • Get the local player’s friends

Sample

package
{
	import com.sticksports.nativeExtensions.gameCenter.GCLeaderboard;
	import com.sticksports.nativeExtensions.gameCenter.GCPlayer;
	import com.sticksports.nativeExtensions.gameCenter.GameCenter;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	[SWF(width='320', height='480', frameRate='30', backgroundColor='#000000')]

	public class GameCenterExtensionTest extends Sprite
	{
		private var direction : int = 1;
		private var shape : Shape;
		private var feedback : TextField;

		private var buttonFormat : TextFormat;

		public function GameCenterExtensionTest()
		{
			shape = new Shape();
			shape.graphics.beginFill( 0x666666 );
			shape.graphics.drawCircle( 0, 0, 100 );
			shape.graphics.endFill();
			shape.x = 0;
			shape.y = 240;
			addChild( shape );

			feedback = new TextField();
			var format : TextFormat = new TextFormat();
			format.font = "_sans";
			format.size = 16;
			format.color = 0xFFFFFF;
			feedback.defaultTextFormat = format;
			feedback.width = 320;
			feedback.height = 260;
			feedback.x = 10;
			feedback.y = 210;
			feedback.multiline = true;
			feedback.wordWrap = true;
			feedback.text = "Hello";
			addChild( feedback );

			addEventListener( Event.ENTER_FRAME, animate );

			GameCenter.init();
			createButtons();
		}

		private function createButtons() : void
		{
			var tf : TextField = createButton( "isSupported" );
			tf.x = 10;
			tf.y = 10;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, checkSupported );
			addChild( tf );

			tf = createButton( "authenticate" );
			tf.x = 170;
			tf.y = 10;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, authenticateLocalPlayer );
			addChild( tf );

			tf = createButton( "localPlayer" );
			tf.x = 10;
			tf.y = 50;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, getLocalPlayer );
			addChild( tf );

			tf = createButton( "playerScore" );
			tf.x = 170;
			tf.y = 50;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, getPlayerScore );
			addChild( tf );

			tf = createButton( "submitScore" );
			tf.x = 10;
			tf.y = 90;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, submitScore );
			addChild( tf );

			tf = createButton( "submitAchievement" );
			tf.x = 170;
			tf.y = 90;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, submitAchievement );
			addChild( tf );

			tf = createButton( "showLeaderboard" );
			tf.x = 10;
			tf.y = 130;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, showLeaderboard );
			addChild( tf );

			tf = createButton( "showAchievements" );
			tf.x = 170;
			tf.y = 130;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, showAchievements );
			addChild( tf );

			tf = createButton( "getFriends" );
			tf.x = 10;
			tf.y = 170;
			tf.addEventListener( MouseEvent.MOUSE_DOWN, getFriends );
			addChild( tf );
		}

		private function createButton( label : String ) : TextField
		{
			if( !buttonFormat )
			{
				buttonFormat = new TextFormat();
				buttonFormat.font = "_sans";
				buttonFormat.size = 14;
				buttonFormat.bold = true;
				buttonFormat.color = 0xFFFFFF;
				buttonFormat.align = TextFormatAlign.CENTER;
			}

			var textField : TextField = new TextField();
			textField.defaultTextFormat = buttonFormat;
			textField.width = 140;
			textField.height = 30;
			textField.text = label;
			textField.backgroundColor = 0xCC0000;
			textField.background = true;
			textField.selectable = false;
			textField.multiline = false;
			textField.wordWrap = false;
			return textField;
		}

		private function checkSupported( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.isSupported:\n  " + GameCenter.isSupported;
		}

		private function authenticateLocalPlayer( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.authenticateLocalPlayer():";
			try
			{
				GameCenter.localPlayerAuthenticated.add( localPlayerAuthenticated );
				GameCenter.localPlayerNotAuthenticated.add( localPlayerNotAuthenticated );
				GameCenter.authenticateLocalPlayer();
			}
			catch( error : Error )
			{
				GameCenter.localPlayerAuthenticated.remove( localPlayerAuthenticated );
				GameCenter.localPlayerNotAuthenticated.remove( localPlayerNotAuthenticated );
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function localPlayerAuthenticated() : void
		{
			GameCenter.localPlayerAuthenticated.remove( localPlayerAuthenticated );
			GameCenter.localPlayerNotAuthenticated.remove( localPlayerNotAuthenticated );
			feedback.appendText( "\n  localPlayerAuthenticated" );
		}

		private function localPlayerNotAuthenticated() : void
		{
			GameCenter.localPlayerAuthenticated.remove( localPlayerAuthenticated );
			GameCenter.localPlayerNotAuthenticated.remove( localPlayerNotAuthenticated );
			feedback.appendText( "\n  localPlayerNotAuthenticated" );
		}

		private function getLocalPlayer( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.localPlayer:";
			try
			{
				if( GameCenter.localPlayer )
				{
					feedback.appendText( "\n  id: " + GameCenter.localPlayer.id + "\n  alias: " + GameCenter.localPlayer.alias );
				}
				else
				{
					feedback.appendText( "\n  null" );
				}
			}
			catch( error : Error )
			{
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function getPlayerScore( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.getLocalPlayerScore()";
			try
			{
				GameCenter.localPlayerScoreLoadComplete.add( localPlayerScoreLoaded );
				GameCenter.localPlayerScoreLoadFailed.add( localPlayerScoreFailed );
				GameCenter.getLocalPlayerScore( "HighScore" );
			}
			catch( error : Error )
			{
				GameCenter.localPlayerScoreLoadComplete.remove( localPlayerScoreLoaded );
				GameCenter.localPlayerScoreLoadFailed.remove( localPlayerScoreFailed );
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function localPlayerScoreLoaded( leaderboard : GCLeaderboard ) : void
		{
			GameCenter.localPlayerScoreLoadComplete.remove( localPlayerScoreLoaded );
			GameCenter.localPlayerScoreLoadFailed.remove( localPlayerScoreFailed );
			feedback.appendText( "\n  localPlayerScoreLoadComplete" );
			feedback.appendText( "\n    board category : " + leaderboard.category );
			feedback.appendText( "\n    board title : " + leaderboard.title );
			feedback.appendText( "\n    rankMax : " + leaderboard.rangeMax );
			if( leaderboard.localPlayerScore )
			{
				feedback.appendText( "\n    playerId : " + leaderboard.localPlayerScore.playerId );
				feedback.appendText( "\n    rank : " + leaderboard.localPlayerScore.rank );
				feedback.appendText( "\n    value : " + leaderboard.localPlayerScore.value );
				feedback.appendText( "\n    formattedValue : " + leaderboard.localPlayerScore.formattedValue );
				feedback.appendText( "\n    date : " + leaderboard.localPlayerScore.date );
			}
			else
			{
				feedback.appendText( "\n    no score for local player" );
			}
		}

		private function localPlayerScoreFailed() : void
		{
			GameCenter.localPlayerScoreLoadComplete.remove( localPlayerScoreLoaded );
			GameCenter.localPlayerScoreLoadFailed.remove( localPlayerScoreFailed );
			feedback.appendText( "\n  localPlayerScoreLoadFailed" );
		}

		private function submitScore( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.submitScore()";
			try
			{
				GameCenter.localPlayerScoreReported.add( scoreReportSuccess );
				GameCenter.localPlayerScoreReportFailed.add( scoreReportFailed );
				GameCenter.reportScore( "HighScore", 180 );
			}
			catch( error : Error )
			{
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function scoreReportFailed() : void
		{
			GameCenter.localPlayerScoreReported.remove( scoreReportSuccess );
			GameCenter.localPlayerScoreReportFailed.remove( scoreReportFailed );
			feedback.appendText( "\n  localPlayerScoreReportFailed" );
		}

		private function scoreReportSuccess() : void
		{
			GameCenter.localPlayerScoreReported.remove( scoreReportSuccess );
			GameCenter.localPlayerScoreReportFailed.remove( scoreReportFailed );
			feedback.appendText( "\n  localPlayerScoreReported" );
		}

		private function submitAchievement( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.reportAchievement()";
			try
			{
				GameCenter.localPlayerAchievementReported.add( achievementReportSuccess );
				GameCenter.localPlayerAchievementReportFailed.add( achievementReportFailed );
				GameCenter.reportAchievement( "started", 1 );
			}
			catch( error : Error )
			{
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function achievementReportFailed() : void
		{
			GameCenter.localPlayerAchievementReported.remove( achievementReportSuccess );
			GameCenter.localPlayerAchievementReportFailed.remove( achievementReportFailed );
			feedback.appendText( "\n  localPlayerAchievementReportFailed" );
		}

		private function achievementReportSuccess() : void
		{
			GameCenter.localPlayerAchievementReported.remove( achievementReportSuccess );
			GameCenter.localPlayerAchievementReportFailed.remove( achievementReportFailed );
			feedback.appendText( "\n  localPlayerAchievementReported" );
		}

		private function showLeaderboard( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.showStandardLeaderboard()";
			try
			{
				GameCenter.showStandardLeaderboard();
			}
			catch( error : Error )
			{
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function showAchievements( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.showStandardAchievements()";
			try
			{
				GameCenter.showStandardAchievements();
			}
			catch( error : Error )
			{
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function getFriends( event : MouseEvent ) : void
		{
			feedback.text = "GameCenter.getLocalPlayerFriends()";
			try
			{
				GameCenter.localPlayerFriendsLoadComplete.add( localPlayerFriendsLoaded );
				GameCenter.localPlayerFriendsLoadFailed.add( localPlayerFriendsFailed );
				GameCenter.getLocalPlayerFriends();
			}
			catch( error : Error )
			{
				GameCenter.localPlayerFriendsLoadComplete.remove( localPlayerFriendsLoaded );
				GameCenter.localPlayerFriendsLoadFailed.remove( localPlayerFriendsFailed );
				feedback.appendText( "\n  " + error.message );
			}
		}

		private function localPlayerFriendsLoaded( friends : Array ) : void
		{
			GameCenter.localPlayerFriendsLoadComplete.remove( localPlayerFriendsLoaded );
			GameCenter.localPlayerFriendsLoadFailed.remove( localPlayerFriendsFailed );
			feedback.appendText( "\n  localPlayerFriendsLoadComplete" );
			if( friends.length == 0 )
			{
				feedback.appendText( "\n    player has no friends" );
			}
			else
			{
				for each (var friend : GCPlayer in friends )
				{
					feedback.appendText( "\n    id : " + friend.id + ", alias : " + friend.alias );
				}
			}
		}

		private function localPlayerFriendsFailed() : void
		{
			GameCenter.localPlayerFriendsLoadComplete.remove( localPlayerFriendsLoaded );
			GameCenter.localPlayerFriendsLoadFailed.remove( localPlayerFriendsFailed );
			feedback.appendText( "\n  localPlayerFriendsLoadFailed" );
		}

		private function animate( event : Event ) : void
		{
			shape.x += direction;
			if( shape.x  320 )
			{
				direction = -1;
			}
		}
	}
}

Assets Pack #11 – Moderna Graphical Interface

Assets , | 1 Comment

This is the Moderna Graphical Interface pack (original link) created by Jorge Avila, from opengameart.org. The pack is composed of health and mana bar, vault window, quest window, spells window, quick spellsbar, system icons for “character, vault, spells, configuration and chat”.

License

This  pack is licensed under the Creative Commons Attribution 3.0 License.

Art attributions

If you use this pack, please include the following attribution in a visible location along with any other credits:

"Moderna Graphical Interface" art by Jorge Avila (opengameart.com)

When possible link to blog post that discusses the original art collection. For this asset pack, it would be ”Moderna Graphical Interface” art by Jorge Avila (OpenGameArt.org)

About the artist

Jorge AvilaJorge Ávila

Hola, soy Jorge, diseñador, artista, novio, estudiante, hijo, hermano, amigo, adulto, niño.