search
top

Trim-it

http://tr.im/remus

RIA in Russia – English please :)

Clearly there are a lot of developers in Russia and ex-soviet countries. I am really happy to see a lot of RIA dedicated sites and some of them have linked articles from my blog. Thank you.

This links have brought also some comments for my articles. Some of them were good some were spam. Most of them were in Cyrillic. Due to my 3 years of learning Russian in school (let’s not forget Romania was under communism for quite a while and a good friend of Russia) I can still understand the alphabet. That doesn’t mean I can understand what is saying in a comment but most of the time I can figure out if it is a spam. However I decided not to allow any comment written using the Cyrillic alphabet or even not written in English.

You have my apologies if I deleted your valid comment but this is an English (or at least as English as I can write :) ) blog. Please write your comments in English.

Adobe Developer Day in Romania

Adobe Romania is organizing a developer day in Bucharest on 19th May. More information can be found on Adobe Romania site. It is about Flex, Flash, AIR, web technologies, RIA, ColdFusion and a lot more.

You will have the chance to meet with Ben Forta – Senior Evangelist, Digby Horner – SVP Emerging Markets and lots of Adobe Romania people.


replace vs. split and join performance in ActionScript 3

In the previous article inside the source code for the regular expression tester you can find the following line:

var htmlString:String = string.split("\n").join("<br />");

I have found this in an ActionScript 3 example at one time and I remembered this as it is a nice construct. However there is another, more common way to write this:

var htmlString:String = string.replace(/\n/g, "<br />");

So I start questioning myself, which one is faster?

After running some tests the results are: split and join ~ 1100ms, replace ~ 800ms. The test was run on a generated string of 16 mil. characters. So, unless you are planning to do this operation on a large data set the difference is not that big and it does not matter which one you will use. For 100k characters both score around 15ms.

Flex Regular Expression Tester – source code

There are a lot of improvements that can be made to this piece of code and when I will get some time I will move forward with the changes. Until then I will post here the source code as it is still small and developers new to the world of regular expressions may learn something from it.

BTW, I have used Flex 4 :)

(updated on 04.15.2009)

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
   3:      xmlns:s="library://ns.adobe.com/flex/spark" pageTitle="Flex Regular Expressions" 
   4:      xmlns:mx="library://ns.adobe.com/flex/halo" height="400" 
   5:      viewSourceURL="srcview/index.html" creationComplete="init()">
   6:      
   7:      <s:layout>
   8:          <s:BasicLayout/>
   9:      </s:layout>
  10:      
  11:      <fx:Script>
  12:          <![CDATA[
  13:          import mx.skins.spark.ButtonSkin;
  14:          private var error:String;
  15:      
  16:          protected function test_btn_clickHandler(event:MouseEvent):void
  17:          {
  18:              var restr:String = regexpInput.text;
  19:              var input:String = textInput.text;
  20:              var igstr:String = modifInput.text;
  21:              
  22:              this.error = null;
  23:              
  24:              if(restr != null && restr != '' && input != null && input != '') {
  25:                  var myPattern:RegExp = new RegExp(restr, igstr);
  26:   
  27:                  var result:Object = myPattern.exec(input);
  28:                  
  29:                  var a:String = '';
  30:                  var b:String = '<br />';
  31:                  var index:int = 0;
  32:   
  33:                  while (result != null) {
  34:                      // copy string from last match
  35:                      a += '<span>' + encode(input.substring(index, result.index)) + '</span>';
  36:                      index = result.index;
  37:                      
  38:                      // copy the matching parts
  39:                      a += '<span color="#339933">' + encode(result[0]) + '</span>'
  40:                      index += result[0].length;                
  41:   
  42:                      // create the trace string
  43:                      b += '<br /> ' + result.index + '\t'; 
  44:                      for(var i:int = 0; i<result.length; i++) {
  45:                          b += result[i] + ',';
  46:                      }
  47:                      
  48:                      if(igstr.indexOf('g') == -1) {
  49:                          a+= input.substr(index);
  50:                          break;
  51:                      }
  52:                      result = myPattern.exec(input);
  53:                  }
  54:                              
  55:                  a += '';
  56:                  resultText.content = a + b;
  57:              }
  58:          }
  59:                      
  60:          protected function encode(string:String):String {
  61:              var htmlString:String = string.replace(/\n/g, "<br />");
  62:   
  63:              return htmlString;
  64:          }
  65:          ]]>
  66:      </fx:Script>
  67:   
  68:      <s:Panel id="contentPane" width="100%" height="100%" left="0" 
  69:          title="Flex Regular Expressions" >
  70:          
  71:          <s:TextArea left="10" right="10" height="150" top="10" 
  72:              text="She sells seashells by the seashore" id="textInput" />
  73:          <s:TextInput text="(\w*)sh(\w*)" id="regexpInput" left="10" top="168" right="175"/>
  74:          <s:TextInput id="modifInput" text="ig" right="85" top="168" width="78"/>
  75:          <s:Button label="test" id="test_btn" right="10" top="168" 
  76:              click="test_btn_clickHandler(event)"/>
  77:          <s:TextArea id="resultText" left="10" right="10" top="198" bottom="10"/>
  78:      </s:Panel>
  79:      
  80:  </s:Application>

Barcode 2d meet Microsoft Tag

VS Microsoft Tag

Both of this images represent my vCard – pretty much the same information. In order to read them you would need specialized programs. For the first one I found out that QuickMark v3.6R is a great tool to use (there are other tools out there as well) as for the second one the only possible tool is Microsoft Tag.

There are other differences also in the way the information is stored. The 2d barcode has the information stored in those black dots and the Microsoft Tag is just a graphical representation of an URL in my opinion. I say that because when I scan the Microsoft Tag an internet connection is required in order to retrieve the information from my vCard.

Aside from this, I think I will create a sticker with my barcode 2d for my cars window so when I block somebody in the parking lot they will have a way to find out my phone :) .

Flex Regular Expressions Tester – a new version

Some time ago I have created a Flex regular expressions tester. When I have moved my site to ICE I have decided to improve a little bit this tester and right now there is a new small Flex application that can be used to play around with some neat symbols :)

http://www.stratulat.com/Regular_Expressions_Flex.html

"Bended" Spaz – a practical application for Pixel Bender

I have written before about Spaz – the Twitter client I use.

Because it is written in AIR and because is open source and AIR 1.5 just got out with new interesting features, I thought, why not “bend” a little Spaz, just for fun.

I say just for fun because it was not something done after a careful consideration of the usefulness of adding this effect in Spaz.

I have used as a starting point the BlaskBookSafe application described in my previous post. The changes made in Spaz were as follows:

  1. I have updated spaz/assets/air/AIRAliases.js with the last one provided by Adobe AIR SDK 1.5
  2. I have copied the bender folder from BlackBookSafe into spaz
  3. I have copied BenderEffect.js and Tween.js from BBS to spaz/assets/lib folder
  4. I have added some small pieces of code in spaz/index.html and spaz/assets/assets/spaz.prefs.js

The added code in index.html was of course importing those two scripts added in the lib folder. We need them in order to create the effect and also to “tween” it, to transform the bend into an animation.

The code from spaz.prefs.js is a little more complicated and it creates the bend effect and starts the tween:

   1:  'window-alpha': {
   2:      setUI: function(value) {
   3:          $('#window-alpha').val(parseInt(value));
   4:      },
   5:      onChange: function(value) {
   6:          //alert(percentage+"%");
   7:          percentage = parseInt(value);
   8:          if (isNaN(percentage)) {
   9:              percentage = 100;
  10:          }
  11:          if (percentage < 25) {
  12:              percentage = 25;
  13:          }
  14:          var val = parseInt(percentage) / 100;
  15:          if (isNaN(val)) {
  16:              val = 1;
  17:          } else if (val >= 1) {
  18:              val = 1;
  19:          } else if (val <= 0) {
  20:              val = 1;
  21:          }
  22:   
  23:          /*  the bending code */
  24:          BlenderEffect.get('app:/bender/page.pbj', function(shader){
  25:              var tween = BlenderEffect.createShaderTransition(window.htmlLoader, 
  26:                  shader , 1200, Tween.effects.elasticEase);
  27:              tween.hideOnFinish = false; 
  28:              tween.start(true);
  29:          });
  30:   
  31:          window.htmlLoader.alpha = val;
  32:      },
  33:      check: function() {
  34:  .....
  35:  }

The addition was inside the onChange method for the window-alpha setting.

The reason I choose this method was to have a visual indication for changing the alpha setting from preferences. With all this in place, when changing the alpha setting for Spaz a nice effect will warp a little bit the window. I will let you to discover this as an image will not do it.

In the mean time I will send an email to Funkatron, maybe they will be interested in incorporating this in a more useful way :) .

Adobe AIR 1.5 is out, now we can bend some pixels.

The last version of Adobe AIR is 1.5 and brings a lot new features especially through integrating Flash Player 10 and updating the included WebKit. More about this can be read on Adobe AIR team blog.

What I want to talk about is a new sample made specially to show the new capabilities of this release, BlackBookSafe. It is an HTML/JavaScript application using jQuery framework and leveraging the encrypted local database, 3d transformations and Pixel Bender effects. Indeed, with the new AIR you can “bend pixels” :) .

BlackBookSafe screen

BlackBookSafe screen

BlackBookSafe bended screen

BlackBookSafe bended screen

The effect was created using the Adobe Pixel Bender available in Flash Player. And yes, I said that BlackBookSafe was created using HTML and JavaScript. You want to find out how was it done? Mihai Corlan, an Adobe Platform Evangelist wrote an article detailing exactly how this application was created in BlackBookSafe: Anatomy of an AIR 1.5 application.

My site on ICE

Recently, to support the testing effort for the Adobe InContext Editing, I have changed all my site to benefit from this new service from Adobe. I was pretty bored with the old design so my site has a new look also.

my site on ice

My site on ICE

Adobe InContext Editing is an online service, available at no charge during the free preview period. It is a RIA application combining both Flex and JavaScript to create a very useful and simple tool to be used by both content contributors and web designers.

Basically what you do is create an HTML page and add some ICE editable regions from Dreamweaver CS4. Then you go in your browser at the same page and hit Ctrl+E and voila.. you can edit that page (in the image above is my Java page after I have done just that). If you need a similar page (let’s say Ajax in my case) you just hit the “duplicate page” button and that is all (aside from additional editing of that page).

« Previous Entries Next Entries »

top