12.16.2010

Compile ActionScript file using mxmlc

Steps in compiling ActionScript file (.as) using mxmlc of Flex SDK.

Obtaining the Compiler
- To create SWF files from ActionScript, you will need a compiler, the program that interprets ActionScript code and translates it into the machine code used in SWF files. The compiler used to compile ActionScript or MXML is mxmlc.exe. mxmlc.exe can be downloaded free, just download the latest Flex SDK, and you will obtain the MXMLC.EXE.

MXMLC.EXE - can be found in SDK_PATH/bin/mxmlc.exe.

About mxmlc.exe

mxmlc.exe is a launcher that runs the MXML and ActionScript 3 compiler that converts MXML files (.mxml) and ActionScript 3 files (.as) into published SWF files (for the purposes of this tutorial, we will be primarily concerned with ActionScript 3 files though the compiler handles both as well as some other file types used in the ultimate generation of the SWF). The real compiler is a Java jar file located in the lib directory of your Flex Builder/SDK install and not mxmlc.exe itself. Because of this, to work with the compiler you'll A) need to make sure you keep all of those files of which the compiler is dependant (i.e. dont go moving around just mxmlc.exe and expect it to work), and B) need to have the Java runtime environment installed on your system. If you've installed Flex Builder you won't have to worry about this since it will take care of this for you. If you just got the SDK, however, and haven't had Java installed on your computer, you can download and install the Java runtime environment from http://java.sun.com.

In the directory containing mxmlc.exe you may notice some other executables. compc.exe is for creating SWC files (pre-compiled component file), and fdb.exe is the command line debugger. Here we are sticking to just using mxmlc.exe which is all you need to get started using ActionScript 3.

For mxmlc command line options, just visit http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html

How to compile ActionScript in mxmlc
- create a batch file. Here is a sample of batch file I used for compiling fonts.
C:\flex_sdk_4.1.0.16076\bin\mxmlc.exe -o output.swf -source-path=C:\_cafepress\devtools\manila\fonts\src\ C:\_cafepress\devtools\manila\fonts\src\font\Alepholon.as

- the ActionScript file (I used Alepholon.as here)
package font
{
import flash.display.Sprite;
import flash.text.Font;

/**
* Font library
* @author mykhel
*/
public class Alepholon extends Sprite
{

[Embed(source='../../lib/Alepholon.ttf'
,fontFamily ='Alepholon'
,fontStyle ='normal' // normal|italic
,fontWeight ='normal' // normal|bold
,unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E'
,embedAsCFF='false'
)]
public static const fontClass:Class;

public function Alepholon()
{
Font.registerFont(fontClass);
}

}

}

Note: This class is to embed font. I get this sample in one of the output file of automation tool in converting Font file (.TFF) into SWF that I have created.

- Run the batch file, and look for the output file. In my example, output file can be found in the directory of the batch file.

Download the sample files here.
Please note, I cannot include the Alepholon font, but you can try the other font. Play around with the batch file, change the path and options.

Original story here.

6.22.2010

Color Spectrum Chart AS3





Color Spectrum Chart is a AS3 tool for creating different types of color spectrum chart. It is very useful for custom color picker. This class includes ColorUtils class, another class which is useful in manipulating colors.

This is PURE CODE and PURE CALCULATION, using pixels and arrays. Absolutely no images embeded. This only requires 2-kb of filesize, and the speed is well analyzed and it is very fast.

I have no liable in other color spectrum charts or others. This class is purely coded and no tools, besides with FlashDevelop, has been used. I'm sharing this to others with no charge. Again, The images (Bitmap) that comes out after finishing this tool was not intended to copy with the others. It is only how it was output by the algo.

The AS3 file is documented well, and will easy to be use by other developer. The tutorials is in the class itself as well as in the ColorUtils class.

Source code here. (used FlashDevelop, if using Flash IDE/FLEX, just copy the src foloder and use the Main.as)
Demo here.

3.22.2010

Free 3D Panorama

Download free 3D Panorama view. I include the source code and sample files. Open the source code and play to learn more about 3Ds. I used the GreenShock's TweenLite engine for tweening animation, and Away3D for 3d engine. It is ready to use, just set the image in the flashvar to change the image.

Explanations are in the source code. Use imagePath for the flash var in HTML.

Sample flashvar:
"imagePath=test.jpg"

Credits to:
GreenShock's TweenLite - for tween engine.
Away3D - for 3d engine.

Download: (im using flashdevelop and AS3)
Free 3D Panorama

Demo:
Free 3D Panorama

If you need help, contact me through my email: mykhel0003 [at] gmail.com

3.03.2010

AS3 Tip of the Day - Saving XML/text using Flash/PHP

This tutorial will show how to save XML or TEXT file in your server using FLASH and PHP.

This is very helpful to me and I have used this many times. In one of my first project using this kind of functionality, I researched in the net, and found this solution.

AS3:

// declaring var xmlcontents String. You should set this first.
var xmlcontents:String = "this is the xml contents to be saved in your xml."

// declaring var foldername String. This is the folder container of the saved XML file
var foldername:String = "myXML."

// declaring var filename String. This is the filename of the XML file
var filename:String = "test.xml."

// declaring var dataPass URLVariables
var dataPass:URLVariables = new URLVariables();

// declaring var urlLoader URLLoader
var urlLoader:URLLoader = new URLLoader();

// declaring var previewRequest URLRequest
var previewRequest:URLRequest = new URLRequest(Main.SERVER_PATH + "saving-xml.php");

// i used method "post" in this sample. you can edit this
previewRequest.method = URLRequestMethod.POST;

// setting dataPass variables to be passed to PHP
dataPass.filename = filename;
dataPass.xmlcontents = xmlcontents;
dataPass.foldername = foldername;

// passing dataPass data PHP
previewRequest.data = dataPass;

// calling the PHP or loading the PHP
urlLoader.load(previewRequest);


PHP:

// POST variable
$fileName = $_POST["filename"];

// POST variable
$xmlContents = $_POST["xmlcontents"];

// backslashes from xml string (skip this for plain text)
$lastBackslashPos = strpos ($xmlContents, "\\");
while($lastBackslashPos >0){
$xmlContents = substr($xmlContents,0,$lastBackslashPos)
.substr($xmlContents,$lastBackslashPos+1,strlen($xmlContents));
$lastBackslashPos = strpos ($xmlContents, "\\");
}

// POST foldername
$foldername = $_POST["foldername"];

// test if the folder name is existing in the server (skip this if you want to test in server path)
if(!is_dir($foldername . "/")) {
mkdir($foldername . "/", 0755);
}

// write xml data to file on server relatively to server path of the this PHP file
$fh = fopen($foldername . "/" . $fileName, "w");
fwrite($fh, $xmlContents);
fclose($fh);
?>

Many thanks to Google.

AS3 Tip of the Day - Matrix

To those who are not yet familiar with the AS's Matrix Class, you can Google it and get yourself familiarized with it.

- If you wan't to know the matrix properties of a DisplayObject:
Example you have mc1 and mc2 in stage, and you want to copy the exact position, rotation, scale of mc1 to mc2.

var mtrx:Matrix = new Matrix();
mtrx = mc.transform.matrix; /// if you have mc in your stage, and you want to clone it's matrix and set it to other objects.
trace(mtrx);
mc2.tranform.matrix = mtrx;


cheers,
- mykhel :D

Bula Game


Game Profile








Bula Game


BulaBULA, bubble collecting game. Avoid falling black pearls and wondering fishes. Collect gold and white pearls to protect the BULA.

  • Game Dimensions: 500x460

  • Primary Category: Adventure

  • Categories: Action

  • Keywords: fish, collecting game, action game, free game, arcade game, flash game, bula, bubble, pearl

  • Rating: Everyone

  • Developer: Mykhel Trinitaria


Just added in MPTGAME.COM for sponsorship. Visit here for more strategy games,or click on the link here for more games.

AS3 Tip of the Day - flashvar

I'm creating an web flash application which requires SESSIONs if the user is login or not.

How I do it? I simply used a "flashvar" to detect if the user is login or not.

to get the parameters in flashvar see sample:

in HTML:
src="testflashvar.swf"

quality="high"
bgcolor="#000000"
width="500" height="300"
flashvars="userid=mykhel trinitaria"
name="testflashvar"
align="middle"
play="true"
loop="false"
quality="best"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">



in FLASH:

var userid:String = root.loaderInfo.parameters.userid
trace(userid); // "mykhel trinitaria"


AS3 Tips of the Day - LocalConnection AS3

AS3' LocalConnection is just the same as in AS2, only differences is the event listeners. This can be useful when it needs to communicate a AS2 to AS3, because we can't loadmovie a AS2 to AS3, or vice versa. There are other ways to use this. Hope my simple example can help others.

Sender:

package {
import flash.display.*;
import flash.events.*;
import flash.net.*;

public class Sender extends MovieClip {
private var send_lc:LocalConnection;
private var params:String = "my name is mykhel";
public function Sender():void {
/// instantiate send_lc
send_lc = new LocalConnection();

/// should have status event for testing purposes
send_lc.addEventListener(StatusEvent.STATUS, onStatus);

/// send to receiver a connection id and methods with params
/// .toString() just to make sure the receiver will be accepting a String
send_lc.send("connectId", "callBackFunction", params.toString());
}

/// instantiate rcv_lc
private function onStatus(evt:*):void {
switch (evt.level) {
case "status":
trace("LocalConnection.send() succeeded");
break;
case "error":
trace("LocalConnection.send() failed");
break;
}
}
}
}


Receiver:

package {
import flash.display.*;
import flash.events.*;
import flash.net.*;

public class Receiver extends MovieClip {
private var rcv_lc:LocalConnection;
public function Receiver():void {
/// instantiate rcv_lc
rcv_lc = new LocalConnection();

/// setting rcv_lc client to this
rcv_lc.client = this;

/// i put in a enterframe event the connect, i used this in a tandem simultaneous connect
addEventListener(Event.ENTER_FRAME, function ():void {
try {

/// rcv_lc connect with connectId (this should be unique id)
rcv_lc.connect("connecId");

} catch (error:ArgumentError) {
trace("Can't connect...the connection name is already being used by another SWF");
}
});
}

/// function to be execute passed from LC sender.
public function changeImage(str:String):void {
trace("LC CONNECTED. PARAMS: " + str);
}
}
}

AS3 Tips of the Day - removeChild()

Our Tip of the Day is DisplayObjectContainer's removeChild() method:

AS3's method removeChild() is a method of DisplayObjectContainer and Inheritance by:
-> DisplayObjectContainer -> InteractiveObject -> DisplayObject -> EventDispatcher -> Object.
-> import flash.display

removeChild() method is not the same as AS2's removeMovieClip(). This are the difference of removeChild and removeMovieClip:
1. removeChild will output and error if you use removeChild in a null object. While removeMovieClip will just ignore if there is a null.

Well, to avoid this error, here are some tips to use removeChild():
1. If you need to isntantiate a movieclip by removing it to stage before adding, but this depends on the instance. I always use this method (removing child before adding child, in some instances)
package {
import flash.display.*;
import flash.events.TimerEvent;
import flash.utils.Timer;

public class Main extends MovieClip {
var arr:Array = new Array()

public function Main():void {
/// creating Timer instance t
var t:Timer = new Timer(1000, 0);

/// add event listener to Timer t, and has a callback function onTimer()
t.addEventListener(TimerEvent.TIMER, onTimer);

/// start the Timer t
t.start();
}

/// callback function onTimer for Timer t
private function onTimer(evt:TimerEvent):void {
/// if arr.length > 5 all movieclips on stage will be removed
if (arr.length > 5) {
/// this is how to removeChild in a stage, by putting a child in a Array
for (var i:int = 0; i < arr.length; i++) {
removeChild(arr[i]);
}
/// will need to instantiate the Array arr
arr = new Array();
}

/// will need to instantiate the Array arr
var mc:Sprite = new Sprite()
mc.graphics.beginFill(Math.random() * 0xffffff);
mc.graphics.drawCircle(Math.random() * 100, Math.random() * 100, Math.random() * 20);
addChild(mc);

/// push the mc in a Array.
arr.push(mc);
}
}

}

2. removeChild by 'name'
/// addChild mc with name "myMc".
var mc:Sprite = new Sprite();
mc.name = "myMc";
addChild(mc);

Iif you want to remove the child by name used:
removeChild(getChildByName("myMc"));

3. To remove directly the instance, but if you don't know if the instance is in the stage, just use try/catch methods:
try {
removeChild(mc);
} catch (err:Error){}

2.13.2010

MPTGAME.COM

MPTGAME.COM now reaches 2000+ free online games and almost 17000+ played games in just 1 month. This is a proof that MPTGAME.COM is now ready to fly. If you are bored and stressed, just visit the websites and play more than 2000+ free online games. Click here to subscribe for the latest free online games.

MPTGAME.COM has sponsored 3 games.
The Turret Bot Defense - has a very good graphics and another addicting tower defense.
Freelancer Tower Defense - has a unique tower and maps.
Alien Bug Invader - an old arcade game which reloaded by MPTGAME.COM

MPTGAME.COM has now 34 categories.
List of categories and games per categoy (feb. 13, 2010):

To subscribe just click here.

2.06.2010

Arcade Banner Exchange

Tired of promoting your arcade sites by commenting to other pages? Well this is the solutions of how to spread and promote your sites. Register for free, and you got free impressions. If you want more impressions, they offer cheap packages and you should try it.

Here is the list:

Promise! You won't regret, because they have thousands of partners and millions of users. You can also edit your own banner. It should be 100x100 or 125x125 .jpg or .gif format. I prefer GIF format because it animates and can attract users to click the ads.

Please take a look of my sample arcade exchange banner, this was register by Mykhel Trinitaria for my website mptgame.com:




















If you are looking for arcade site which you want to sponsorized, just visit here.

2.02.2010

Turret Bot Defense on MPTGAME.COM


Game Profile









Turret Bot Defense


Defend the base from the waves of mob by building tanks and turrets on the terrain. This is addicting tower defense game

  • Game Dimensions: 640x520

  • Primary Category: Strategy

  • Categories: Action

  • Keywords: tower defense, td

  • Rating: Everyone

  • Developer: Mykhel Trintiaria


Just added in MPTGAME.COM for sponsorship. Visit here for more strategy games,or click on the link here for more games.

1.31.2010

XPOGames.com New Social Gaming Network

XPOGames.com is new social gaming network. I just try to upload 2 games with it, and I'm happy with the services, unlike with the kongregate, they don't like other ads. For those game developers/game sponsors this is the great place to expose your stuff for the amazed eyes of thousands of gamers. Online gamers with verbal abilities :-)

Their API is easy to use, and easy to integrate into your existing flash game.

The other thing which amazed me is they ask for your Google Adsense pub-id. PUB id is your identifier in Google Adsense program. After submitting the ID, every page with your game on it will serve your google on %50 of the Ad units, and XPO's on the other %50. From testing and first impressions by several underground developers I've been in touch with, Google Adsense on Flash content (+description, community buzz, tags etc.), is about $10 for 1000 ad exposure. This is cool, well I haven't reach that 1000 ad exposure but that's what I heard and read.

Xpogames is actually NewGrounds, HallPass and Kongregate all together. They're all great within their own closed borders. However, there are great communities there. with millions of gameplays per day. So if you integrate their API and upload your games, they'll get the kick start you need, the testing (and hostile I might add) environment. From my own experience, they're mostly about "will give you cash, but we will be very happy if you could you spent it here", but you don't have to. The word says it's about $2 for 1000 gameplays.

If you're looking for more flash game sites which you can upload your game, click here.

1.29.2010

Free 3D Carousel Effect AS3

I wrote a 3D Carousel Effect in AS3.

Features:
- The code is neat and easy to understand.
- It is open source so you can use it or abuse it.
- All images and names are in XML.
- It has ToolTip, too.
- Flexible in any environment: Flex or FlashDevelop or Flash IDE.

The XML I used is from my arcade site (MPTGAME.COM)

You can download the file here.

1.28.2010

Subscribe at MPTGAME.COM

Just added rss page for MPTGAME.COM

Play everyday with new games because we added newest game everyday and everynight. Subscribe now so you got everyday new game and be the first highscore with our leaderboard.

You can subscribe here:
http://mptgame.com/rss.php

1.23.2010

Freelancer.com Tower Defense

New game sponsored by MPTGAME.COM.

If you want to play a unique tower defense this is it:

Freelancer.com Tower Defense

[caption id="attachment_115" align="alignleft" width="100" caption="Freelancer.com Tower Defense"]Freelancer.com Tower Defense[/caption]

This game is not associated with the website of freelancer.com, any concerns with this websites, please visit here. I used their logo and name, because I want to spread and promote their site and new logo. I wan't paid with this one, I want to express my uniqueness for promoting this site. Because in some time, I became an avid visitor of this site. For any concerns about the other logo, please send me an email.

1.15.2010

MPTGAME.com Reaches 200+ Games

Yes!

It reaches 200+ games in just 4 days... And another good news is it reaches 1000+ playd games...

Play now for free. You can play online or you can download the file if you want to.

We have latest actions, shooting, adventure, puzzles, board game, other, and etc...

Right now our featured game is Alien Bug Invader by Mykhel Trinitaria.

Register and Subscribe now to get the latest game and updates with our sites... We offer new and latest games everyday... and targeting 1000+ games by end of January.

1.12.2010

Alien Bug Invader at MPTGAME

Just sponsor the game Alien Bug Invader in MPTGAME.COM.

Alien Bug Invader
Description: Your goal is to eliminate the alien bugs invader. There are 4 stages, and each stages has 4 different types of bug. Get the powerups to help you to eliminate the bugs.
Instructions: Eliminate all the alien bugs that attacks in four areas.

I created it this last December 2009. My plan is to sponsorized it in other games website, but changed my mind. So I just sponsor my own game, and that's is only my game. LOL

To play the game, click here.

1.11.2010

MPTGAME.COM

MPTGAME.COM is now up. We can now play mini games and flash games absolutely FREE.

MPTGAME.COM goal is to setup and install 100 great games per month... for the meantime, i just install a game i always used to.

MPTGAME.COM is open for submission of the game and i will appreciate if you'll contribute. But can't sponsored for the moment... still budgeting lol

Thanks to:

  1. AV Script for the arcade script

  2. GoDaddy.com cheap for the domain

  3. HostGator for unlimited hosting.

  4. to me ahehe

1.01.2010

AS2 and AS3 Tutorials to Create Flash Games

How to create Flash Games? Well, there are lots of tutorials can be found in Google. Just search and learn, it just needs dedication and patience. Flash is a very flexible application for building games that are both entertaining and educational and and also it can be developed both online and offline applications, too. However, the software itself is a quite tough to learn and extremely hard to master, as I said it just need dedication and patience and discipline. There are lots of websites providing free and paid tutorials of flash. Here we present you a bunch of free tutorials for game development in flash. We believe these are the best free tutorials available in Flash Game Development. And all these tutorials come with the source files.!

If you need tutorials or components for Flash Physics, just visit my previous article here. It is collection of AS2/AS3 Physics Engine.

1. Flash Racing Game Tutorial

Flash Racing Game

This is a “time trial” racing game tutorial. After completing it, you will be able to make your own racing game with custom tracks and cars, smooth collisions, lap records and more.

2. Balloon Shooter

Balloon Shooter

It is a shooting game where player / user have to shoot the flying balloons and gain the points. There are orange colored balloons, which gives player / user extra bonus points. Player / user get 1-minute time to play this game, within this period he / she need to shoot as many as balloons he / she can. For every missed balloon, separate score is maintained.

3. Guess Next

Guess Next

GuessNext, a simple card game with highscores.

4. Space Shooter

Space Shooter

Its a series of tutorials on how to develop Space Shooter game.

5. Platform Game Tutorial Redux: All The Basics

Platform Game Tutorial

This tutorial will show you all the basics of creating a platform game, Collisions that automatically move up slopes, Jumping, Moving, Simple Scrolling, Basic AI, and health

6. Make a dynamic hangman game with XML and ActionScript

Hang man

This tutorial is intended for intermediate or advanced users of ActionScript. Before continuing with this lesson, you should already know some fundamental ActionScript concepts, such as variables, if/else conditional logic, for loops, function basics, paths, dynamic text fields and movie clip events.

7. Snake Game Tutorial

Sanke Game

The “snake game” (it has several names) is one of the simplest game concepts ever, and just like Tetris it’s very addictive. There are a lot of variations of this game written in Flash, and this tutorial will explain one way to create it. It’s a relatively easy game to code, but many fail to make sure that when keys are pressed in rapid succession they are all registered. This is necessary if you want to have full control of the snake at all times.

8. Create a survival horror game in Flash tutorial

Horror Game

From Wikipedia: Survival horror is a video game genre in which the player has to survive against often undead or otherwise supernatural enemies, typically in claustrophobic environments and from a third-person perspective. This is the tutorial of a new and very funny game that introduce some concepts I’ve never seen before in a Flash game.We’ll learn how to create the engine for a survival horror game.

9. Creating a Flash Lite Game Tutorial (Flash game for Mobile Devices)

Develop your own Flash Mobile Game

The game we will create is a very basic arcade game, the player merely collects the objects before they reach the ground. If he fails to collect three objects then the game ends. This tutorial will teach you how to create a Flash Lite game playable on the Flash Lite Player version 1.1 – one of the earliest versions and most restricted, but the most widely spread version as well. Our basic game could be created without using the advanced features provided in later versions. Adopting Flash Lite 1.1 will guarantee that the game will be compatible with the largest possible number of Flash Lite powered devices.

10. Flash dodge ball game

Dodge Game

This tutorial teaches to create a dodge ball game in Flash. This is going to be a very long tutorial so even newbies should be able to follow it, and hopefully learn a lot, and to see how easy it is to make games in Flash. It is divided into 7 parts, from making of the character to getting points.

11. Create a flash artillery game

Artillary Game

This tutorial teaches you to create a flash artillery game. Something like Worms. Or similar.

12. Creating a Sniper Game in Flash

Snipper Game

It teaches you to create a Snipper Game in Flash. The step by step tutorial will be very helpful for you to create similar games in future..

Part 1- http://www.worldfaction.com/forums/showthread.php?t=44

Part 2- http://www.worldfaction.com/forums/showthread.php?t=48

Part 3- http://www.worldfaction.com/forums/showthread.php?t=63

13. Chicken and Eggs Game

Checken and Eggs

This tutorial going to teach you create one of the most popular game in Flash – Chicken and Eggs This tutorial only explain the logic used by the game and will not go into creating the graphics. You will need to change the used Movie Clip graphics to personalize the game to your liking. Also remind you that using the same graphics of the original game could be illegal.

14. Mini Car Race Game

Mini Car Race Game

People show you how to make your car move, or a car with boundarys – but you may wonder how to make your own mini-game.. good animaters will find the CPU part alot easier by the way.

15. Flash ball game with visual effects

Flash Ball Game

This tutorial I’ll cover two types of gameplay: one with the ball that runs on a static stage, and one with a fixed ball with a scrolling stage. We’ll see the pros and cons of both type of games.First of all, you have to take your ball to the exit of each level avoiding any kind of traps.

16. Flash Fighting Game tutorial

Fighting Game

Learn how to make a Fighting Game with this simple and good tutorial. Learn how to make HP bars, hitTest function and more

17. Simple Jigsaw Puzzle Tutorial

Jigsaw Puzzle

The aim of the project is to demonstrate the object oriented capabilities of Flash. This is a simple four piece jigsaw puzzle, programmed with ActionScript. The coding is done in such a way that new puzzles can be created using the same file, with very little effort.

18. Basic Flash Hit Game Tutorial (Video Tutorial for Beginners)

Hit Game Tutorial

This tutorial teaches how to Create a character, move it, create buttons, basic hitting, and use health bar.

19. Create a flash game like Security 2

Security Game

This is one of the interesting games in Flash which is created in logic of the game Security 2 . It’s a simple game: navigate through a level by using the arrow keys avoiding security traps and guards. This one is easy do develop but so interesting about artificial intelligence.

20. Complete Flash pool game with high scores

Pool Game

This is one of the very latest flash game developed by Alejadro Quarto, from Argentina. You can download the source file from the blog of Emanuele Feronato. Alejandro made this game in a day! The step by step tutorial is yet to be published. Still you can download the source file now.