TextField Replacing é with é in Adobe Flash

  • Embedding Fonts didn’t work
  • Not Able to reproduce problem in StandAlone Example
  • Got Post online that it’s converting text into UTF-8, but didn’t get any solution on how to resolve it
  • In trace it was displaying é but in textField it was Ã©
  • I was loading data from feed and saving it to XML, tried firstChild.nodeValue and lot of thing related to XML but didn’t work
  • Tried search/replace but indexOf(“é”) was -1, though indexOf(“é”) returning position of é
  • Commenting System.useCodePage = true; worked like magic 

Reference pages

http://www.phpcs.com/codes/CONVERSION-CARACTERES-SPECIAUX-UTF-EXPORT-DANS-WORD-EXCEL_33814.aspx

http://www.weblogism.com/item/270/why-does-e-become-a

If you have better solution please post in comment. 

Some Useful Flash API

Google Map

This API allows you to add interactive Google Map in your flash content. This API is not only alternative to JavaScript map API, but it also provides ability to mix flash content with Google Maps (like using MovieClips as marker).

Documentation and download: http://code.google.com/apis/maps/documentation/flash/

YouTube API

This API is useful to integrate YouTube content in flash unit. There are separate APIs for data, Player, Custom player, Widgets.

Documentation and download: http://code.google.com/apis/youtube/overview.html

Papervision 3D

Papervision is most popular open source realtime 3D engine for Flash.

Download: http://code.google.com/p/papervision3d/

Sandy3D

Sandy3D is another open source 3D API for flash AS2, AS3.

This 3D engine main features are :

  • Viewing volume clipping for perfect interior scenes rendering
  • Advanced shading effects such as (Phong, Gouraud, CelShading, flat shading).
  • Material system to easily change your objects appearance. Several material are available allowing to create transparent faces, bitmap texture and video texture as webcam video stream.
  • Flash player 7 to 10 compatibility.
  • Complete set of parsers to handle various set of 3D formats (Collada, 3DS, ASE, MD2)
  • Several 3D primitives, allowing fast and parameterized object creation without any 3D modelisation knowledge.

Download: http://flashsandy.org/download

Away3D

Away3D is next generation realtime 3D engine for Flash. Away3D is very advanced and uses GPU rendering, Create stunning 3D environments with highly detailed texture, Animate and transform all types of 3D objects, including 3D Text, Get the best performance from the Flash Player with proven Away3D optimization techniques, without compromising on visual appeal.

Download: http://away3d.com/downloads

Facebook API

Facebook API for Flash, Flex and AIR. This is class library created by gskinner.com that communicates with Facebook using the OpenGraph API.

Download: http://code.google.com/p/facebook-actionscript-api/

More Resource: http://www.adobe.com/devnet/facebook.html

Tweener API

Tweener class is useful for creating code based dynamic animations and transitions.

Download: http://code.google.com/p/tweener/

Documentation: http://hosted.zeh.com.br/tweener/docs/en-us/

Greensock Tweening Platform

Amazing code based tweening platform for all. This is having various options like TweenNano, TweenLite, TweenMax which gives you ability to add amazing code based animation, filter effects in your project.

Most exciting part is interactive demos where you can set parameters and it will instantly gives you code.

This API is available in AS2 and AS3.

Document, Downloads and Resources at http://www.greensock.com/v11/

Box2D API

Box2D is very popular physics engine for flash game developers. It’s useful to create Ragdolls, Compound Shapes, Joints, Continuous collision detection and many more features. This can actually add life to your flash project.

Download: http://sourceforge.net/projects/box2dflash/

Documentation: http://www.box2dflash.org/docs/

Stardust Particle Engine

Stardust is wonderful particle engine for flash. It is useful for creating 2D and 3D particle effects. Some of my personal favorites are waypoints, exploding image and star fireworks.

Download and Documentation: http://code.google.com/p/stardust-particle-engine/

amMAP

AmMap is a tool that lets you have good-looking and functional maps on your website. The tool use Adobe Flash technology for a compelling online experience. You can display maps in any HTML page (web page), or inside another Flash movie. You can also use the maps in PowerPoint presentations.

Download: http://www.ammap.com/download

Documentation: http://www.ammap.com/docs/

Giggya API

Giggya is a perfect tool for sharing your flash content on social network like Facebook, Twitter, LinkedIn, Yahoo!, Google Buzz, Windows Live, opened etc.

Gigya’s “wildfire in widget” lets you add sharing in flash AS2/AS3/Flex project. Here you can select theme, choose network sites, customized height and width, show/hide bookmarks, show/hide email and customize many more features and after that all you have to do is copy code and paste is in your flash project. (you need to sign in to http://www.gigya.com/ to do this)

Documentation: http://developers.gigya.com/

WiiFlash API

Ever think of playing flash games with Wiimote? If yes, than this is the API for that. This consist of two parts WiiFlash Server (for getting input from Wiimote and send it to Flash and vice versa) and WiiFlash ActionScript API (for using Wiimote events in Flash)

Download: http://code.google.com/p/wiiflash/

FLARToolKit

FLARToolKit is a AS3 version of ARToolKit, which is a software library for building Augmented Reality (AR) applications. FLARToolKit recognize the marker from input image and calculate its orientation and position in 3D world.

Download, Resource, Examples: http://www.libspark.org/wiki/saqoosha/FLARToolKit/en

Player.IO

Player.IO is a support tool service for multiplayer game, database service, connectivity for Facebook, solution for in-game payment. It supports AS3, .NET and Unity3D.

It’s one stop solution for those who are looking for affordable multiplayer game serving.

Download: http://playerio.com/download/

Documentation: http://playerio.com/documentation/

Come2Play

Come2Play platform is for single player as well as multiplayer. It’s having features like leader board, viral messaging, in-game money, banner ads, and lobby for multiplayer games.

Download and Resources: http://www.come2play.com/developer.asp


Getting Start with Flash based Virtual World

Developing Virtual World is a huge task, but if we break the task list, here is first step.

In this example I have integrated SmartFox with OpenSpace.

Software Check List
1. SmartFox Server (http://www.smartfoxserver.com/products/)
2. Open Space Engine (http://www.openspace-engine.com/evaluate.php)
3.IIS or any local server i.e. WAMP (http://www.wampserver.com/en/download.php)

  • Install SmartFox (You can install any version of SmarFox Lit, Basic or Pro)
  • Start SmartFox Server. Programs-SmartFox Server-Start SmartFox Server
  • Start Admin Tool.  Programs-SmartFox Server-Admin-Admin Tool
  • Login Using Default Setting Server IP 127.0.0.1, Port 9339, User Name sfs_admin, Password sfs_pass
  • Click Config.xml Tab
  • Under Zones Tag Add the Following


<Zone name="openspace" uCountUpdate="true" maxUsers="200" customLogin="false">
<Rooms>
<Room name="Ranch (inside)" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
<Room name="Ranch (outside)" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
<Room name="Slopes area" maxUsers="50" isPrivate="false" isTemp="false" uCountUpdate="true" />
</Rooms>
</Zone>

  • Extract the “OpenSpace_trial.zip”  and go to the following folder “OpenSpace_trialOpenSpace_trialExamples”
  • Copy “FarWest_Ranch” and “Slopes” to loacalhost root. (C:Inetpubwwwroot)
  • Open Your browser and type “http://localhost/FarWest_Ranch/OpenSpace_tester.html” or http://localhost/Slopes/OpenSpace_tester.html” and see your character moving into virtual world.

You can edit the world using Editor Which is Located at “OpenSpace_trialEditorOpenSpaceEditor_trial.air” (You need to install it)

You can edit avatar by editing following file “OpenSpace_trialOpenSpace_trialExamplesFarWest_RanchlibrariesAvatarsLibraryExample.fla”

Shuffling Array in Flash

We often need to shuffle array in flash but flash is not having any in-built function to shuffle the array.
Here is code to shuffle the array in a simple manner.

Please convert smart quotes to normal quote before pasting the following code to flash

// Initinal Value of the Array
var aData:Array = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

trace(‘Before Shuffling : aData = {‘+aData+’}’);// Before Shuffling : aData = {1,2,3,4,5,6,7,8,9,10}

for (i=0; i<aData.length; i++) {

//This will fetch the value at random index and save it in nData
var nData:Array = aData.splice(randRange(0, aData.length-1), 1);

//This will store the nData value to end of the same array
aData.push(nData[0]);
}

trace(‘After Shuffling : aData = {‘+aData+’}’);// After Shuffling : aData = {5,6,1,3,7,10,2,9,8,4}

function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}

Using Flash with open social

Open Social is a google api for social applications across multiple websites. With standard JavaScript and HTML, we can create apps that access a social network’s friends and update feeds.

I have used social api to create the Orkut Application, and found that it’s really very very easy to build orkut app.

Here is the sample app xml which you can use to create your orkut app.

//—– XML Starts from here


<?xml version="1.0" encoding="UTF-8"?>
<Module>
 <ModulePrefs title="____YOUR_APP_TITLE____">
  <Require feature="opensocial-0.7"/>
 </ModulePrefs>
 <Content type="html"><![CDATA[
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="765" height="500" id="____YOUR_APP_ID____(This is name of your swf file with out extention, not orkut application id)" align="middle">
 <param name="allowScriptAccess" value="always"/>
 <param name="movie" value="____FULL_PATH_OF_YOUR_SWF____"/>
 <param name="quality" value="high"/>
 <param name="bgcolor" value="#ffffff"/>
 <embed src="____FULL_PATH_OF_YOUR_SWF____" quality="high" bgcolor="#ffffff" width="765" height="500" name="____YOUR_APP_NAME____" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
    ]]></Content>
</Module>

 

//—–XML Ended

 

Now some points to remember

1. When you copy this code to any editor, don’t forget to replace smart-qoute with standard quotes.

2. As Application is on your domain only use full path like http://www.yoursite.com/yourfolder/yourfile.swf for all images, mp3, js or any file used in your app.

3. Use crossdomain policy file.

//—- Save this as crossdomain.xml and put it on same folder, where your .swf recides

<?xml version=”1.0″?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd“>
<cross-domain-policy>
<allow-access-from domain=”*” />
</cross-domain-policy>

//—

Please update “allow-access-from domain” as per your need.

4. For any commnocation with social api use External Interface.

5. In object tag update “param-name” “allowScriptAccess”, from “sameDomain” to “always”

6. When you update the .xml file use &bpc=1 in URL, it will bypass the Orkut Application XML Cacheing, e.g. http://sandbox.orkut.com/Application.aspx?uid=XXXXXXXXXXXX&appId=XXXXXXXX&bpc=1

Here are some useful Links

 Getting Started Videos (Must see!!!!!!!!!!!!!!!!!!!)

http://www.youtube.com/view_play_list?p=5F0F046F77B7B62A

OpenSocial API Documentation

http://code.google.com/apis/opensocial/docs/index.html

OpenSocial API Developer’s Guide (v0.7)

http://code.google.com/apis/opensocial/docs/0.7/devguide.html

Orkut Documentation

http://code.google.com/apis/orkut/docs/index.html

Orkut Developer’s Guide

http://code.google.com/apis/orkut/docs/orkutdevguide.html

Fake Gravity Algo

Hi,

This is the fake Gravity algo. I have copied this from book “Flash MX 2004 Game Design”.

//————– Copy from here ——————-

// Object require on Stage

// ball:MovieClip – Idally with a circle or whatever you want.

var ymov:Number = 0;
//
var gravity:Number = 2;
ball.onEnterFrame = function() { 
 ymov += gravity;
 ball._y += ymov;
 if (ball._y>(Stage.height – ball._height)) {
  ball._y = Stage.height – ball._height;
  ymov *= -1;
 }
};

//————– Stop Copying ——————-

Tween Class

Tween class is preety smilple and very very useful. I have not used it till last month and after using it I always think that If I had spend 1hr on this class before 2 years, Icould make many application more interesting. (Specially some Drag & Drops)

Here is one example of Tween Class.

You need to put one movieClip named “mcObject” on Stage and paste the code in Action Layer.

//————– Copy from here ——————-

import mx.transitions.Tween;

import mx.transitions.easing.*;

//

var mcObject:MovieClip;

//

mcObject.onPress = pressHandler;

mcObject.onRelease = mcObject.onReleaseOutside=releaseHandler;

//

function pressHandler() {

//trace(“pressHandler called with [“+arguments+”]”);

this.oldX = this._x;

this.oldY = this._y;

this.startDrag();

}

//

function releaseHandler() {

//trace(“releaseHandler called with [“+arguments+”]”);

this.stopDrag();

var xTween:Tween = new Tween(this, “_x”, Bounce.easeOut, this._x, this.oldX, 5, true);

var yTween:Tween = new Tween(this, “_y”, Bounce.easeOut, this._y, this.oldY, 5, true);

}

//————– Stop Copying ——————-

You can take offical help on Tween class from here