“An artificial neural network (ANN), usually called “neural network” (NN), is a mathematical model or computational model that tries to simulate the structure and/or functional aspects of biological neural networks. It consists of an interconnected group of artificial neurons and processes information using a connectionist approach to computation. In most cases an ANN is an adaptive system that changes its structure based on external or internal information that flows through the network during the learning phase. Neural networks are non-linear statistical data modeling tools. They can be used to model complex relationships between inputs and outputs or to find patterns in data.” (Wikipedia)
So, repetition is the mother of all learning they say. You damn right it is. And you can do it in AS3 of course. Not the fastest choice out there but that’s not the point. NN’s are usually not that fast but they’re useful in so many ways.
So, here is my implementation of a neural network multi-layer-perceptron made in AS3, set to learn a simple XOR problem. It uses 2 inputs neurons , 2 hidden layers, each having 2 neurons and one output neuron. It takes about 2 seconds to train it using 10.000 epochs, but then you can save a snapshot of the NN memory as a byteArray, save it to the server and load it back again in an instant without requiring a new training. I didn’t take the time to thoroughly document the classes just yet but I’m sure you’ll find them pretty easy to use.
Some reading material:
http://en.wikipedia.org/wiki/Artificial_neural_network
http://fbim.fh-regensburg.de/~saj39122/jfroehl/diplom/e-index.html (this is great)
http://www.ai-junkie.com/ann/evolved/nnt1.html
Sources and Download
Flex / ActionScript, Programming actionscript3, ai, artificial, flash, flex, intelligence, networks, neural
Yup! Flex Apps on your mobile. And I’m not talking about Flash Lite and you won’t need CS5 either.
ELIPS Studio converts the Flex code in native code for Windows Mobile, Symbian, Android, iPhone and mass-market mobiles. It’s still beta and you have to register for a beta account to get it but I think will do wonders for the mobile dev. world.
And in their words:
“ELIPS Studio 3 is a plug-in for Adobe Flex Builder, a widely used IDE for internet & desktop application. Our plug-in allows Flex to go mobile!
The product offers a mobile-optimized Flex Framework, plus numerous Flex extensions, including mobile UI components & access to mobile device features (voice call, SMS, access to calendar and contacts, to the camera, etc.)
The product includes a form-factor device simulator allowing you to see your application behavior on different devices. It also includes a network simulator allowing to generate calls, SMS, etc.”
So..get it while it’s hot
Flex / ActionScript, Programming android, as3, elips, flex, iphone, mobile, symbian, windows
The goal here is to use a TextArea component to display some text that doesn’t quite fit in the specified region and ellipsis points (…) should be showed to let user know the text is trimmed. Standard stuff right ? But Flex doesn’t do it by itself and I thought someone might look for this.
My problem was with a Flex app that uses i18n and in some languages the text didn’t fit the box, the scroll bar policy was off and user had no idea there was more text in there and didn’t had the possibility to scroll further. Anyway, here it is :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| <mx :Script>
< ![CDATA[
[Bindable]
private var text : String = 'The quick brown fox jumped over the lazy dog. ' +
'The quick brown fox jumped over the lazy dog. ' +
'The quick brown fox jumped over the lazy dog. ' +
'The quick brown fox jumped over the lazy dog. ' +
'The quick brown fox jumped over the lazy dog. ';
private function trim(text : String) : String
{
box.text = text;
box.validateNow();
if(box.maxVerticalScrollPosition > 0) {
text = text.replace("...", "");
text = text.substr(0, text.length - 1) + "...";
} else {
return text
}
return trim(text);
}
]]>
</mx>
<mx :TextArea id="box"
verticalScrollPolicy="off"
width="250"
height="50"
wordWrap="true"
text="{trim(this.text)}"
paddingBottom="0"
editable="false" /> |

Flex / ActionScript ellipsis, flex, points, recursion, textarea
I just finished writing a Flex3 library that will allow you to read a great number of image formats using flex and actionscript 3. The component uses a codec like rendering system, so each time you provide it with a source, the codecs attempt one by one to read the file signature and decide which one is fit to decode the image.
So doing this, it won’t matter the file extension or the way you provide the image asset (archived, link, base64 encoded, plain text, byteArray or embedded at compile time)
It’s a work in progress but curently I’ve made codecs for the following formats:
- PointLineCAD 3D objects (*.p3d)
- Photoshop images (*.psd, *.pdd)
- ZSoft images (*.pcx)
- Truevision TGA (*.tga, *. icb, *.vda, *.vst, *.win)
- Windows icon files (*.ico)
- GIF images (*.gif – static and animated gifs)
- JPEG images (*.jpg. *.jpeg, *.gfif)
- PNG (Portable network graphic) images (*.png)
- Windows Bitmap images ( *.bmp, *.rle, *.dib)
- Adobe Shockwave Flash (*.swf)
As I said before, the way you provide the source doesn’t really matter. You can zip up all your images in an archive and as source you can just point to the file inside the zip.
1
| <adm :ExtendedImage id="img" source="archive.zip://image.png" /> |
This way, you greatly reduce the number of requests to the server. But this is not all. Source can be also provided as a base64 encoded string, or as plain text (only p3d can take advantage of this since the p3d file is plain text as well).
For a bit more details, a demo and API description, visit this page
Flex / ActionScript, Programming actionscript, as3, component, flex, library
It may be interesting to know at runtime whether an application is running from a debug or release SWF file. It allows the application to automatically execute debug specific code when the file is a debug SWF file and ignore this code when it is published as a release file. Also, it should be nice to know if you have a debug flash player just for the same reasons. But for the last one, there is a function in the Capabilities class called isDebugger.
One solution would be to use conditional compilation. The other solution is in the following code (hack).
package org.adm.runtime
{
import flash.system.Capabilities;
public class ModeCheck
{
/**
* Returns true if the user is running the app on a Debug Flash Player.
* Uses the Capabilities class
**/
public static function isDebugPlayer() : Boolean
{
return Capabilities.isDebugger;
}
/**
* Returns true if the swf is built in debug mode
**/
public static function isDebugBuild() : Boolean
{
return new Error().getStackTrace().search(/:[0-9]+]$/m) > -1;
}
/**
* Returns true if the swf is built in release mode
**/
public static function isReleaseBuild() : Boolean
{
return !isDebugBuild();
}
}
}
This code simply searches for line numbers of errors in StackTrace result. Only StackTrace result of a debug SWF file contains line numbers. Then we know that we are running a debug or release SWF file.
This class is also available in the Components Pack at Runtime subpackage
Flex / ActionScript, Programming actionscript, as3, debug, flex, release