Having a fantastic time here in Toronto, although in a supreme display of poor planning my session is at 9am this morning! Never fear! We shall fight the hangovers from the awesome party last night (thanks Influxis) and produce more crazy particle effects! As ever, bring your laptop [...]
I just updated The GAE SWF Project to version 1.21. New source code for the update is now available for download. All changes in this version are server-side: All requests apart from those to the PyAMF gateway go through the IndexHandler class. The app.yaml file no longer maps /examples/ urls to the various example SWF applications (currently [...]
I'm pleased to announce that the Prana Framework 0.5 release is now available. Download | API Documentation | Changelog In this release we further focused on bringing the core Inversion of Control container API closer to that of the well known Spring API. In addition, the release also contains the following: an XSD for editing object definition XML files application context classes that [...]
Just a quick note to let you know that I’ll be giving a presentation on Prana at the Dutch Flex Usergroup called Flugr on the 13th of June. So if you’re in the neighborhood (Utrecht) and would like to meet, feel free to visit the event. The following sessions will be given: - Benjamin Dobbler & Stephan [...]
*UPDATED FOR GREAT WHITE* I have many requests by e-mail to update this example for Great White. Here you go: In case your curious, that’s a picture of me and my son. I’m the one on the right First you must download Tweener from here: http://code.google.com/p/tweener/downloads/list and add it to your classpath just [...]

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.

Whilst working today in Flex Builder we all did an update on SVN and all of a sudden we all had the same error... Description: An internal build error has occurred. Right-click for more information. Location: Unknown So off we went trying to find the problem as there wasn't any other info on the error. We trawled through all sorts [...]
Whilst working today in Flex Builder we all did an update on SVN and all of a sudden we all had the same error... Description: An internal build error has occurred. Right-click for more information. Location: Unknown So off we went trying to find the problem as there wasn't any other info on the error. We trawled through all sorts [...]
iSpy was created based on Doug McCune’s Simple Flex Motion Detection example In addition to Doug’s web based motion detector, iSpy uses the AIR File and FileStream classes with the JPEGEncoder class to do its magic. If there is a level of motion that exceeds the sensitivity level, it will either take a quick snap shot [...]
Richard Lord over at Flash Game Code has released a few useful AS3 classes. One of which is the KeyPoll class. This is really useful because the Key.isDown event no longer exists in ActionScript 3. Here is a quick example I knocked up … The Flash source code for this can be downloaded [...]
Earlier this year, I came to understand how to use interfaces in ActionScript 3. I used them in a particular case where polymorphism was needed but that was it since then. Last week I realized that I could use them in much more case than that. I actually need them in nearly all of my [...]
I got some feedback about the sound equalizer that I posted a few days ago, and especially about the reflection effect I used in there. I thought that maybe it was a good idea to write a tutorial about how to make these kind of reflection using AS3. It is a pretty straightforward technique, but [...]
Here is the reason why I was quite busy lately, after almost one year of work, my ActionScript 3 book is finished. Almost 1200 pages of pratical ActionScript 3 As you may know this book was supposed to be released by O'Reilly France, but it couldn't be released for different reasons. After a few days [...]
PlanetFlash.org is here! Planet Flash is a central place to look for news from the Flash community. It downloads news feeds published by blogs from Flash designers and Flash developers all around the world and aggregates their content together into a single combined feed, latest news first. Let me know if you don’t find your Flash blog [...]
While working on a recent campaign we had a bit tricky production pipeline. Our 3D artist was working with modo but needed to export to Collada (which is not supported by modo and currently one of the best supported formats in Papervision3D). To be able to export his work to be used with Papervision we [...]
Error: No class registered for interface 'mx.resources::IResourceManager'. If you have experienced this before, you are in for a bumpy ride. There are loads of these errors floating about when using the flex sdk to compile your project with. The reasons are vast and different but basically boils down to dependencies. Classes within the flex framework depend on a heap of other classes, that is why it is known as an Application framework.

This is something we all experience on a daily basis, we want to use some piece of code written for a previous project, and quite often we find ourselves spending way more time to make the code standalone that we would have like to. Very similarly, I want to use the RPC package for various reasons but without using the whole Flex Application framework.

So where does ResourceManager fit in and why is there no class registered for interface IResourceManager?

I’m flying with fellow Plug-in Media colleagues Juliet and Sarah to New York on Tuesday to meet with clients that I’m not sure I’m allowed to talk about… but we’re producing some cool Flash 3D for a massive US sports company… seriously exciting work so watch this space for more details. And I’m taking the [...]
The Rolls-Royce of the FDT 3.0 family, Enterprise, was released a couple days ago. This probably isn’t news to you anymore but I thought I’d mention it anyway. I’ve got to say I’m very happy with where the Powerflasher team has taken this magnificent tool. Today I find it hard to work without FDT mostly because [...]
…and end the drawNow madness. I knew something was SERIOUSLY wrong when I read in the official docs (Part 3) from Adobe that if your code doesn’t work correctly, try using “drawNow”, and failing that, “validateNow”. What do you mean “try”? What… the… hell…
Got a background music on your Flash website? It would be nice to add a tiny equalizer in the footer. Or maybe you're developing an AS3 application that features MP3 playback? An equalizer will surely be useful in there too...

Subscribe to Planet Flash

Search

Tags

3d Actionscript actionscript 3 ActionScript 3.0 Adobe Adobe Air Adobe AIR (Apollo) Adobe Flash Adobe Flex AdobeMAX08 AIR AIR Adobe Integrated Runtime Announcements apollo as3 Asides awards BEA Beautiful Web Business Cairngorm ColdFusion Community Components Conferences design dev Development Events Examples Featured Flash Flash CS3 Flash experiments flash player Flex Flex 3 Flex Example FMS Fun Gallery General Google Jobs Marketing MAX MAX 2007 Misc News Open Source Other Papervision3D Personal photos Photoshop Process Processing RIA Stuff techmology Technology Thinking Loud Uncategorized Whatever

Blogs

Buttons

Planetarium