Tip #1: Using negative numbers with String operations

Every now and then you need to remove some characters from a String, and when is from the end of the String what I normally do is calculate the length of the String and subtract the amount of chars to remove.
for example:
1
2
var test:String = "This is a tip and trick";
trace (test.substr (18, test.length)); // Output: trick
But after checking the String Doc’s I found an alternative.
If endIndex is a negative number, the ending point is determined by counting back from the end of the string, where -1 is the last character.

So, with this we could do:

1
2
3
var test:String = "This is a tip and trick";
trace (test.slice(10, -10)); // Output: tip
trace (test.substr(-5)); // Output: trick

I don’t know if this is obvious for you but I haven’t tried this before…

Hope this can be useful
Gus

Jobs vs Flash

I’ve been reading a lot about this topic and feel there are always a couple of points in my opinion left unsaid…

  • First of all I believe its pretty irresponsible say that the main reason of crashes in MacOS is the FlashPlayer. Flash is only a tool and as EVERY tool there are ways of using them wrong. Adobe shouldn’t take the responsibility for bad programmers. If that’s the case Adobe could say that the flash player runs in MacOS thus it’s a MacOS problem. Should be pretty easy create an application with lots of leaks for the iPhone which crashes, and] shouldn’t be the fault of the IPhone but of the App.
  • After reading this Jabcob Nielsen report about iPad Usability and knowing how Jobs thinks I could conclude that the iPad doesn’t work, but this means there are room for improvement.

  • Second excuse used against Flash it’s that a platform independent application won’t take advantage of all the advantages a particular platform offers. I think this depends on how its implemented which could be a requirement from Apple and not an excuse to deny it. And why I think it depends on the implementation? basically think that this particularities should be transparent for the developer, how the app its going to behave when its minimized or in background should be responsibility of the Flash Player (how in fact is handle from version 10.1)

After a lot being said against Flash I’m more convinced this is a direct attack against Flash directly or there is any other reason why in almost every attack posts no one mention Silverlight or any other plug-in? If the community is so certain that plug-in are going to die why the need to Kill them now? isn’t better to let the time determine who has the reason instead of looking like an Ass? I’m sure Adobe will continue innovating and adding more cool stuff in the player!

Here are a collection of interesting posts about the topic:

And to conclude I just want to say that I’ve been working with Adobe Flex for a long time now and I’m a proudly owner of a Mac but I just can’t agree with one person telling what not to use. And yes, Adobe is not the most open Company of all but surely is more open than others, and its trying…

Well those are my two cents… ;)

[Offtopic]A Sublime Celebration!

This is one of the most important music related news this month… or maybe this year!! XD it’s about the “celebration” of SUBLIME! this is kind of complex for a Sublime fan… but I have to admit I love the way the guys are taking it… its not a reunion nor a come back… its a celebration of Sublime music…of Bradley.

I invite every fan out there to read an interview made to Bud (founder/drummer) which is posted in they MySpace real page and to visit the band member ROME MySpace

They recently were interviewed by Kevin & Bean at KROQ and you can watch some performance videos at YouTube…

Adobe Max Online

The Adobe Max just started… couln’t be there but watching online :D And expecting the announcements!!

Improving Flex code (FlexPMD)

As this topic is highly talked in English I’ll leave the long post to the Spanish page… I will only have to tell you that if it doesn’t work (specially in automator) you should check the path to the files in the script… it happened to me and spend a while until I figured out hehehe….

If you want more info or download follow the golden path http://opensource.adobe.com/wiki/display/flexpmd/FlexPMD

So, hope this helps and happy code improvement!!

(Español) Un error común con la carga de modulos

Sorry, this entry is only available in Español.

Flex Coverage

This is a GREAT tool for a Flex Developer… I think everyone should used to be sure every part and every condition of a programm is tested…

You’ll only have to replace some files in your Flex SDK folder, set the new SDK in eclipse (if your building with it, see the docs for ant instructions), rebuild and set to go.

Within the downloaded files you’ll have an AIR app to see the result of the coverage, in here you load a file auto-generated in your bin folder and enjoy the results… and the best thing is that it updates automatically!!! as you walk thru your app…

Another important thing is that you can turn it off if you want without having to change the SDK, just add the parameter coverage=false to the compiler

So, here’s the link: FlexCover

Flexlib Scheduling Sample

Recently had to build a component to do some scheduling… so first started to browse for some sample and options I had and found three options: First pay for the iLog Elixir components which has a pretty good scheduling component, but paying for that was not an option to us.

Then I found the Doug’s post about the gantt chart component and flexgeek post (with doug’s same approach). this seemed a good option and actually started to develop it on top of flexgeek’s component, but as I test it found a leak that didn’t allow the grid’s columns to get GC’d and when a drill down/up was made all the columns where removed and added (not really)… also I wasn’t able to show two month in a day view for example.

So, I went for the Third option… the so feared and undocumented scheduling library (now in flexlib, previously in adobe’s lab). Surprisingly I thing it was the best option, don’t know why nobody tried before, maybe the lack of samples… just had to made some modifications to the lib to add some events like click and drag over the items and some timeline modifications so it’ll be like the iLog’s component.

I think that there is a couple of modifications needed in the component and thats it to use the hierarchical classes in flex (my approach wasn’t the best but for time problems it seemed the quick and lazy way), and adding styles and colors.

I haven’t been able to finish it due to a change of priorities in the company but here it is… (viewsource is enabled)

Scheduler component Sample

Scheduler component Sample

and here is the flexlib source with my modifications (download), I have to separate more my classes from the originals

I’ll be posting more on the modifications I made to the libs

Any feedback will be appreciated :)

Decompling Flex Code

Recently I was playing with the decompiler after reading doug’s post about decompile flex code, and got to say that my inner geek wanted a ABC debugger just to see how it behaves in run time and understand better the ABC code (I don’t know if such thing exist but it would be soooo nice)…

You’ll need some tools, and Sothink Decompiler is a very good one, but it won’t give you the same clean result as decompiling Java code,  next there are a couple of air apps that will show you the ABC code and help you fix the error in the decompiled code. These are LibraryManager and Nemo 440, both gives you the ABC but the first one is more organized IMHO although it eats some of the functions header and you’ll need this, so I used both programms.

And last but not least, as Doug point it out in his blog, there are the SWF and AVM 2 Specs docs, I used more the last one just to trying to figure out what the ABC was doing.

So, here are some tips:

  • if you see something like var private::_1455875791myVar:Object    /* slot_id 0 */, and then a function like [Bindable(event="propertyChange")]
     function get myVar():Object    /* disp_id 0*/
      {
        //Some ABC Code
      }
function set myVar(Object):void    /* disp_id 0*/
{
  // More ABC Code
}

this mean the there is a Bindable var named myVar so you could just replace this with

[Bindable]
private var myVar:Object
  • Imagine you have a class named MyClass (pretty creative) and you see another class under a package named MyClass.AS$42 means that the second class is a inner inside MyClass, so don’t try to add that package because you’ll get reference errors.
  • I don’t know if this is 100% correct but when you see  /* slot_id 0 */ means private function or var and /* disp_id 0*/ is a public one

These are some things that I learned while browsing the ABC, is not much but hope it helps someone…

Hello World! Hello Flex!

This is my Flex related Blog and maybe some other stuff… althoug I’m not much of a writter I hope to update it every now and then, hoping to help other fellow Flex coders.

I’ve got some projects which involve RoboHelp to create Flex/Air context sensitive help, playing with the Flex Scheduling Components, Merapi and some accessibility tests. So, some interested in some of these topics just check the blog and don’t worry, I’m planning to share the code, examples and any discovery I may make…..