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){}