Ok, I am a bit late with my report but I was a bit busy the last weeks working on the Multi-Mania conference we are organizing in May but I really wanted to make a short wrap up of the conference. In some words : 360 FLEX Europe was fantastic !! I cannot describe it in [...]

Finally I have a bit of free time to write down this post. Some days ago a guy on the forum asked about how to evaluate at runtime simple mathematical expressions with support for symbols and function calls.

Now that the eval function have been removed from the language for reasons I've not enought time to talk about, we need to parse and execute those expressions manually.

I built a simple Actionscript library that can be used to parse mathematical expressions: it has support for function calls, for variables and it is able to convert the expression into a postfix rappresentation if you may need it. The expression parser is quite simple and have been built manually following some concepts related to programming language compilers; it includes a Scanner (or lexer - however you want to call it) to tokenize the expression, a Parser that convert the expression into an Abstract Syntax Tree and a simple routine that evaluates that AST using a Symbol Table as evaluation context.

There are no comments inside the code right now; I hope to find a little bit of time to write an in depth discussion about this topic. In the mean time you can continue reading the entry for a general explanation about how does the code works and for some examples that may be useful.

Here is a simple example that shows how does the code works:


import it.sephiroth.expr.CompiledExpression;
import it.sephiroth.expr.Parser;
import it.sephiroth.expr.Scanner;

public class Example
{
  public static function run(): void
  {
    var expression: String = "sin( x / ( 8 / 2 + (-0.12 + 2.3) * x / x ) ) * 100";
    var scanner: Scanner = new Scanner( expression );
    var parser: Parser = new Parser( scanner );
    
    var compiled: CompiledExpression = parser.parse();
    
    var context: Object = {
      x:    100,
      sin:   Math.sin,
      cos:  Math.cos
    };
    
    trace( 'Postfix:', compiled.toString() );
    trace( 'Result:', compiled.execute( context ) );
  }
}

Before I forgot, you can download the source code here with a simple example included.

I've been working on a project lately that uses Flex, AMFPHP, Propel and MySQL. For most of you these technologies may be well known, except maybe for Propel. In this post, I'll briefly mention what Propel is, what it does and how you can hack the AMFPHP Deserializer to make maximum use of Propel. Propel From the [...]
If you want to distribute AIR applications the install badge is definitely the best way to go. The one problem I had with it is that its a pain to prepare and embed on your blog. To help remedy this I started working on this AIR Badge plugin last night, it allows you to simply use [...]
I’m up bright and early to do some last minute packing and head to the airport for FiTC Toronto. Yeah! But I did want to mention that Flash on the Beach tickets are now on sale! There are 250 earlybird tickets at an unbelievably low price. You know you’re going, so get in cheap! http://www.flashonthebeach.com/tickets/
BLITZ helped our clients at Naked Juice launch a new website that reflects the company’s promise of delivering a pound of bare-naked, all natural fruit in every 15.2 oz bottle of juice (or half pound of fruit in every 10 oz bottle).  In addition to learning about all of the goodness that goes into every product, visitors can [...]
Today I'm releasing The GAE SWF Project, a resource of Flash and Flex-related knowledge specifically aimed at getting you up and running quickly with Google App Engine. If you want to skip all the details and start playing with it, skip to the Getting Started section. Everyone else, read on! When Google announced Google App Engine last [...]
I wrote a news aggregator a couple of years ago called Newsbrew which I primarily used for my own news-reading needs. After Google launched the Google App Engine, I decided to take a little break from Flex and AIR and rewrite Newsbrew in Python to get a good feel for the GAE experience.
If you missed my SQLite talk at one of the onAIR tour events earlier this month, Mike Chambers recorded it in Brussels and its now available to watch online. Upcoming events where I’ll be covering Adobe AIR are Multi-Mania, Scotch on the Rocks and another In-the-Brain session on “The Evolution of the Flash Platform” with [...]
Anyone know what's going on here? I have a property on a model that is bindable: PLAIN TEXT Actionscript: [Bindable] public var currentAmount:Number = 0; I have a command that increments that value, by some fractional amount: PLAIN TEXT Actionscript: [Bindable] model.currentAmount += 1.25; What's happening is I am winding up with values like 1.25000000000000000001. Even wierder is that the last [...]
Just putting this up there in case anyone else needs it: if you are trying to get rounded corners on your container (like HBox) by setting the cornerRadius style, you need to make sure that you also set the borderStyle to 'solid' or the rounded corners won't render. You can set the borderThicknessProperty [...]
If you are in, or can get to, or would like to travel (travel expenses paid) to Detroit next week to work on a small AIR (Flex) project then please leave a comment or shoot me an email.
If you're spending a decent amount of time manipulating images in php using GD or command-line ImageMagick, you should check out the Imagick php extension. Imagick provides an object-oriented interface to the ImageMagick API. As far as I can tell, this extension was left for dead a while ago but revitalized over the last [...]
Two quick notes related to Control Bars in Flex. First, I was trying to get an ApplicationControlBar to dock to the bottom of the app, which I couldn't get to work. Maybe someone could point out a better solution, but I went with using a DockableToolbar from the awesome flexlib and setting draggable=false. The [...]
Ran into an issue today with AMFPHP trying to send an ArrayCollection...it kept choking when trying to decode the collection. I knew this was already possible, but forgot I had installed the php extension AMFEXT, which handles the encoding/decoding for amfphp when it is installed. Turns out that it doesn't like incoming arraycollections. [...]
Sheesh...I just wasted half a day trying to figure out how to get a borderSkin to appear on top of all the children in a custom component I was building. It was a subclass of Canvas, so it was really easy...now that I know, it seems so obvious I want to kick myself. [...]
There is a weird bug in AMFPHP regarding sending negative integers. If you try and send a number such as -87, it shows up as 4294967209 in php. I did some digging and found on the amfphp forums that it has to do with amfphp's readAmf3Int() method in AMFDeserialzer.php. Here is the [...]
I wrote this up for a client, and realized I had given some version of this many times, so since I had it all written out I figured I'd post it here. I was trying to keep it somewhat high-level, as it's generally targeted towards the non-developers. Originally there was Flash. Flash was [...]
I was doing a bunch of Flex work for the past few months, and get really comfortable with Flex Builder. There are so many awesome features to aid development it simply kicks ass. However, my current project is Flash CS3-based, so I went back to TextMate, which I also love. There are [...]

Subscribe to Planet Flash

Search

Tags

<head> 3d 3d Flash Actionscript actionscript 3 ActionScript 3.0 Adobe Adobe Air Adobe AIR (Apollo) Adobe Flash Adobe Flex AdobeMAX08 AIR AIR Adobe Integrated Runtime Announcements apollo Art AS2 as3 Asides awards Babble BEA Beautiful Web Books Business Cairngorm ColdFusion Community Components Conference Conferences degrafa design dev Development Events Examples Featured Flash Flash CS3 Flash experiments flash player Flex Flex 3 Flex Builder Flex Builder Development Flex Example FMS Fun Gallery General GeoWeb Google Industry Inspiration iphone Jobs Links linux Marketing MAX MAX 2007 Misc News news & events Off topic Open Source Other Papervision3D Parallax Denigrate Personal photos Photoshop Process Processing Resources RIA Singularity Site News Stuff techmology Technology Tennis Thinking Loud Tips Uncategorized Video Whatever

Blogs

Buttons

Planetarium