Monday, March 09, 2009

Unicode versus non Unicode. Things to remember


Initial Steps for Unicode-enabling Microsoft C/C++ Source



  • Define _UNICODE, undefine _MBCS if defined.

  • Convert literal strings to use L or _T

  • Convert string functions to use Wide or TCHAR versions.

  • Clarify string lengths in API as byte or character counts. For character-based display or printing (as opposed to GUI which is pixel-based) use column counts, not byte or character.

  • Replace character pointer arithmetic with GetNext style, as characters may consist of more than one Unicode code unit.

  • Watch buffer size and buffer overflows- changing encodings may require either larger buffers or limiting string lengths. If character size changes from 1 byte to as many as 4 bytes, and string length was formerly 20 characters and 20 bytes, either expand the string buffer(s) from 20 to 80 bytes or limit the string to 5 characters (and therefore 20 bytes). Note maximum buffer expansion may be constrained (for example to 65 KB). Reducing string length to a fixed number of characters may break existing applications. Limiting strings to a fixed byte length is dangerous. For example, allowing any string that fits into 20 bytes. Simple operations such as uppercasing a string may cause it to grow and exceed the byte length.

  • Replace functions that accept or return arguments of a single character, with functions that use strings instead. (International) Operations on a single character may result in more than one code point being returned. For example, upper('ß') returns "SS".

  • Use wmain instead of main. The environment variable is then _wenviron instead of _environ.

    wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] ).

  • MFC Unicode applications use wWinMain as the entry point.

    In the Output page of the Linker folder in the project's Property Pages dialog box, set the Entry Point symbol to wWinMainCRTStartup.

  • Consider fonts. Identify the fonts that will render each language or script used.



File I/O, Database, Transfer Protocol Considerations



  • Consider whether to read/write UTF-8 or UTF-16 in files, databases, and for data exchange.

  • Consider Endian-ness in UTF-16 files.

    Read/Write Big-Endian on networks. Use Big-Endian if you don't produce a BOM.

    Endian-ness of files will depend on the file format and/or the architecture of the source or target machine.

    When reading files encoded in UTF-16 or UTF-32, be prepared to swap-bytes to convert endian-ness.

    Also consider streams and transfer protocols and the encoding used in each.

  • Label files or protocols for data exchange with the correct character encoding. E.g. set HTTP, HTML, XML to UTF-8 or UTF-16.

  • Consider Unicode BOM (Byte Order Marker) and whether it should be written with data. Remove it when reading data.

  • Consider encoding conversion of legacy data and files, import and export, transfer protocols. (MultiByteToWideChar, WideCharToMultiByte, mbtowc, wctomb, wctombs, mbstowcs )

  • Consider writing to the Clipboard-

    use CF_TEXT format and write native character encoding (ANSI) text, and

    use CF_UNICODETEXT format and write Unicode text.

  • Database applications should consider Data Type (NCHAR, NVARCHAR) and Schema Changes, Triggers, Stored Procedures, and Queries. Data Storage growth, Indexes and Performance.

    Note that the Unicode schema changes will have different impacts and concerns on different vendors' databases. If database portability is a requirement, the features and behaviors of each database need to be taken into account.

    (I know this item is seriously understated. To be expanded sometime in the future.)



Stream I/O


Streams are difficult in Microsoft C++. You may run into 3 types of problems:



  1. Unicode filenames are not supported. The workaround is to use FILE * _wfopen and if needed, use the FILE handle in subsequent stream I/O.
    std::ifstream stm(_wfopen(pFilename, L"r"));


  2. Stream I/O will convert Unicode data from/to native (ANSI) code page on read/write, not UTF-8 or UTF-16. However the stream class can be modified to read/write UTF-8. You can implement a facet to convert between Unicode and UTF-8.
    codecvt <wchar_t, char_traits <wchar_t> >


  3. To read/write UTF-16 with stream I/O, use binary opens and binary I/O. To set binary I/O:
    _setmode( _fileno( stdin ), _O_BINARY );



    Also see the Microsoft run-time library reference: "Unicode Stream I/O in Text and Binary Modes".


Note: There aren't TCHAR equivalents for cout/wcout, cin/wcin, etc. You may want to make your own preprocessor definition for "tout", if you are compiling code both ways.



Internationalization, Advanced Unicode, Platform and Other Considerations





Unicode BOM Encoding Values
















































Encoding Form BOM Encoding
UTF-8 EF BB BF
UTF-16

(big-endian)
FE FF
UTF-16

(little-endian)
FF FE
UTF-16BE, UTF-32BE

(big-endian)
No BOM!
UTF-16LE, UTF-32LE

(little-endian)
No BOM!
UTF-32

(big-endian)
00 00 FE FF
UTF-32

(little-endian)
FF FE 00 00
SCSU

(compression)
0E FE FF

The Byte Order Marker (BOM) is Unicode character U+FEFF. (It can also represent a Zero Width No-break Space.) The code point U+FFFE is illegal in Unicode, and should never appear in a Unicode character stream. Therefore the BOM can be used in the first character of a file (or more generally a string), as an indicator of endian-ness. With UTF-16, if the first character is read as bytes FE FF then the text has the same endian-ness as the machine reading it. If the character is read as bytes FF FE, then the endian-ness is reversed and all 16-bit words should be byte-swapped as they are read-in. In the same way, the BOM indicates the endian-ness of text encoded with UTF-32.


Note that not all files start with a BOM however. In fact, the Unicode Standard says that text that does not begin with a BOM MUST be interpreted in big-endian form.


The character U+FEFF also serves as an encoding signature for the Unicode Encoding Forms. The table shows the encoding of U+FEFF in each of the Unicode encoding forms. Note that by definition, text labeled as UTF-16BE, UTF-32BE, UTF-32LE or UTF-16LE should not have a BOM. The endian-ness is indicated in the label.


For text that is compressed with the SCSU (Standard Compression Scheme for Unicode) algorithm, there is also a recommended signature.




Constant and Global Variables

























ANSI Wide TCHAR
EOF WEOF _TEOF
_environ _wenviron _tenviron
_pgmptr _wpgmptr _tpgmptr



Data Types






































































ANSI Wide TCHAR
char wchar_t _TCHAR
_finddata_t _wfinddata_t _tfinddata_t
__finddata64_t __wfinddata64_t _tfinddata64_t
_finddatai64_t _wfinddatai64_t _tfinddatai64_t
int wint_t _TINT
signed char wchar_t _TSCHAR
unsigned char wchar_t _TUCHAR
char wchar_t _TXCHAR
  L _T or _TEXT
LPSTR

(char *)
LPWSTR

(wchar_t *)
LPTSTR

(_TCHAR *)
LPCSTR

(const char *)
LPCWSTR

(const wchar_t *)
LPCTSTR

(const _TCHAR *)
LPOLESTR

(For OLE)
LPWSTR LPTSTR




Platform SDK String Functions


There are many Windows API that compile into ANSI or Wide forms, depending on whether the symbol UNICODE is defined. Modules that operate on both ANSI and Wide characters, need to be aware of this. Otherwise, using the Character Data Type-independent name requires no changes, just compile with the symbol UNICODE defined.


The following list is by no means all of the Character Data Type-dependent API, just some character and string related ones. Look in WinNLS.h for some code page and locale related API.



























































































































































ANSI Wide Character Data Type-

Independent Name
CharLowerA CharLowerW CharLower
CharLowerBuffA CharLowerBuffW CharLowerBuff
CharNextA CharNextW CharNext
CharNextExA CharNextExW CharNextEx
CharPrevA CharPrevW CharPrev
CharPrevExA CharPrevExW CharPrevEx
CharToOemA CharToOemW CharToOem
CharToOemBuffA CharToOemBuffW CharToOemBuff
CharUpperA CharUpperW CharUpper
CharUpperBuffA CharUpperBuffW CharUpperBuff
CompareStringA CompareStringW CompareString
FoldStringA FoldStringW FoldString
GetStringTypeA GetStringTypeW GetStringType
GetStringTypeExA GetStringTypeExW GetStringTypeEx
IsCharAlphaA IsCharAlphaW IsCharAlpha
IsCharAlphaNumericA IsCharAlphaNumericW IsCharAlphaNumeric
IsCharLowerA IsCharLowerW IsCharLower
IsCharUpperA IsCharUpperW IsCharUpper
LoadStringA LoadStringW LoadString
lstrcatA lstrcatW lstrcat
lstrcmpA lstrcmpW lstrcmp
lstrcmpiA lstrcmpiW lstrcmpi
lstrcpyA lstrcpyW lstrcpy
lstrcpynA lstrcpynW lstrcpyn
lstrlenA lstrlenW lstrlen
OemToCharA OemToCharW OemToChar
OemToCharBuffA OemToCharBuffW OemToCharBuff
wsprintfA wsprintfW wsprintf
wvsprintfA wvsprintfW wvsprintf




TCHAR String Functions


Functions sorted by ANSI name, for ease of converting to Unicode.


























































































































































































































































































































































































































































































































































































































































































































































































































































































































ANSI Wide TCHAR
_access _waccess _taccess
_atoi64 _wtoi64 _tstoi64
_atoi64 _wtoi64 _ttoi64
_cgets _cgetws cgetts
_chdir _wchdir _tchdir
_chmod _wchmod _tchmod
_cprintf _cwprintf _tcprintf
_cputs _cputws _cputts
_creat _wcreat _tcreat
_cscanf _cwscanf _tcscanf
_ctime64 _wctime64 _tctime64
_execl _wexecl _texecl
_execle _wexecle _texecle
_execlp _wexeclp _texeclp
_execlpe _wexeclpe _texeclpe
_execv _wexecv _texecv
_execve _wexecve _texecve
_execvp _wexecvp _texecvp
_execvpe _wexecvpe _texecvpe
_fdopen _wfdopen _tfdopen
_fgetchar _fgetwchar _fgettchar
_findfirst _wfindfirst _tfindfirst
_findnext64 _wfindnext64 _tfindnext64
_findnext _wfindnext _tfindnext
_findnexti64 _wfindnexti64 _tfindnexti64
_fputchar _fputwchar _fputtchar
_fsopen _wfsopen _tfsopen
_fullpath _wfullpath _tfullpath
_getch _getwch _gettch
_getche _getwche _gettche
_getcwd _wgetcwd _tgetcwd
_getdcwd _wgetdcwd _tgetdcwd
_ltoa _ltow _ltot
_makepath _wmakepath _tmakepath
_mkdir _wmkdir _tmkdir
_mktemp _wmktemp _tmktemp
_open _wopen _topen
_popen _wpopen _tpopen
_putch _putwch _puttch
_putenv _wputenv _tputenv
_rmdir _wrmdir _trmdir
_scprintf _scwprintf _sctprintf
_searchenv _wsearchenv _tsearchenv
_snprintf _snwprintf _sntprintf
_snscanf _snwscanf _sntscanf
_sopen _wsopen _tsopen
_spawnl _wspawnl _tspawnl
_spawnle _wspawnle _tspawnle
_spawnlp _wspawnlp _tspawnlp
_spawnlpe _wspawnlpe _tspawnlpe
_spawnv _wspawnv _tspawnv
_spawnve _wspawnve _tspawnve
_spawnvp _wspawnvp _tspawnvp
_spawnvpe _wspawnvpe _tspawnvpe
_splitpath _wsplitpath _tsplitpath
_stat64 _wstat64 _tstat64
_stat _wstat _tstat
_stati64 _wstati64 _tstati64
_strdate _wstrdate _tstrdate
_strdec _wcsdec _tcsdec
_strdup _wcsdup _tcsdup
_stricmp _wcsicmp _tcsicmp
_stricoll _wcsicoll _tcsicoll
_strinc _wcsinc _tcsinc
_strlwr _wcslwr _tcslwr
_strncnt _wcsncnt _tcsnbcnt
_strncnt _wcsncnt _tcsnccnt
_strncnt _wcsncnt _tcsnccnt
_strncoll _wcsncoll _tcsnccoll
_strnextc _wcsnextc _tcsnextc
_strnicmp _wcsnicmp _tcsncicmp
_strnicmp _wcsnicmp _tcsnicmp
_strnicoll _wcsnicoll _tcsncicoll
_strnicoll _wcsnicoll _tcsnicoll
_strninc _wcsninc _tcsninc
_strnset _wcsnset _tcsncset
_strnset _wcsnset _tcsnset
_strrev _wcsrev _tcsrev
_strset _wcsset _tcsset
_strspnp _wcsspnp _tcsspnp
_strtime _wstrtime _tstrtime
_strtoi64 _wcstoi64 _tcstoi64
_strtoui64 _wcstoui64 _tcstoui64
_strupr _wcsupr _tcsupr
_tempnam _wtempnam _ttempnam
_ui64toa _ui64tow _ui64tot
_ultoa _ultow _ultot
_ungetch _ungetwch _ungettch
_unlink _wunlink _tunlink
_utime64 _wutime64 _tutime64
_utime _wutime _tutime
_vscprintf _vscwprintf _vsctprintf
_vsnprintf _vsnwprintf _vsntprintf
asctime _wasctime _tasctime
atof _wtof _tstof
atoi _wtoi _tstoi
atoi _wtoi _ttoi
atol _wtol _tstol
atol _wtol _ttol
character compare Maps to macro or inline function _tccmp
character copy Maps to macro or inline function _tccpy
character length Maps to macro or inline function _tclen
ctime _wctime _tctime
fgetc fgetwc _fgettc
fgets fgetws _fgetts
fopen _wfopen _tfopen
fprintf fwprintf _ftprintf
fputc fputwc _fputtc
fputs fputws _fputts
freopen _wfreopen _tfreopen
fscanf fwscanf _ftscanf
getc getwc _gettc
getchar getwchar _gettchar
getenv _wgetenv _tgetenv
gets getws _getts
isalnum iswalnum _istalnum
isalpha iswalpha _istalpha
isascii iswascii _istascii
iscntrl iswcntrl _istcntrl
isdigit iswdigit _istdigit
isgraph iswgraph _istgraph
islead (Always FALSE) (Always FALSE) _istlead
isleadbyte (Always FALSE) isleadbyte (Always FALSE) _istleadbyte
islegal (Always TRUE) (Always TRUE) _istlegal
islower iswlower _istlower
isprint iswprint _istprint
ispunct iswpunct _istpunct
isspace iswspace _istspace
isupper iswupper _istupper
isxdigit iswxdigit _istxdigit
main wmain _tmain
perror _wperror _tperror
printf wprintf _tprintf
putc putwc _puttc
putchar putwchar _puttchar
puts _putws _putts
remove _wremove _tremove
rename _wrename _trename
scanf wscanf _tscanf
setlocale _wsetlocale _tsetlocale
sprintf swprintf _stprintf
sscanf swscanf _stscanf
strcat wcscat _tcscat
strchr wcschr _tcschr
strcmp wcscmp _tcscmp
strcoll wcscoll _tcscoll
strcpy wcscpy _tcscpy
strcspn wcscspn _tcscspn
strerror _wcserror _tcserror
strftime wcsftime _tcsftime
strlen wcslen _tcsclen
strlen wcslen _tcslen
strncat wcsncat _tcsncat
strncat wcsncat _tcsnccat
strncmp wcsncmp _tcsnccmp
strncmp wcsncmp _tcsncmp
strncpy wcsncpy _tcsnccpy
strncpy wcsncpy _tcsncpy
strpbrk wcspbrk _tcspbrk
strrchr wcsrchr _tcsrchr
strspn wcsspn _tcsspn
strstr wcsstr _tcsstr
strtod wcstod _tcstod
strtok wcstok _tcstok
strtol wcstol _tcstol
strtoul wcstoul _tcstoul
strxfrm wcsxfrm _tcsxfrm
system _wsystem _tsystem
tmpnam _wtmpnam _ttmpnam
tolower towlower _totlower
toupper towupper _totupper
ungetc ungetwc _ungettc
vfprintf vfwprintf _vftprintf
vprintf vwprintf _vtprintf
vsprintf vswprintf _vstprintf
WinMain wWinMain _tWinMain

Thursday, March 05, 2009

How MPEG-4 and H.264 video compression work

How video compression works

BDTI explains how video codecs like MPEG-4 and H.264 work, and how they differ from one another. It also explains the demands codecs make on processors.
This article assumes a basic understanding of video compression algorithms. For an introduction to video coders, see How video compression works.

Friday, February 20, 2009

Frenglish humor

Some of you reading my blog may have noticed that I am not obviously born in USA because of the amount of english mistakes. I am certainly confident that some of you mostly engineer won't have any problem to read. According to a research at Cambridge University, it doesn't matter in what order the letters in a word are. The only important thing is that the first and last letter be in the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself, but the word as a whole

http://www.jtnimoy.net/itp/cambscramb/

Wednesday, February 18, 2009

Size matter... Deep inside FLVplayback to reduce the size of the generated SWF

There is a nice balance between using the built-in Flash video components and doing your own thing to achieve the exact look and feel that you want as well as making sure the size of your SWF is small enough for what you want to do. Why ?
The answer is obvious. CDN company charges by the bandwidth so if you have a SWF on a web server which is supposed to stream a video without any user control make sure you don't build a SWF with controls. This might looks like a penny but if your ad is viewed by million of users, you end up winning some of the cost because of the size of the SWF. Finally, sometimes you are paying for the SWF and others for the content bandwidth. The new as3 version of FLVPlayback has some great features in it, including a sophisticated connection management and a well thought-out event system. However, over the years you've learned to avoid to using the standard Flash component set because there is always some sort of customization that your art director wants from you guys that the standard set just won't support.

The VideoPlayer class lets you create a video player with a slightly smaller SWF file than if you used the FLVPlayback component. Unlike the FLVPlayback component, the VideoPlayer class does not let you include a skin or playback controls, and although you cannot find or seek to cue points, the cuePoint events will occur. The FLVPlayback class wraps the VideoPlayer class. Use the FLVPlayback class in almost all cases because there is no functionality in the VideoPlayer class that cannot be accessed using the FLVPlayback class.

In practice the file size reduction of using VideoPlayer instead of FLVPlayback is on the order of 30kb. That's a nice savings bump, but it's probably irrelevant compared to the size of the video files. This 30kb savings is achieved by adding the classpath for the video playback package to the .fla file's classpath instead of just dragging the component icon into the library. For reference, here's the paths to add (File -> Publish Settings ->Flash -> ActionScript 3.0 Settings)


$(AppConfig)/Component Source/ActionScript 3.0/FLVPlayback

$(AppConfig)/Component Source/ActionScript 3.0/User Interface

So that's pretty easy, but there is one limitation that can was make your life complicated. If you are making use of all kinds of cool functions such asBitmapData.draw, SoundMixer.computeSpectrum, etc which require that your domain security ducks all be in a row. If you want to take Bitmap snapshots of a video as it's playing back. (FYI: this is an option only for video delivered using http progressive download and not for video delivered by rtsp stream coming out of Flash Media Server.) In as3 most classes which load remote files offer a means of telling the loader to check against the crossdomain.xml files that have already been loaded and if necessary, try and load the crossdomain.xml file from the new files' domain. This is handy, because you only request domain files when they are needed and you don't need to know the domains in advance. To trigger the domain checks Loader uses the LoaderContext class, Sound files use the SoundLoaderContext class, and video files use the checkPolicyFile property on the NetStream class.

So how do you set this flag when using the VideoPlayer or FLVPlayback components? Unfortunately, there is no method to do this in the existing api. VideoPlayer is an excellent wrapper around NetConnection and NetStream, however you cannot set properties directly on the NetStream object from outside the VideoPlayer thus leaving the checkPolicyFile property stuck at the false setting. What to do? Extend the class and set the flag yourself. Here's some code for a VideoPlayerExtended class:

package {import fl.video.*;

import flash.events.NetStatusEvent;
import flash.net.NetStream;

use namespace flvplayback_internal;

/**
* Extended version of fl.video.VideoPlayer class.
*/

public class VideoPlayerExtended extends VideoPlayer {

/**
* Override the default means of creating a netstream object
*
* Add checkPolicyFile=true to force loading of a crossdomain.xml file
*
* @private
*/
flvplayback_internal override function _createStream():void {
_ns = null;
var theNS:NetStream = new NetStream(_ncMgr.netConnection);
if (_ncMgr.isRTMP) {
theNS.addEventListener(NetStatusEvent.NET_STATUS, rtmpNetStatus);
} else {
theNS.addEventListener(NetStatusEvent.NET_STATUS, httpNetStatus);
}
theNS.client = new VideoPlayerClient(this);
theNS.bufferTime = _bufferTime;
theNS.soundTransform = soundTransform;
theNS.checkPolicyFile = true;
_ns = theNS;
attachNetStream(_ns);
}
}
}

You may be interested to read more about interactive video in Flash CS4 as well
using FLVPlayback Component or NetStream AS3 Class

http://younsi.blogspot.com/2008/12/interactive-video-in-flash-using-f4v.html

Monday, February 16, 2009

How to convert XMP Cuepoint Time to Millisecond in AS3

Following my article

http://younsi.blogspot.com/2008/10/flv-cuepoints-in-flash-cs3-with-flash.html

I wanted to explain to the Flash Community how they can interpret XMP Cuepoint
in millisecond time that Flash Can understand

To synchronize an action for a cue point in an F4V video file, you must retrieve the cue point data from either the onMetaData() or the onXMPData() callback functions and trigger the cue point using the Timer class in ActionScript 3.0. For more information on F4V cue points, see Using onXMPData().


Each XMP Tracks do have a framerate value
first get the nTracksFrameRate and then for each cuepoint time
devide the value read from XMP by the TrackFrameRate and you will
now have a time in millisecond.


function getFLVCuepointsFromXMP(onXMPString:String):void {
var onXMPXML = new XML(onXMPString);
var onXMPTracksXML;
var onXMPCuepointsXML;
var cuePointCount:Number = 0;
var strFrameRate:String;
var nTracksFrameRate:Number;
var cuePoints:Array = new Array();
var cuePoint:Object;

// Set up namespaces to make referencing easier
var xmpDM:Namespace = new Namespace("http://ns.adobe.com/xmp/1.0/DynamicMedia/");
var rdf:Namespace = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");

var strTracks:String = "";

if (verbose) {
trace("###### TRACKS");
}

// This iteration get all the Tracks
for each (var it:XML in onXMPXML..xmpDM::Tracks)
{
var strTrackName:String = it.rdf::Bag.rdf::li.rdf::Description.@xmpDM::trackName;
var strFrameRateXML:String = it.rdf::Bag.rdf::li.rdf::Description.@xmpDM::frameRate;
strFrameRate = strFrameRateXML.substr(1,strFrameRateXML.length);

nTracksFrameRate = Number(strFrameRate);

cuePoint["time"] = nStartTime/nTracksFrameRate;

............


Hope this will solve few headhaches...

Now implement a timer and sync your Cue Point the way you want using Action Script 3 code.

I am talking about the best use cases of XMP Cue points in an older
article

http://younsi.blogspot.com/2008/12/interactive-video-in-flash-using-f4v.html

Saturday, February 07, 2009

ActionScript 2.0 to ActionScrip3.0 Migration

Livedocs


The following table describes the differences between ActionScript 2.0 and 3.0.
http://livedocs.adobe.com/flex/201/langref/index.html?migration.html&all-classes.html

Conversion Tool

PHP
A great PHP set of class and stand alone windows exe will do few automated translation for you.

Features include:

* Updates createTextField to new TextField() syntax. Sets x, y, width and height if they are not the default (0). Uses addChildAt unless getNextHighestDepth() is used for argument 2, in which case addChild is used. Parses the first parameter and uses it as the variable name unless it is not a simple string, in which case a temp name is used, and the original name is shown in a comment on top of the block. Pretty sweet.
* Updates getURL to new URLRequest syntax. Works as above.
* Updates var, function and class to public var, public function and public class to remove warnings as requested by my childhood hero Robert Penner. Parses the class to recognize block depth to not affect local vars and inline functions.
* Smarter class and package name recognition.
* Removes unnecessary imports in the same package as the current class.
* Should properly recognize various line endings (crossing fingers).

The zip now includes a command-line executable called convertas2as3 for those Windows users who don’t feel like installing PHP. The zip is pretty big because it includes the php libraries for Windows users. On other platforms you can run the command-line utility in src/convert.php by typing php convert.php at the command line.

Try it here, download it here


JAVA
A Java JAR package and command line batch available here
http://jobemakar.blogspot.com/2007/05/convert-actionscript-2-to-actionscript.html
It automatically creates the package syntax, converts Void to void, recursively walks subdirectories, and outputs to a new location. In addition to those things it allows you to use two simple but powerful tags to do custom replacement of specific lines of code during upconversion. For instance:
//@replace var numShots:int = 10;
var numShots:Number = 10;

comes out as:
var numShots:int = 10;

Installation/usage instructions are included in the zip.
http://www.electrotank.com/junk/jobe/AS2_to_AS3.zip


SOME BASIC AS2 TO AS3 CONVERSION SAMPLE

Color
Old version:

First up, the old setRGB method of the legacy Color class.In the old days of ActionScript 1.0 and 2.0, you would create a Color object with a movieclip instance as an argument in the constructor, then apply the setRGB method on this Color instance. It was a bit weird, as you never really directly “talked to” the MovieClip whose colour you wanted to change.

var col:Color = new Color(some_mc);
col.setRGB(0x123456);

New Code

This has changed with AS3. The Color class is something else entirely, and in its place as a colour manipulator, we have this: ColorTransform.

import flash.geom.ColorTransform;
import flash.geom.ColorTransform;// create a new ColorTransform object
var colTrans:ColorTransform = new ColorTransform();
colTrans.color = 0xFF9900;
colTrans.alphaMultiplier = 0;
some_mc.transform.colorTransform = colTrans;

So this would set the colour of the object, but also set its alpha to 0.

Movie Clip Loader

Old Code

this.mcPreview.alpha = 0;
this.mcPreview.mcLoader = new MovieClipLoader();
this.mcPreview.mcLoaderListener = new Object();
this.mcPreview.mcLoaderListener.onLoadInit = Proxy.create(this, previewImageLoaded);
this.mcPreview.mcLoader.addListener(this.mcPreview.mcLoaderListener);
this.mcPreview.mcLoader.loadClip(pPath, this.mcPreview);

public class Proxy
{
public static function create(oTarget : Object, fFunction : Function,... arguments) : Function
{
/* Create an array of the extra parameters passed to the method. Loop
through every element of the arguments array starting with index 2,
and add the element to the aParameters array.*/
var aParameters : Array = new Array();
for(var i : Number = 2;i < arguments.length; i++)
{
aParameters[i - 2] = arguments[i];
}

// Create a new function that will be the proxy function.
var fProxy : Function = function():void
{
/* The actual parameters to pass along to the method called by proxy
should be a concatenation of the arguments array of this function
and the aParameters array.*/
var aActualParameters : Array = arguments.concat(aParameters);

/* When the proxy function is called, use the apply( ) method to call
the method that is supposed to get called by proxy. The apply( )
method allows you to specify a different scope (oTarget) and pass
the parameters as an array.*/

fFunction.apply(oTarget, aActualParameters);
};

// Return the proxy function.
return fProxy;
}
}
}
addChild(loader);

New Code

import flash.events.*;
import flash.display.Loader;
import flash.net.URLRequest;

var url:String = http://www.yourfullyqualidieddomain.com/yourswftoload.swf?cachebusters='+new Date().getTime();
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.OPEN,loadinit); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loading);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completes);
loader.load(new URLRequest(url));




TWEEN

OLD CODE

the migration of onMotionFinished an event triggered on completion of the old mx.transitions.Tween class. There is a new class:TweenEvent (fl.transitions.TweenEvent) It looked like this in AS2:

import mx.transitions.Tween;
import mx.transitions.easing.Regular;

class SlidingClass extends MovieClip {var xTween:Tween
// class constructor etc. not shown
function slideTo(xTarget:Number, frames:Number, callbackObj:Object, callbackFunc:Function) : Void {
xTween = new Tween (this, "_x", Regular.easeOut, this._x, xTarget, frames, false)
xTween.onMotionFinished = function() {callbackFunc.call(callbackObj);
};};


New Code

no need to pass the target object anymore - that is inherent in the function argument:

import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.Regular;
var xTween:Tween;

function slideTo(xTarget:Number, frames:Number, func:Function) {
xTween = new Tween(this, "x", Regular.easeOut, this.x, xTarget, frames, false);
xTween.addEventListener(TweenEvent.MOTION_FINISH, func);};


Because of AS3 Event handling, a reference to the Tween is automatically passed to the target function as an Event datatype, via the “target” property.


OnPress

//code in AS 2
cornerplus1.onPress = function () {

startDrag(this);

}


Warning: 1090: Migration issue: The onPress event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'mouseDown', callback_handler).

NEW

// in AS 3 becomes

cornerplus1.addEventListener(MouseEvent.MOUSE_DOWN, dragFn);
function dragFn(event:MouseEvent){
event.target.startDrag();
};


LoadVars


OLD

var msg:LoadVars = new LoadVars();
var msgSent:LoadVars = new LoadVars();
msg.var1 = "one";
msg.var2 = "two";
msgSent.onLoad = function($success:Boolean):Void
{
if ($success)
{
trace("Message sent.");
}
else
{
trace("Message failed.");
}
};
msg.sendAndLoad("http://www.yourfullyqualifieddomain.com/script.php", msgSent);

NEW

var scriptRequest:URLRequest = new URLRequest("http://www.yourfullyqualifieddomain.com/script.php");

var scriptLoader:URLLoader = new URLLoader();
var scriptVars:URLVariables = new URLVariables();
scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);
scriptVars.var1 = "one";
scriptVars.var2 = "two";
scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;
scriptLoader.load(scriptRequest);
function handleLoadSuccessful($evt:Event):void
{
trace("Message sent.");
}
function handleLoadError($evt:IOErrorEvent):void
{
trace("Message failed.");
}

http://www.yourfullyqualifieddomain.com/script.php?var1=one&var2=two


MovieClip

Creating new instances of a class has been greatly simplified in ActionScript 3.0. In previous versions of ActionScript, you needed to call createEmptyMovieClip() or createTextField() if you wanted to create a new MovieClip or TextField. Now, in ActionScript 3.0, you can simply call new MovieClip() or new TextField() directly, as shown in the following examples:

OLD

// AS2
this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.beginFill(0xFF0000);
mc.moveTo(0, 0);
mc.lineTo(100, 0);
mc.lineTo(100, 80);
mc.lineTo(0, 80);
mc.lineTo(0, 0);
mc.endFill();
mc._x = 80;
mc._y = 60;

The previous code creates a new movie clip instance, draws a red rectangle which is 100x80 pixels, and moves the instance to 80,60 on the Stage. Compare that to the following code which does the exact same thing, although using the new drawRect() method instead of having to use the moveTo() and lineTo() methods:

NEW

// AS3
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill(0xFF0000);
mc.graphics.drawRect(0, 0, 100, 80);
mc.graphics.endFill();
mc.x = 80;
mc.y = 60;
addChild(mc);

MovieClip

OLD

ReferenceError: Error #1056: Caused by Declaring Stage Instances Private
If you declare a stage instance private you get the message: "ReferenceError #1056 Cannot create property my_mc on StageIntanceDeclarationsClass"

This error occurs when you uncheck the "Declare Stage Instances Automatically" checkbox in the "ActionScript 3.0 Settings" dialogbox and proceed to declare stage instances as private variables in the class associated with the containing MovieClip.

A Note on Inheritances and Declaring Stage Instances:
You cannot choose to simply always declare stage instances automatically without forcing the use of inheritance in classes linked to MovieClip Symbols. If you have a class APrime which is derived from class A and APrime is linked to a MovieClip Symbol, all stage instances used in the base class A must be manually declared in class A. "Declare Stage Instances Automatically" only declares instances in the class linked to the MovieClip Symbol and does NOT make those references available to any base classes.

Example:
Assume that the class StageIntanceDeclarations is set as the class associated with a MovieClip which c0ntains the MovieClip my_mc. Then the following code will cause ReferenceError #1056 at runtime.



package
{
import flash.display.MovieClip;
public class StageIntanceDeclarations extends MovieClip
{
//Private Causes ReferenceError #1056
private var my_mc:MovieClip;
function StageIntanceDeclarations()
{
}
}
}



The output is as follows:
ReferenceError: Error #1056: Cannot create property my_mc on StageIntanceDeclarations.
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at TestStageIntanceDeclarationsBase$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()

NEW

To avoid this error simply declare my_mc as public:
public var my_mc:MovieClip;


XML

OLD
NEW

undefined null Nan

OLD
NEW

Thursday, February 05, 2009

Flash CS3 to Flash CS4 migration awerness when using FLVPlayback

For those of you who are willing to open existing FLA created by Flash CS3 in Flash CS4 and if those FLA were referencing some instance of the FLVPlayback in the library only controlled by Action Script 3 code, you have to be careful when saving the FLA in Flash CS4 the first time.

Flash CS4 will ask you to migrate your FLA to CS4. Great ! you are MORE than welcome to do this if you were using Action Script 3 code to load video (obviously FLV) and now you are planning to manipulate F4V/MP4/H264 and produce Flash Player 10 SWF. If this is your plan, do not forget to replace the existing FLVPlayback component in the library with the new one as well before upgrading your FLA to Flash CS4.Ddrag and drop the FLVPlayback on stage. You will be prompt to replace. Then save your FLA with Flash CS4. Doing so will guaranty better support of any new files extension supported by latest Flash Player and/or FLash Media Server. Enhancement are always likely to happen from one version of Flash CS to another. From there you will be on track for awesome new features.

Finally, I also recommend ActionScript 3 devs to use load method as much as possible and avoid source in AS3 CS3 code. Sanity check your code if you don't want to upgrade to latest FLVPlayback but still want to manipulate MP4/H264/F4V file by just targeting Flash Player 10.

BTW: If you are manipulating FLV, you are just fine.

Monday, January 26, 2009

How to write XML data with Xerces which can be edit with unicode text editor

Serializing XML data with Xerces

The DOMBuilder class provides an API for parsing XML documents and building the corresponding DOM document tree; while the DOMWriter class provides an API for serializing (writing) a DOM document out in an XML document. To serialize XML data, first load the XML data to a DOM tree using a DOMBuilder and then use a DOMWriter to write out the DOM tree. For example:


Listing 1. Serializing XML data
// DOMImplementationLS contains factory methods for creating objects
// that implement the DOMBuilder and the DOMWriter interfaces
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(gLS);

// construct the DOMBuilder
DOMBuilder* myParser = ((DOMImplementationLS*)impl)->
createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);

// parse the XML data, assume it is saved in a local file
// called "theXMLFile.xml"
// the DOMBuilder will parse the data and return it as a DOM tree
DOMNode* aDOMNode = myParser->parseURI("theXMLFile.xml");

// construct the DOMWriter
DOMWriter* myWriter = ((DOMImplementationLS*)impl)->createDOMWriter();

// optionally, set some DOMWriter features
// set the format-pretty-print feature
if (myWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
myWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);

// set the byte-order-mark feature
if (myWriter->canSetFeature(XMLUni::fgDOMWRTBOM, true))
myWriter->setFeature(XMLUni::fgDOMWRTBOM, true);

// serialize the DOMNode to a UTF-16 string
XMLCh* theXMLString_Unicode = myWriter->writeToString(*aDOMNode);

// release the memory
XMLString::release(&theXMLString_Unicode);
myWriter->release();
myParser->release();



Both DOMBuilder and DOMWriter are constructed using factory methods from DOMImplementationLS. When finished, they both need to be released explicitly to relinquish any associated resources. Also, the returned string from writeToString is owned by the caller, who is responsible for releasing the allocated memory.

You can also opt to set some features that control the behavior of the DOMWriter. Xerces-C++ has implemented a number of DOMWriter features that are specified in the W3C DOM Level 3 Load and Save Specification. A complete list can be found in the Xerces-C++ programming guide, DOMWriter Supported Features (see Resources). A couple of them are worth highlighting:

format-pretty-print -- This formats the output by adding a newline carriage return and indented whitespace to produce a pretty-printed, human-readable form. The exact form of the transformations is not specified in the W3C DOM Level 3 Load and Save Specification, and thus the parser has its own interpretation. In releases prior to Xerces-C++ 2.2 (or XML4C 5.1), the parser only pretty-prints the prologue and the epilogue. It doesn't touch the content within the root element. And from Xerces-C++ 2.2 (or XML4C 5.1) onwards, turning on this feature also causes the content within the root element to be formatted.
byte-order-mark -- This is a non-standard extension added in Xerces-C++ 2.2 (or XML4C 5.1) to enable the writing of the Byte-Order-Mark (BOM) in the resultant XML stream. The BOM is written at the beginning of the resultant XML stream, if and only if a DOMDocumentNode is rendered for serialization, and the output encoding is one of the following:

UTF-16
UTF-16LE
UTF-16BE
UCS-4
UCS-4LE
UCS-4BE

Saturday, January 17, 2009

My Favorites Flash AS2/AS3 Components/FLA Part I

Components in Flash CS3 and CS4

Kudos for Ultrashok.com done in Flex. Interview with Patrick Miko

http://theflashblog.com/?p=312

http://blogs.adobe.com/rgalvan/2008/01/about_components.html

A great candidate for a new video playback component : A component using netstream to interpret interactive hot spot produced by Activideo embedded in FLV/F4V stream.
You may be interested to read more about interactive video in Flash CS4
http://younsi.blogspot.com/2008/12/interactive-video-in-flash-using-f4v.html

Overall my favorites component for Flash CS3/Flash CS4 to
render Photo Gallery and now Video. Each Video transition now
support Pixel bender. Once drop on stage you will have access
to a Video Component with an impressive set of parameters.

http://slideshowpro.net/examples/

http://www.ultrashock.com/#/asset/41197/as-flash-media-player.html



AS-Flash Media Player (standalone)

Features:
- Video player with H264 support
- Audio player
- Subtitles - XML
- .srt to xml converter (PHP script)
- Share (send to friend) (PHP script)
- Cue points (highlights)
- external (XML) and internal (in video) CP
- YouTube support
- Alternate video content (low/high quality)
- Image preview
- External loaded logo
- URL protection
- Version test for Adobe Flash Player
- Auto hide controls
- Loop on/off
- Keyboard shortcuts
- Mouse wheel, doubleclick
- Fullscreen support
- FlashVars & Query driven
- AS 2.0

http://www.ultrashock.com/#/asset/41084/ultra-xml-item-slider.html



XML driven item slider.
You can change almost everything: number of items/page, number o change/click, image 1, image 2, text 1, text 2, speed, blur, saturation, brightness, reflection and much more. AS 2.0 - Flash Player 8


http://www.ultrashock.com/#/asset/40818/pageflipper-as3.html




Engage your users with truly intuitive browsing experiences with the pageFlipper, a Flash component that enables magazine style flipping of pages. Sensational when used for company brochures, family photo albums or editorial style content. With realistic page turning effects introduce an enhanced sense of interaction to your users. Use Movieclips, external images or SWFs for pages. Add pages using XML, Actionscript or the Component Inspector panel. Only 14KB.

Flip through the book in the example by either clicking and dragging the pages from the corners in a page flipping motion or by clicking in the corner of each page. You may also flip to each page directly using the direct page number links above the book. AS 3.0 - Flash Player 9

http://www.ultrashock.com/#/asset/40263/tree3d-as3-component.html



Tree3D is a tree component for ActionScript 3 with a twist. It allows you to easily create a three dimensional interactive tree UI navigation systems. Based on data driven XML, the component can be easily adapted to virtually any data source.

Developed by Zerofractal Studio and based on an idea by Alejandro Gonzalez, Tree 3D offers an intuitive user friendly functional spatial tree that combines horizontal navigation for the current level and depth cascade style navigation for its hierarchy.

Common uses for Tree 3D are: File/Folder Browsers, Menu systems, site-maps, or any tree based structure.

Features:
- Data driven
- Customizable Label and Icon styles
- Breadcrumb Navigation
- Customizable UI settings
- Incredible 3D eye-candy effects
- Customizable Scrollbar
- Keyboard/Mouse Wheel Navigation.
- Flash Player 9 - AS 3.0

http://www.ultrashock.com/#/asset/40612/flash-igoogle-weather.html



Cool Flash Weather widget XML based (data is received from Google web service at -(www.google.com/ig). You can choose different towns, languages, US or SI units. You can add unlimited number of cities and languages (XML settings).

Your server must support PHP in order to avoid the security sandbox for this widget.
Flash Player 8 - AS 2.0

http://www.ultrashock.com/#/asset/41193/spinning-3d-earth-globe.html



- Real 3D globe (not just one flat map animated);
- Smooth animation based on 72 frames;
- 100% scalable vector;
- Translucent globe;
- One movieclip contains all graphic elements. Simply drag and drop;
Included AS code for 9 versions of the globe (as seen in the preview);
- Easy to customize (with or without actionscript): globe elements colors; globe elements transparency;
- AS 2.0 - Flash Player 8

http://www.ultrashock.com/#/asset/41988/news-rotator-01.html



Features:
- resizable from xml
- unlimitted images/content
- dinamically resizable scroller
- you can change most of the colors/sizes using the xml
- you can position the entire component as well as the other individual components just from the xml
- you can change the button's text/url/target for each slide
- the content is html formatted text and you can easily change it for each slide
- also, from the .xml file you can change the sliding timing and the fade in/out time and animation type
- in the xml you have a variable (autoplay), when this is activated, on first load the news rotator will start playing

The component can easily be embedded into another project, all you have to do is copy the srouce files into your new projects folder, copy the library items into your new projects, drag and drop on the stage the gal movie clip and it's done.

You can use the news rotator in many ways, it's a useful component and because the level of customization is high it's a must have. It can be a news rotator, a product show off or even a family album, sky is the limit.
- AS 2.0 - Flash Player 8.0


http://www.ultrashock.com/#/asset/40683/3d-stack-as-2.0.html



The 3D Stack can be easily use to display groups of images, movie clips, SWFs with perspective, depth, fading and much more!

Key features:

* Adjustable images position via parameters or
* Using camera keyboard and mouse controls
* XML configuration file easy to setup
* AS 2.0 - Flash Player 8.0

http://www.ultrashock.com/#/asset/40777/ripple-dissolve.html



AS3 RippleDissolve class that works best with small vectors or bitmaps. The effect is triggered on a MovieClip by using a single line of ActionScript. Settings include effect duration, ripple height, ripple speed and effect strength. Goldfish not included.

http://www.ultrashock.com/#/asset/41497/dynamic-sliding-menu-02.html



Sliding menu, mouseover pushes out the normal state of the button.

Features for the xml/what you can change:
- the menu's position
- normal/over/pressed gradient colors, font size, font name, button's height, button's added width to the text's total width if you want the button to be a little wider
- you can toggle either a button will be launched at first menu load
- you can toggle either a line will appear around button, you can even choose the line's gradient colors
- you can toggle each bg (normal/over/pressed) and of course you can change each of the button's gradients and alpha value
- you can toggle on/off the menu's big background and you can change it's gradient color, width, height, alpha value and you can even position it anywhere you want.
- you have 4 motion options ( up-down, down-up, right-left, left-right )
- you can change the animation time and you can choose the animation type ( I have used tweener for this and you have a link in the help file with all the transition types available )
- AS 2.0 - Flash Player 8.0

Flexibile menu, easy to customize without having to install flash, all you need is a text editor to change it's graphics. In this preview version getURL had been disabled but in the original file it works just fine and in the xml you can change the url and the target as well.

Enjoy this new release from OXYLUS Flash


http://www.ultrashock.com/#/asset/41487/ultimatescrollerpro.html



This is the PRO version of the ultimateScroller component, rewritten for ActionScript 3.0 with several additional features and enhancements. An easy to use, drag and drop Flash scroller that can scroll movie clips and dynamic text fields. Includes drag scrolling, easing, motion blur, mouse wheel scrolling and CS3 skinning.
Available for ActionScript 3.0. .

http://www.ultrashock.com/#/asset/40645/photosplash-as3.html



Displays a collection of images in a random layout and angle. The viewer can rearrange the layout by clicking and dragging the images or by pressing the optional reshuffle button. Large images can also have mouse over titles and descriptions. Built-in easing effects and skinnable image holders.
AS 3.0 - Flash Player 9

http://www.ultrashock.com/#/asset/41191/world-map-with-navigation-menu.html



Stylish vector world map with continent navigation menu. It could be used for corporate websites (list of company branches or distributors locations). Continents: North America, South America, Europe, Asia, Africa and Australia.
AS 2.0 - Flash Player 8.0

http://www.ultrashock.com/#/asset/39773/tooltip-v.2.html



This is a nice yet powerful tooltip. This can easily be integrated into all of your flash applications. AS 2.0 - Flash Player 8.0

http://www.ultrashock.com/#/asset/41194/



Spinning Earth - AS 2.0 - Flash Player 8.0

http://www.ultrashock.com/#/asset/41041/magneticmenu.html




The magneticMenu flash component displays icons, images, or flash files in a magnetic like menu. When a user mouses over an icon the icon is attracted to the mouse pointer much like a real magnet. Supports both a horizontal or vertical menu.

Key Features
* All settings and photos can be changed through the component inspector or the XML file
* Customizable spacin
* horizontal or vertical format
* Supports all Flash image formats
* Supports .swf files
* ActionScript API available
* AS 3.0 - Flash Player 9

http://www.ultrashock.com/#/asset/41544/event-count-down-widget-v1.html




EVENT COUNT DOWN WIDGET V1

A simple but useful event countdown ticker. Great for under-construction pages
with a known launch date. All code resides on the timeline and is well commented.
Additional documentation describes how to modify the widget's variables to your
liking.

Future upgrades will include:

- Parameters to be set externally via XML
- Pure V2 component implementation
- AS 2.0 - Flash Player 7

http://www.ultrashock.com/#/asset/41576/rotarygallery.html



The rotaryGallery displays images and Flash .swf files in a unique circular layout. Once a user clicks on a thumbnail image, the thumbnail expands to full size while the current image sizes down to a thumbnail and the rest of the thumbnails dynamically reorganize. The rotaryGallery has many customizable parameters to get an infinite number of looks.

All settings and images/videos can be changed through the component inspector or the XML file
Custom thumbnail image size
Custom image size
Custom diameter of the gallery
Option to place the center image onto or below the thumbnail images
Optional Glass like effect over the images
Custom glow transparency
Custom glow color
Custom glow blur
Optional link click through
Supports all Flash image formats
Supports Flash .swf files
AS 3.0 - Flash Player 9

http://www.ultrashock.com/#/asset/40799/calendar-xml.html



Fully customizable events calendar, XML driven.

Here are some of the variables you can edit:
calendarWidth & calendarHeight
calendarColor & calendarGradient
backgroundAlpha & alphaSpeed
calendarTextSize & calendarTextFont & calendarTextColor
effect
daySize & dayColor & dayEventColor & dayAlpha
daySpacing
eventBorder & eventColor
eventTextSize & eventTextFont & eventTextColor
transition & eventTransitionSpeed
startDay

http://www.ultrashock.com/#/asset/12202/fire-effect.html



Set any static movie clip on fire
AS 3.0 - Flash Player 9

http://www.ultrashock.com/#/asset/41516/clouds-mask-xml-banner-rotator-(as3).html




This banner rotator is driven xml. It uses 'perlinNoise' and 'threshold' method to create clouds mask effect. You can show image. Customize button color, hover color, text color, button number, button shape. Also, open window method and delay time for every image. Very powerful, hope you to like it.

Features:

  • xml driven

  • Customize button color

  • Customize hover color

  • Customize text color

  • Customize button number

  • Customize button shape

  • Pause/Play rotator

  • customize link enable for banner (linkEabled = 'yes' or linkEabled = 'no'

  • Customize position of buttons

  • Customize open window method for every image: '_blank' or '_self'

  • Customize delay time for every


http://www.hitasoft.com/
RIPE WEB FLV PLAYER 1.0
The slow motion Video Feature is interesting

http://www.flashloaded.com/flashcomponents/3dwall/



The 3D Wall Flash component displays images on an engaging interactive 3D wall using the Papervision3D engine. The PRO version can also display FLV videos and SWF's

http://flashxpert.net/products/







Wall of images

http://flashden.net/files/116659/index.html

How The Wall Works

- A list of images is drawn from an XML file and then loaded in randomly.

- The app then calculates how many squares will fit on the screen (based on the “target width” and “target height” XML settings) and then randomly fills the browser with your images.

- Your image list can be any size. For example, if you have only two images in your list, the file will take those two images and repeat them until the wall is built. If you have more images in your list than allotted squares, the file will then leave out the extra images.

- You can choose whatever size you want your squares to be from two settings in the XML file

- The app will scale your images to fill each square appropriately

- Your large images can be any size. If they are too big to fit on the viewer’s browser, they will be scaled down to fit.
XML Options

- Set the target height and width of your squares

- Choose to use the file as a clickable gallery or use it as a dynamic website background image

- Customize your Right Click Menu with target supported links

- Set the path to your photos and write their HTML /CSS supported descriptions

Uses GreenSock TweenLite. Lightweight at only 25kb (with embedded font, 12kb with device fonts). Class driven and easy to integrate with your Flash Projects (code below)

import com.crackerjack.Wall;
var wall:Wall = new Wall();
addChild(wall);



XML BANNER ROTATOR 02 AS3

http://flashden.net/item/xml-banner-rotator-02-as3/39423

This is a flexible and easy to customize banner ad rotator that supports external images and swf files. All settings and item locations/descriptions can be set in the .xml file. Very easy to resize (change dimensions in the .xml and re-compile the file with the same dimension = done).

Among its features :
- ActionScript 3.0
- virtually unlimited items (visualy limited by the height of the file for the drop-down selector)
- xml powered, flexible
- supports both images and swf files
- autoplay timer setting
- text description for each item with the posibility to have no description bar
- clean unobtrusive design
- cool motion blur animation
- play/pause feature
- quick setup and customization

FLIP BOOK SLIDESHOW

http://flashden.net/item/flip-book-slideshow/35254

Features of the ActionScript3 Flip Book Slideshow.
– Item support JPG , GIF , PNG files.
– Each page move for its own path.
– You can use it as:
1. E-Book or E-Jurnal.
2. Image Viewers.
3. Banner rotator.
4. Image slideshow.

– Easy configure and modify all settings and parameters by XML files:
1. Unlimited number of pages.
2. You may add unlimited number of images and HTML -formatted texts for each page and move it to any positions on the page.
3. You may add link for any images with different target parameters.
4. You may edit font size, font colour, background colour, background opacity and width for every text block by XML .
5. You may turn on/off autoslideshow mode, set animation speed, animation pause, buttons colour, preloader colour by XML .
6. You may set one of two modes:
a. Loop mode – pages will be flip by loop.
b. Single mode – Flip Book Slideshow will be looked like on simple book.
7. You may set background image or colour for Flip Book Slideshow and for any page.


SLIDE ZOOM VIEWER

http://flashden.net/item/slide-zoom-viewer/33484

This is a drag and drop XML drive image viewer with zoom/pan capability and HTML /CSS description text. It can be used both for flash files to be embedded in HTML as well as for dragging and dropping into your flash project.
Features:

* Drag and drop and XML driven.

* Can go over any background (the wood one shown in preview is just an example of this).

* Coded to load into other swf’s without problems.

* Text is HTML /CSS text for thorough formatting abilities.

* Help files included.

* 100% vector with easy on stage editing of graphics.

* Zooming and Panning allows large detailed images to be inspected closely.



XML TEAM BUSINESS CARDS VIEWER

http://flashden.net/item/xml-team-business-cards-viewer/34182


XML Team Business cards is a team viewer, which displays Business cards of the members of your team, your office…

Without opening any fla, just edit the XML .

You can display the photo of each member, his name, his role, job or position, and his e-mail. The e-mail address is clickable, to open your messenging tool to send an e-mail.

You can customize : the colors and the shapes of your Business cards, put a different color for each member.

You can add as many members you want.



3D XML BUSINESS CARD

http://flashden.net/item/3d-xml-business-card/18716

This Papervision 3D Business card is very simple to use, just open up the XML file in your favourite text editor like Notepad and replace the default details with your own business card information. Then, just create your imagery for both the front and back of the business card. Once youve done that you are ready to go!

I have listed this as a business card because that was my main inspiration for making it, but you could use it for anything where you wanted to flip something with two images on.

Features:

* True 3D, built using the fantastic 3D engine, Papervision, no skewing and distortions to create an illusion like others
* XML based, you can control the business card text data within an XML file, along with settings like size, flip speed, blur amount and the front and back images to be used




IMAGE TRANSITION COMBO EFFECTS

http://flashden.net/item/image-transition-combo-effects/1116

These are 8 image transition effects, include: Rotate, Scale, Blur and Fade. Maybe you have never seen this kind of transition before, not using mask, tweening, filter etc… but from the small rectangles that build up the image. By modifying the properties of those small rectangles, you can create many different transition effect. The Fade effect is somehow different from the traditional fade effect you knew . Quite impressive and useful, the choice is yours!

BLUR MASK EFFECT

http://flashden.net/item/blur-mask-effect/372

Mask effect on an image with blur.


XML PIXELATE!!!

http://flashden.net/item/xml-pixelate/10479


MIRAGE IMAGE

http://flashden.net/item/mirage-image/10789

XML CARDS TRANSITION

http://flashden.net/item/xml-cards-transition/14416

XML COOL SQUARE TRANSITION

http://flashden.net/item/xml-cool-square-transition/14015


BOXED TRANSITIONS 2

http://flashden.net/item/boxed-transitions-2/13552

It’s all vector, therefore you can resize it all you want and not lose the quality. It is ready for drag and drop. Place the movieclip “mask” over your photo or other elements.

If you want to change color transition, set and edit movieclip “box” (first color) and “addons” (second color). Additionally You can put “tint” color effect in movieclip “mask”.

Only 5kb (without photo)!

BOXED TRANSITIONS

http://flashden.net/item/boxed-transitions/12780

It’s all vector, therefore youcan resize it all you want and not lose the quality. The items in the stage have a “tint” as color effect. It is ready for drag and drop.

Only 3kb (without photo)!

Pixel Bender Filter in Flash CS4






My first Pixel Bender filter (RGB RAMP)



Today I spent a few hours with Pixel Bender and it is well worth the effort. As you know CS4 was announced recently and packs a pretty substantial list of features, but Adobe is equally impressing developers on the Adobe Labs. One of the newer additions is Pixel Bender. Pixel Bender is essentially a toolkit that is used to develop filters. These filters can be used in Flash 10 and After Effects and allow everyday people to create some very interesting filters.

The running of the filter in Flash CS4 is pretty much identical to an included filter, like the BlurFilter or DropShadowFilter.


Start by opening the Pixel Bender Toolkit, which can be obtained on the Adobe labs


Then create your kernel script by simply copying and pasting the code provided here into the code window of the Pixel Bender toolkit. Pixel Bender Files have the extension pbk.














<languageversion : 1.0;>

kernel QuadBlur
< namespace : "com.pixelbender.filters";
vendor : "RGB Filter";
version : 1;
description : "Creates a basic RGB Pixel Color Ramp";
>

{

input image4 src;
output pixel4 dst;

parameter float red

<

minValue:1.0;

maxValue:15.0;

defaultValue:1.0;

>;

parameter float green

<

minValue:1.0;

maxValue:15.0;

defaultValue:1.0;

>;

parameter float blue

<

minValue:1.0;

maxValue:15.0;

defaultValue:1.0;

>;


void


evaluatePixel()

{


pixel4 p = sampleNearest(src,outCoord());

p.r *= red;

p.g *= green;

p.b *= blue;

dst = p;

}


}</languageversion>



Then export the filter File > Export Kernel Filter for Flash Player and save the Sample.pbj (binary file) file on you desktop.

Now Open Flash and create a new ActionScript 3 document. For a test sample you need to insert an image on the stage and an image for a button inserted as movie clip. Save the new Flash document to your desktop, where you saved the filter file. Once the file is saved import an image that you will apply the filter to.


Click on the following link to see the filter in action. You must have Flash Player 10 installed to view it.



The ActionScript 3 code that I used to import the new sample shader is
shown below.









import adobe.utils.*;

import fl.controls.*;

import flash.accessibility.*;

import flash.desktop.*;

import flash.display.*;

import flash.errors.*;

import flash.events.*;

import flash.external.*;

import flash.filters.*;

import flash.geom.*;

import flash.media.*;

import flash.net.*;

import flash.printing.*;

import flash.profiler.*;

import flash.sampler.*;

import flash.system.*;

import flash.text.*;

import flash.text.engine.*;

import flash.ui.*;

import flash.utils.*;

import flash.xml.*;



var shader:flash.display.Shader;

var timer:flash.utils.Timer;

var loader:flash.net.URLLoader;

var timerInt:uint;

var startBtn:fl.controls.Button;

var image:flash.display.MovieClip;

var shaderFilter:flash.filters.ShaderFilter;









try

{

startBtn["componentInspectorSetting"] = true;

}

catch (e:Error)

{

};

startBtn.emphasized = false;

startBtn.enabled = true;

startBtn.label = "Start Effect";

startBtn.labelPlacement = "right";

startBtn.selected = false;

startBtn.toggle = false;

startBtn.visible = true;

try

{

startBtn["componentInspectorSetting"] = false;

}

catch (e:Error)

{

};



timerInt = 40;

image = new PixelBenderImage();

image.y = 20;

image.x = 25;

addChild(image);

startBtn.addEventListener(MouseEvent.CLICK, this.startEffect);





function restartEffect(arg1:flash.events.MouseEvent):*

{

image.alpha = 0;

initFilter();

return;

}

function startEffect(arg1:flash.events.MouseEvent):*

{

loader = new URLLoader();

loader.dataFormat = URLLoaderDataFormat.BINARY;

loader.addEventListener(Event.COMPLETE, this.loadComplete);

loader.load(new URLRequest("Sample.pbj"));

return;

}





function initFilter():*

{

shader.data.red.value = [20];

shader.data.green.value = [20];

shader.data.blue.value = [20];

shaderFilter = new ShaderFilter(this.shader);

image.filters = [shaderFilter];

image.alpha = 1;

timer = new Timer(timerInt, 0);

timer.addEventListener(TimerEvent.TIMER, this.timerHit);

timer.start();

return;

}

function timerHit(arg1:flash.events.TimerEvent):void

{

var loc2:*;

var loc3:*;

var loc4:*;


if (shader.data.red.value == 1)

{

startBtn.label = "Restart Effect";

startBtn.removeEventListener(MouseEvent.CLICK, this.startEffect);

startBtn.addEventListener(MouseEvent.CLICK, this.restartEffect);

timer.stop();

return;

}

loc2 = shader.data.red.value - 0.1;

loc3 = shader.data.green.value - 0.1;

loc4 = shader.data.blue.value - 0.1;

shader.data.red.value = [loc2];

shader.data.green.value = [loc3];

shader.data.blue.value = [loc4];

shaderFilter = new ShaderFilter(shader);

image.filters = [shaderFilter];

return;

}

function loadComplete(arg1:flash.events.Event):void

{

shader = new Shader(loader.data);

initFilter();

addEventListener(Event.ENTER_FRAME, loop);

return;

}

/*

function onChange(p:Number):void

{

p *= 50;

shader.data.amount.value = [p, p, p];

image.filters = [filter];

}

*/





Pixel Bender filter (ZOOM BLUR)




This filter will create a zoom blur effect













<languageVersion : 1.0;>

kernel ZoomBlur

< namespace : "com.rphelan";

vendor : "Ryan Phelan";

version : 1;

description : "A simple implementation of zoom blur, using 15 levels of blur.";

>

{

parameter float2 center

<

minValue:float2(0.0, 0.0);

maxValue:float2(2048.0, 2048.0);

defaultValue:float2(256.0, 256.0);

>;



parameter float amount

<

minValue:0.0;

maxValue:0.5;

defaultValue:0.05;

>;


input image4 src;

output pixel4 dst;

void

evaluatePixel()

{

// Obtain the output pixel coordinate

float2 coord = outCoord();



// Offset by the center value

coord -= center;



float scale;

dst = float4(0.0);



// This is an expanded for loop.

// Loops are not currently supported in pixel bender.

// For increased definition at the cost of performance,

// simply add more levels.



// Take 15 samples radiating out from the center and

// add them to dst



scale = 1.0;

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (1.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (2.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (3.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (4.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (5.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (6.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (7.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (8.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (9.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (10.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (11.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (12.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (13.0/14.0);

dst += sampleNearest( src, coord*scale + center );



scale = 1.0 + amount * (14.0/14.0);

dst += sampleNearest( src, coord*scale + center );



// Divide by 15 to get the average of the samples

dst /= 15.0;

}

}



Then export the filter File > Export Kernel Filter for Flash Player and save the .pdk file on you desktop.

Now Open Flash and create a new ActionScript 3 document. Save the new Flash document to your desktop, where you saved the filter file. Once the file is saved import an image that you will apply the filter to.


Click on the following link to see the filter in action. You must have Flash Player 10 installed to view it.



The ActionScript 3 code that I used to import the ZoomBlur sample shader is
shown below.









import adobe.utils.*;

import fl.controls.*;

import flash.accessibility.*;

import flash.desktop.*;

import flash.display.*;

import flash.errors.*;

import flash.events.*;

import flash.external.*;

import flash.filters.*;

import flash.geom.*;

import flash.media.*;

import flash.net.*;

import flash.printing.*;

import flash.profiler.*;

import flash.sampler.*;

import flash.system.*;

import flash.text.*;

import flash.text.engine.*;

import flash.ui.*;

import flash.utils.*;

import flash.xml.*;





var shader:flash.display.Shader;

var timer:flash.utils.Timer;

var loader:flash.net.URLLoader;

var timerInt:uint;

var startBtn:fl.controls.Button;

var image:flash.display.MovieClip;

var shaderFilter:flash.filters.ShaderFilter;









try

{

startBtn["componentInspectorSetting"] = true;

}

catch (e:Error)

{

};

startBtn.emphasized = false;

startBtn.enabled = true;

startBtn.label = "Start Effect";

startBtn.labelPlacement = "right";

startBtn.selected = false;

startBtn.toggle = false;

startBtn.visible = true;

try

{

startBtn["componentInspectorSetting"] = false;

}

catch (e:Error)

{

};



timerInt = 40;

image = new PixelBenderImage();

image.y = 20;

image.x = 25;

addChild(image);

startBtn.addEventListener(MouseEvent.CLICK, this.startEffect);





function restartEffect(arg1:flash.events.MouseEvent):*

{

image.alpha = 0;

return;

}

function startEffect(arg1:flash.events.MouseEvent):*

{

loader = new URLLoader();

loader.dataFormat = URLLoaderDataFormat.BINARY;

loader.addEventListener(Event.COMPLETE, this.loadComplete);

loader.load(new URLRequest("ZoomBlur.pbj"));

return;

}





function initFilter():*

{

return;

}

function timerHit(arg1:flash.events.TimerEvent):void

{

return;

}

function loadComplete(arg1:flash.events.Event):void

{

shader = new Shader(loader.data);

filter = new ShaderFilter(shader);

image.filters = [filter];

return;

}