Fix =no MapCSS check. This must be the longest-standing bug in P2...
[potlatch2.git] / net / systemeD / halcyon / styleparser / Eval.as
1 package net.systemeD.halcyon.styleparser {
2
3         /*
4                 === Eval ===
5
6                 This serves as the EventListener for an eval rule and copes with subsequent invocations.
7
8         */
9
10         import flash.display.Loader;
11         import flash.display.LoaderInfo;
12         import flash.events.Event;
13         import flash.system.ApplicationDomain;
14         import flash.system.LoaderContext;
15         import flash.utils.ByteArray;
16
17         import it.sephiroth.expr.CompiledExpression;
18         import it.sephiroth.expr.Parser;
19         import it.sephiroth.expr.Scanner;
20
21         public class Eval extends Loader {
22
23                 private var swfclass:Class;
24
25                 public function Eval(s:String) {
26                         var scanner:Scanner=new Scanner(s);
27                         var parser:Parser=new Parser(scanner);
28                         var compiled:CompiledExpression=parser.parse();
29                         var swfdata:ByteArray=compiled.compile();
30
31                         this.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded, false, 0, true);
32                         this.loadBytes(swfdata, new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)));
33                 }
34                 
35                 private function swfLoaded(event:Event):void {
36                         var info:LoaderInfo = event.target as LoaderInfo;
37                         swfclass=info.applicationDomain.getDefinition( "CompiledExpression" ) as Class;
38                         dispatchEvent(new Event("swf_loaded"));
39                 }
40                 
41                 public function exec(tags:Object):* {
42                         if (!swfclass) { return null; }
43                         var cp:Object=new swfclass();
44                         for (var k:String in tags) { cp[k]=tags[k]; }
45                         return cp.execute();
46                 }
47         }
48 }