A Cyberlynxx está com uma oportunidade para Desenvolvedor de Sistemas Mobile. Segue requisitos da oportunidade: – Programação: ASP.Net, C#, Javascript, PL/SQL; – Banco de dados : SQL Server e/ou Oracle; – Experiência em trabalhar com Framework 3.5 ou superior; – Experiência em desenvolvimento de sistema para Windows Mobile; – Conhecimento de gravação e leitura de [...]
Oportunidade para Desenvolvedor de Sistemas Mobile – Rio de Janeiro
Server-Side ActionScript no Flash Media Server
Poucos sabem mas o Flash Media Server(versão Interactive) possui uma linguagem de servidor chamada Server-Side ActionScript ou ActionScript Communications(extensão .asc). O que permite recurso poderosos em seus aplicativos multimídia muito além de um simples streaming.
Server-Side ActionScript é o nome que Adobe deu para o JavaScript 1.5, o Flash Media Server possui uma engine de JavaScript para compilar e executar os scripts.
O Server-Side ActionScript é parecido mas não idêntico ao ActionScript 1.0, mas ambos são baseado no ECMAScript(ECMA-262) edition 3 language specification. O Server-Side ActionScript roda sob a engine SpiderMonkey da Mozilla que consta no Flash Media Server enquanto que o ActionScript 1.0 roda sob o AVM1(ActionScript Virtual Machine 1) no Adobe Flash Player. O SpiderMonkey implementa o totalmente o ECMAScript enquanto que a AVM1 do Flash Player não. A grande diferença entre os dois é que o Server-Side ActionScript é case-sensitive.
Portanto para quem já tem conhecimento de JavaScript, pode reaproveita-lo para usar no Flash Media Server, é possível utilizar a maioria dos recursos e ainda contar com os recursos exclusivos do Flash Media Server.
Vamos os primeiros passos para utilizar o Server-Side ActionScript no Flash Media Server. Uma maneira de testar seus scripts é usando o fms_console localizado no caminho:
INSTALATION FOLDERAdobeFlash Media Server 4.5webrootswfsfms_adminConsole.swf
Se você tiver o Adobe Flash Professional, pode abrir esse arquivo diretamente apenas dando dois cliques, caso contrario, abra pelo navegador. Ao ser aberto, devemos ter uma tela como essa:
Basta entrar com o login e senha que você determinou no momento em que estava instalando o Flash Media Server que deveremos entrar para a seguinte tela:
Esse será seu melhor amigo ao desenvolver aplicativos com Flash/Flex e Flash Media Server. Por padrão, o Flash Media Server lê o seguinte diretorio:
INSTALATION FOLDERAdobeFlash Media Server 4.5applications
Esse caminho pode ser configurado modificando a linha “VHOST.APPSDIR” no seguinte arquivo:
INSTALATION FOLDERAdobeFlash Media Server 4.5conffms.ini
Criaremos um diretorio chamado “teste”, e dentro dele um arquivo chamando “main.asc” com o seguinte conteúdo:
-
// ActionScript Communications Document
-
trace(“init app…”);
Agora no console, carregaremos nossa aplicação criando uma nova instância dela selecionando no combobox:

Na tela seguinte, basta dar um “enter”.

Deveremos ter o resultado do nosso trace na caixa de texto como na imagem:
Uma recomendação que faço é que você limpe a tela antes de executar novamente o script main.asc, basta clicar no botão Clear Log(1) e depois em Reload Application(2):

Alguns exemplos do que pode ser usado com o Server-Side ActionScript
Constantes
-
// ActionScript Communications Document
-
trace(“init app…”);
-
const PI = 3.14;
-
trace(PI);
Expressões Regulares
-
// ActionScript Communications Document
-
trace(“init app…”);
-
myRe = /d(b+)d/g;
-
myArray = myRe.exec(“cdbbdbsbz”);
-
trace(myArray);
Funções
-
// ActionScript Communications Document
-
trace(“init app…”);
-
function teste()
-
-
return “to na funcao o/”;
-
-
trace(teste());
-
-
function factorial(n)
-
-
if ((n == 0)
-
}
-
trace(factorial(5));
Objetos
-
// ActionScript Communications Document
-
trace(“init app…”);
-
var obj = id:“teste”,data:2,status:“ONLINE”,type:“admin”
-
trace(obj);
-
for(s in obj)
-
-
trace(s +” – “+obj[s]);
-
Array
-
// ActionScript Communications Document
-
trace(“init app…”);
-
var arr = ["leo", "carol", "pam", "perla","carlinha"];
-
trace(arr);
-
function removeValueFromArray(arr, value)
-
-
var len = arr.length;
-
-
for(var i = len; i> -1; i–)
-
-
if(arr[i] === value)
-
-
arr.splice(i, 1);
-
-
}
-
return arr;
-
}
-
trace(removeValueFromArray(arr,“pam”));
Aviso importante, use esses recursos SOMENTE em ambiente de desenvolvimento. Em ambiente de produção, você derrubará todo mundo que estiver conectado ? sua aplicação.
![]()
Referência:
Documentação do Adobe Flash Media Server
Depois de 6 anos de Flex, irei migrar para HTML5?
Regra geral não sou apologista de dispersar conteúdo, nem de fazer posts no riapt em Inglês. Neste caso em específico, visto tratar-se de um assunto que está na ordem do dia, vou abrir uma excepção e duplicar aqui um post que fiz no Google+. O endereço original é este:? https://plus.google.com/109047477151984864676/posts/CVGJKLMMehs
After 6 years doing Flex, am I moving to HTML5?
Short answer: no. But I’m investing in HTML5.
(really) Long answer: see below.
After coming back from the Flex Summit, many people have contacted me asking what was going to happen with Flex and if I was going to “migrate” our projects (like http://airgile.com ) and services to HTML5. After plenty of exchanged emails and dozens of long talks, I decided to write down and share some notes of my first steps in the HTML5 world regarding the development of Enterprise RIAs (or not). These notes are not organized, they have typos, and, as I said above – they are only my first steps so more experienced people might (and will) prove me wrong in some topics.
Background
I founded Webfuel in 2004 and since then we’ve specialized in building long-term (> 6 months) enterprise-grade RIAs that had to scale well and be prepared for constantly changing requirements with a low cost in maintainability, while simultaneously providing a top-notch user experience. We’ve managed to offer our services comfortably with a very limited number resources and small development teams (3-5 persons per project), much thanks to the way we leveraged existing knowledge on Software Engineering and applied it to our platform of choice – Adobe Flex (now fortunately called Apache Flex).
Our decision was purely technical and we have never regret our choice, until it got badly affected by the bad PR around the Flash platform.
Worse PR ever in November 2011
The Flash platform was already in bad shape, much thanks to one year of chaotic PR and there were already some inconsistent signs from Adobe. While disappointed, I was not very surprised when all hell broke loose in November 2011 with Adobe destroying the very last credibility that Flash still had, directly affecting Flex, our businesses and careers. Long story short, Adobe wasn’t able to monetize the Flash Platform and the top managers who don’t really care or understand it’s power simply decided to put the money where their mouth was: HTML5. I happen to strongly agree with the move on investing in HTML5, but they could and should have done it without destroying (the perception of) Flash. Especially because in the meanwhile it had turned into the platform of choice for Enterprise Development.
In December ’11 Adobe has donated Flex to Apache. While this might end up in being the best thing that could happen to Flex, the initial reaction from the Enterprise was that Adobe was getting rid of Flex. Like someone said during the Flex Summit – “it seems to me that Adobe has built the best platform for enterprise-grade application by accident”. Adobe understands design; creativity; marketing; publishing; Adobe doesn’t seem to understand Enterprise. Example #1: Zero Support = the biggest complaint about Adobe I heard for years on the Enterprise. Example #2: the pricing of LCDS.
Did Adobe killed Flex? No! A technology doesn’t have an heart attack and drops dead on the floor. Flex is still alive and the reasons why we chose it are still perfectly valid. Flex didn’t got worse suddenly – it’s still the same robust platform for enterprise RIA development.
What Adobe destroyed was perception of the Flash Platform. And the perception is what matters on business. You can have the best product of the world, but if people believe it’s bad they won’t buy it (and they’ll even be happy on telling everyone how much your product – that they never used – sucks). But if they think it’s good – even if it actually sucks – they’ll probably buy it (and complain later). Perception. That’s what sells. Perception.
Will the perception around Apache Flex ( http://incubator.apache.org/flex/ ) improve? Most likely, yes. In 9 days, there were more than 1.4 thousand emails exchanged on the Flex Mailing List ( http://incubator.apache.org/flex/mailing-lists.html ) ! It’s pretty impressive the number of people that are now involved in pushing Flex forward and this number will most likely keep raising. But Apache Flex still relies (or, at least for now) on the Flash Platform and I’m not seeing the bad perception on the Flash Player changing in a near future. Of course there’s still AIR, but what concerns me are browser applications
We are desktop-developers-working-on-the-web
An important side note, is that I see Webfuel as a team of desktop developers working on the web. In another words, we use desktop development paradigms, best-practices and design patterns borrowed from the JAVA world and we’ve applied them to build applications that happen to run inside the browser. Our work consists normally in building at least two loosely coupled applications, connected by an RPC API: a client application (running inside the web-browser) and a server application that only exposes services and is not aware of the client application.
Most Flex developers out there think on themselves as web-developers, but in most cases the mindset of a Flex developer is closer to a desktop developer than to a web developer. IMHO, this is the most single-most-important reason on why we, Flex developers, dislike so much the “normal” web development approaches.
We work with “views”, web developers work with “documents”. We do old-school MVC, DI, loosely coupled approaches, dependency management, RPC, code coverage, continuous integration [...], and when we’re forced to do web-development these are the first concepts that we try to investigate and replicate… before we get frustrated and enter in “denial”.
To be good at typical web-development, we have to change our mindset.
Is “HTML5″ ready?
According to Twitter, online magazines, blogs, Apple, Microsoft and even Adobe, HTML5 is the silver-bullet for everything. In can be used to build websites, webapps, games, software, mobile applications, doing laundry and cooking. The focus is all on HTML5 right now. Is it the right moment to use it?
From the point of view of a web-developer – of course it is!!! For a typical web-developer, HTML5 means more tools, more power and much better cross-browser compatibility than what they had before. If you’re working on the web, HTML5 and the storm of JS frameworks is simply the best thing that has happened to the web since…. humm… Flash.
) Bottom line, HTML5 is for sure a giant step forward.
From the point of view of desktop-developer-working-on-the-web – hell no! WTF? We work on the enterprise and enterprise means stability. We can’t afford to have too many moving pieces all the time. We can’t afford to deal with un-structured languages. If you’ve used Flash or Flex for the last 5 years, you’ll feel that in HTML5 there’s nothing new or better than what you already have. Worse, you’ll feel that there still are hundreds of needed capabilities and tools missing. Exception to the rule, happens if you’re targeting the browser of Mobile devices, where HTML5 is king.
It’s quite understandable that a Flex developer feels frustrated. You feel you’re going backwards 4 or 5 years. It happens that, as Ted Patrick stated ( http://tedpatrick.com/2011/11/12/living-in-the-future/ ) , we were living in the future…
Ignore the shit storm. Ignore fanboys. Choose the right tools. Ask the right questions to the right developers
People like to take sides. If I like and use something, for sure it’s because it’s the best thing ever, and all the rest sucks or is dead. That’s how it works for most fanboys.
Newsflash: if 10.000 persons say that something sucks, it doesn’t really mean that it really sucks. It means that they believe it sucks. Like they believe in a religion. The irony is that developers should be pragmatic people, but we often see them becoming fanatic about their technology choices. “Infidel, infidel”, they yell with their pitchforks in the air when you say the name of a “competitor” technology. WTF?
For me, technologies are just tools. Obviously I would like to have as many good tools as possible so I can be able to choose the right one for each task. Be it Flex, HTML5, Javascript, Actionscript, JAVA, PHP, whatever.
Bottom line: ignore the shit storm and the bad PR. Ignore fanboys. Choose your tools based on logic. You wouldn’t choose a hammer to cut wood, would you?
Last year, when I started digging seriously into Javascript, I had many questions. I took for granted that someone who defends a technology with so much conviction, probably understands it pretty well. So I placed several questions to these guys expecting to learn new stuff and understand their best practices. It happens that I haven’t learnt shit. It was like if me and them were from different planets, speaking different languages. Even similar words have different meanings (their MVC is not our MVC. their dependency management is not our dependency management… etc).
I’ve sent a couple of emails to mailing lists of HTML5 and JS development asking people what they were using for MVC, IoC, Unit Testing, Code Coverage, Compiling, Continuous Integration, etc, etc. The answers were like “WTF dude, IoC? What are you talking about?”. I now know that I was doing the wrong questions, as you’ll see below.
Since I couldn’t get (or understand) answers from the gurus of the JS world, I started trying to find people who were doing both large-scale Actionscript and Javascript. They would understand me.
) It happens that there aren’t many and most of them were more or less at the same point I was. The best single advice I got was: “accept web dev for what it is and don’t try to change it. Don’t do RIAs. Do simple web development. Then improve.”. Good advice!.
Redefining our focus
As I said above, technology-wise, Flex is still perfectly valid. But it’s perception is at it’s lowest level and clients are quite confused and started asking us to use HTML5 to build the same type of solutions we were building with Flex.
So we had to rethink our business, and considering our desktop-developers-working-on-the-web mindset, we’ve decided to:
- return to our roots: desktop development. That’s what we’re good at and we can still keep using Flex to build AIR applications, either for the desktop or mobile. Since we can embed the AIR runtime, those applications will be future-proof to any other crazy-game-changing decisions made by Adobe.
- increasing our investment in developing (simple) HTML(5) webapps, while accepting the web for what it is: broken. In another words, we have to be humble about what we can provide on the web. It’s too hard and expensive to build the same type of applications we were building, so we’re starting with just simple webapps.
We won’t be accepting huge enterprise-grade projects if they’re meant to be built in HTML(5). This is actually the hardest problem to manage. There are expectations from clients. They’ve got used to our beautiful RIA applications, with almost no waiting times, with beautiful and pixel-perfect interactive user interfaces. And now they want the same, but in HTML5, because Flash is “dead” and HTML5 will also run on their Mobile devices (all of them), faster and without consuming battery. At least, it’s what they heard…. The solution for this problem is to say “No, we are not ready to develop it in HTML5″. We’ll be restricting us to simpler web-apps, until we feel that we (and the web) is ready.
First steps in JS and HTML5
During 2011, I’ve read A LOT? about JS frameworks, libraries, approaches, etc. Sometimes, after finishing reading something, it was already outdated and a better library was available.
My first impression was that most docs were “meh”: in most cases you have an excellent “Getting Started” guide, but as soon you start getting your hands dirty in more complicated scenarios, things start falling apart and you’ll see no or outdated advanced documentation.
Another trend that I hated in my readings was the lack of objectivity: instead of the typical docs saying “this framework does A,B,C,D” , I saw a lot of “THIS IS THA MOTHA-FUCKA FRAMEWORK THAT WILL SAVE UR LIFE!”, “MEGA-HYPA-SHIZZLA-FRAMEWORK”. Feels awkward.
I’ve also seen several frameworks being dropped in favor of others, which was actually what scared me the most. I felt insecure choosing the “right” libs and frameworks, so most choices I did at start were the safe ones, as you’ll see below.
Another irony was that most of the JS frameworks exist to overcome the limitations of the web development (normally, the crossbrowser issues). Coming from an environment where a framework tries to abstract application concepts, it felt weird to me to use frameworks to abstract technical limitations. Today, I’ve learnt to enjoy and welcome these frameworks. Accept them for what they are, because the technical limitations actually exist? and without those frameworks you’re screwed.
Knockout.js
Despite having read about Backbone, Spine and other complicated frameworks, I’ve decided to start small and simple with Knockout.JS . I just wanted simple data-binding to start with, so I could get some separation between the data model and the view. Later, when we were more experienced, I would re-evaluate the choice of the framework and choose between Backbone, Spine, or another.
My choice has proven to be worthy since Knockout is actually quite simple – but far more complicated and intrusive than the ultra-easy and powerful binding we’re used to in Flex.
The documentation of Knockout is quite good, with plenty of tutorials available. On Google you won’t find as many resources on Knockout as you would like, but fortunately the website covers most of the important topics. The mailing list is pretty good, despite not being as active as the MLs I’m used to in the Flex world with dozens or hundreds of experts. Anyway, in the Knockout ML, there are always one or two persons kind enough to point you on the right direction, which is great.
jQuery
I had already a good impression on jQuery, but even still it turned up to be even better than what I expected. jQuery not only hides a lot of the crossbrowser issues – not all -, but also boosts up a lot your productivity with dozens of shortcut functions to most of the stuff people normally need to do on the web. Use it (can you live without it?).
SaaS
Managing CSS can easily turn into a pain especially if you need to do many changes to an existing stylesheet with hundreds of CSS declarations. When Googling for best practices, I met SaaS. SaaS is actually pretty simple: it let’s you define CSS stylesheets with declaration hierarchy, variables and mathematic expressions, saving them on a scss file. Then you start a command line task that listens to changes to your scss file and converts it to a CSS file on the fly.
I haven’t looked at Less, so I don’t really know which one is better.
Lab.JS
I also discovered (in the hard way) the pain that it can be to manage dependencies in Javascript. I was used to having all class definitions packaged for me in a single SWF and the Flash VM would take care of embedding and managing dependencies for me (pretty most like all bytecode VMs do). In the Javascript world, there’s nothing taking care of this for you. You start by setting in the HTML file the location of the scripts needed, but then you cannot control the order they are loaded and run. So you can be calling a function myFunction() in fileB.js that was defined in fileA.js that was not loaded yet – resulting in errors.
I’ve chosen Lab.JS to solve the issue of loading dependencies on the right order. I’m also making sure that any initialization code only runs AFTER all the needed files are loaded.
I’ve found a problem with Lab.JS: if your code throws exceptions, they will be swallowed by the library and nothing happens. My workaround (read: ugly hack) was to do a ” setTimeout(initialize, 1); ” after the scripts are loaded. This way exceptions are now caught by the browser, as you would expect.
IDEs
This was one of the biggest disappointments at the beginning. The biggest problem of JS is that due to it’s dynamic nature it’s hard to be tooled around. For building large scale complex systems, especially in a team environment, I needed good refactoring capabilities. It happens that refactoring doesn’t exist in the IDEs I tried.
Ok, there is something called “rename” in WebStorm but it works for very simple cases and I’ve seen it resulting in unexpected results (so I always use the “preview”).
Flash Builder is a complete beast (in a good sense). I’ve seen many people ranting on Flash Builder and even I had some disappointments a couple of years ago. But after FB 4 it just got awesome, with it’s serious refactoring capabilities, find usages, metadata completion, autocomplete, inline docs, content assist, etc. Most of the best tricks from the JAVA world are available on FB. If you expect to find those in JS editors, I have bad news for you.
I’ve started with Aptana. It’s free. It’s based on Eclipse, so I felt at home at least with the shortcuts and the structure of the IDE, but with a black editor (wtf? is this the “fashion-color” for supa-dupa-web-developers?). Anyway, after two months I got tired of it. I couldn’t do refactoring. I couldn’t jump properly to a function definition with CTRL+click (and this was REALLY annoying). It didn’t have decent auto-complete. I’ve tried making the debugging work but it only worked properly 15% of the time.
Then I’ve decided to give PHPStorm a try – which is the same as WebStorm, but also supports PHP. At first, I was scared: I couldn’t find half of the stuff I needed. After one day, I was pretty comfortable with it and now I feel it’s actually pretty well built. Ok, it’s NOT Eclipse, but even still it’s quite powerful. What those guys did was to implement really well? the things you use most while developing and packaged all of them in a clean and objective interface. Kudos to JetBrains ( http://www.jetbrains.com/ )!
In PHPStorm, refactoring “sorta” works in simple scenarios. If you complicate too much (like when you try to mimic packaging for your objects), it won’t work. Click and jump to a function definition works. Debugging… works!! Autocomplete works a lot better than I expected. Actually, it works quite well. The catch: comparing to Aptana, it’s not free.
Coming from Flash Builder, will you be happy with PHPStorm? No. But currently it seems to me that it is probably the best IDE for Web development.
Debugging
I feel ashamed to say that I couldn’t debug properly during the first two to three weeks. Every tool I tried didn’t work as expected. It happens I was using the wrong tools, browsers and approaches.
I ended up using the debugging capabilities of both Firebug (in Firefox!) and PHPStorm. Firebug is also pretty helpful to inspect the DOM of the document, something you’ll be doing every 5 minutes. Both Firebug and PHPStorm allow you to place a breakpoint in JS code and then run your code step by step, as expected. PHPStorm looks more comfortable to me, also because it’s where I’m writing my code.
Bottom line: If your debugging is not working, don’t blame JS: you’re simply using the wrong tools.
Javascript
This was probably my biggest pain point. I’ll start with the conclusions: accept Javascript for what it is and don’t try to mimic your common OOP techniques and classes. There.are.no.real.classes.in.javascript.
Of course, you can try? to mimic them – I’ve read half of a book teaching how to do that. But I’ve come to the conclusion that the complexity that you’re adding to get you closer to your comfort zone ends up not being comfortable at all…
You have objects in Javascript. Some might argue that they’re not “real objects”, but wtf, they are what they are and bitching around all the time won’t turn them into real objects. They are objects. Its the definition of “real” that is subjective
)
The problems with JS:
- Silent errors. They happen. Get ready for them.
- Hard coupling everywhere. It’s pretty hard to do loosely coupled architectures. It’s quite easy to end up with a web of dependencies between different objects. I’ve read there are techniques to avoid hard-coupling, but I haven’t had time to dig up more, so this might be my fault.
- Uglyness. I’m used to a HUGE-ULTRA-CLEAN separation between classes, libraries, modules, components and applications. In the webdev world, get ready to see PHP spitting HTML with JS that spits more HTML… Or function a() that creates another function in object b, that knows about object c and changes how c behaves. Things like that. In many known js libraries.
- It’s not built for team work. At Webfuel we normally don’t need to talk much with each other about development. Half a dozen guys can be working together for half a year on the same project, commiting code every 5 minutes to the same SVN, without breaking the code of others. This was quite easy to achieve much thanks to the structured nature of Actionscript, on top of some very simple practices borrowed from the JAVA world. Enter Javascript and you’ll see your code breaking the code of someone else. While developing JS in a team, it’s normal that developers need to talk a lot about what each one is doing, warning the other to be careful about X or Y, or asking the other “where did you put the code for…”. Actionscript makes teamwork a joy almost since moment zero – there’s no rocket science for a healthy teamwork environment. In Javascript, the trick is to put people working in very different unrelated parts of the projects and use techniques to encapsulate their code – I have yet to learn them, but I will soon. I’ve asked some JS developers about this but the ones I know are all lone-wolves so they didn’t understand what I was talking about (apart from the reaction “SVN?? WTF?? Use GIT!”.. hum… that wasn’t my question…)
- Unpredictable. In AS3, the “this” refers to the instance where the method is defined. In JS, “this” can mean pretty much anything (remember AS2?). This was one of my biggest pain-points at first. Another problem is guessing by looking at the code the properties and functions of an Object. You can’t. A function in an object can be defined pretty most anywhere. It’s up to you (and your team; and your partners; and your library-providers) to make sure that you keep your house clean with everything organized in the right place.
- Code practices. These are completely different from everything you know. I taught everyone here at Webfuel to not be afraid of writing many lines of code. I want them to write self-explanatory code, like if they were writing English. Enter Javascript. And cry. By some weird reason, people like to write as much code as possible in a single line, making it not only very hard to read, but also very hard to maintain. I’ve got used to seeing the #(‘huge’).line(of: code, that: function() looks() ).like(‘a’).train(); . And this practice is everywhere, pretty most all examples, libraries and worse: in books! One of the books I read had one line that took me around 5 minutes to understand! The fun part is that I had the book with me in San Francisco on the Flex Summit and I showed that line of code to several people just to scare the shit out of them. It worked!
Bottom line: if you’re a OOP purist, with many years of experience on software engineering on Flex and/or JAVA, you’re going to be scared. The mindset is different. The problems are different. The solutions are different. Even the slang is different. The good part: no compiling times. Which is actually a very good part…
There’s so many people betting in JS, shouldn’t it be good?
This is actually the question that confuses me the most. I simply don’t have an answer… Some people seem to be able to pretty much do anything they need. But at the same time the language certainly has it’s fundamental problems that can scare the shit out of you if you’re doing a one-year-project.
One thing is for sure: it’s being pushed forward and you can’t deny that.
CoffeeScript
I haven’t tried yet CoffeeScript. After reading a bit about CoffeeScript, I’ve learnt that you still need to be comfortable with Javascript to use CoffeeScript properly. And that’s what I’m doing. On the next project I might give CS (or other language that cross-compiles) a try.
Layouting and the DOM
This was actually my biggest disappointment. Flex (>4) is amazingly simple and powerful on what it comes to pixel perfect skinning and layouting. You have pretty most no constraints in Flex in what it comes to layouting, giving you imense freedom in creating perfeccionist user-experiences. You don’t think “how am I going to implement this?” because there’s not much to know with Spark skinning: it’s really powerful and simple.
The HTML world is different. You have to be aware of the constraints before creating the design and setting the user experience. I wasn’t aware of these constraints so we had to change the designs of the product we’re building a couple of times on the middle of the project to turn them into something possible/easier to achieve in HTML. I really hate constraints that end up affecting the user experience.
You have also to be prepared to accept small (and big) cross-browser rendering differences. They will happen. A lot. But that’s another topic…
Optimizations/Preloading content
Coming from the Flash world I was used to have to build one single application (the SWF) that has all (static) assets embedded. This results in pretty small files (yes, a SWF is smaller than it’s HTML+JS+CSS+Assets equivalent, even after minimization and gzip, and etc), only one request to the server (which results in a very low load on the server), and the assumption that all the content you need is available at runtime since moment 0. If you want to achieve a similar result in JS, you have to do it by hand – there’s nothing taking care of that for you. You have to join and minify Javascript and CSS files and resort to image sprites to reduce the number of requests to the server and the user perceived speed.
An image sprite is simply one PNG file with all the images and icons you use in your webapp. Then you simply apply that image as the background image of your UI component, using CSS to set a translation so it shows the icon/image you need. It’s quite simple, but make sure you load this image before your content appears on screen. The same applies to other content, in case you don’t want the user to see “glitches” on the layout while things load.
During loading I am hiding most divs (display: none) in the DOM, showing a preloader and after all content is ready (JS files through Lab.JS, Image Sprite, etc), I’m using jQuery to show stuff. It’s quite simple, actually, but of course, Flex did take care of all that for you… BTW, I saw this today, but I haven’t tried it yet: https://github.com/thinkpixellab/PxLoader
I’ve started today looking for a Javascript minifier. I need something that can automatically watch a folder with several JS files and merge them in a single minified file. If possible, assigning a revision number to the generated file. I haven’t yet found anything, but I’ll update this post if I have positive results.
HTML(5), JS and Mobile
If you think you’re going to build something in HTML(5)+JS that will work seamlessly and without problems in desktop AND mobile browsers, think again. Document based websites usually work without problems on both types of environments. But if you’re doing a more or less advanced user experience that relies in some CSS and JS magic, then be prepared to be disappointed when you open your content in your Mobile device. Not that the mobile browsers are bad – they’re actually pretty good. The problem is that the Mobile experience needs to be thought from the start – people will be using their huge clumsy fingers to interact, the screen will be smaller and the hardware resources are more limited. So at the end, you have to implement at least two different user experiences and switch between them according to the device capabilities using Media Queries. I haven’t yet tried Media Queries, so there’s not much I can say about this. I just mentioned this topic because I’ve seen several people migrating their Flash applications to HTML expecting them to work right away on iOS – without thinking that it’s probably cheaper to keep the Flash version on the desktop and building a dedicated version for iOS.
UI Components
DateChooser, NumericStepper, TextInput, DropDownList, RadioButton, Panels, Accordions, HGroup, Charts, Lists with Renderers, DataGrid, etc, etc, etc, almost all types of components you can imagine are available in Flex. And they are extendable and completely skinnable. You have great control in your hands. In the HTML world, either you go with the limited browser components – that are not extendable and are hard to skin but they integrate with the browser and the device -, or you have to choose a component library like jQuery UI, ExtJS or zkoss, among other – that are more or less powerful, but don’t integrate with the browser or device.
After exploring dozens of options, all of them with their cons and cons, I felt unsecure on choosing one option, spending time and money learning it and teaching it to my team, to later conclude that I might have chosen the wrong one. So I’ve decided NOT? to try any component library – apart from the limited jQuery UI -, simply because there are too many things changing right now and it’s very hard to predict which libraries will succeed and which ones will not. I’m going to be lazy (also because I can’t study thousands of stuff at the same time) and wait to see what other Flex developers will choose. In the meanwhile, as I said above I won’t be using HTML(5) to build RIAs, but only simple webapps. And for that, jQuery UI is up to the task (with some quirks here and there).
Crossbrowser issues
Heck, this is my biggest nightmare. I tremble everytime someone says the world “web browser”. Ok, I’m exagerating a bit. Crossbrowser issues exist, they are a PITA and they will consume at least? 30% of your time in a project. But to be honest, at first I was expecting it would be a lot worse. Don’t take me wrong here, crossbrowser issues are? a nightmare. Simply, they’re not as scary as I thought. If you follow me on twitter ( https://twitter.com/#!/joaosaleiro ) you’ve probably seen me cursing some web-browsers (hint: has two letters, starts with an I, ends with an E). Get ready to having to test something in several browsers and to change plans in the middle of the project because your approach doesn’t work as expected in one or two major browsers – especially if you’re building edge-cases and using HTML5 stuff.
You can’t miss this article: http://www.joelonsoftware.com/items/2008/03/17.html
We had one crossbrowser issue this week that almost killed our current project. We needed to override the browser URL while the user was navigating the application and we couldn’t rely in simple URL hashes. We were hoping that history.pushState was up the task, but it happens that it is not. Erratic behavior in Safari, doesn’t work in IE, worked in Android until 2.3.3 and stopped working in 3.0 and 4.0 (WTF?)… Fortunately, I’ve found History.js which was built exactly to fix our problem and reduce (not fix) the cross-browser issues. See, the good thing is that crossbrowser issues happen to everyone, so you’ll likely find a workaround on the web.
If you’re doing HTML5 you probably know about http://caniuse.com/ . If you don’t, go there.
Productivity
Our productivity is pretty bad right now – but we are getting better! We’ve spent 11 weeks of two resources to build something in HTML(5)+JS that we would have built in 3 weeks with the same resources in Flex, without any stress at all. Of course, I take a big part of the guilt here: we’re still learning and during the first weeks there were a lot of readings, plan changes, tests and bumps on the road.
The real issue is how tight the relation between productivity and your experience with the tech is: the bumps on the road are there, they happen to everyone and you won’t be able to predict them, so the only solution is be experienced and be aware of those issues. They will simply happen, you’ll curse them, search the internet for hours, fix/hack them and the next time you’ll meet them, THEN, you’ll be ready and productive.
You’ll end up implementing workarounds and hacks (on top of other hacks) constantly. Coming from the Flex world, you’ll feel ashamed of your hack – don’t be. It’s normal. Most of the times, you won’t have another choice but to accept the hack and move on.
Coming from a rapid development environment as Flex, productivity in JS and HTML can be quite frustrating until you get used to the bumps on the road. After you’re experienced, it will get better, but I don’t expect it to come any close to Flex development in a near future.
Conclusions
The first conclusion is that we’ll keep using Flex in long-term enterprise RIAs projects. Neither the open-standards nor we are ready to build the same type of experiences that our clients expect us to do.
At the same time, we’ll be accepting smaller webapps. At this point, after three months, we’re already pretty comfortable building web experiences, so it’s a matter of raising the bar slowly, webapp after webapp. But I don’t think we’ll be able to do the same type of RIAs we were doing with Flex at least in the next two years. Also, maintainability and it’s cost scares the shit out of me. And all the moving parts of HTML5 – new libraries appearing, others disappearing, browsers dropping support of features, etc. There are lots of “ands”.
I know I’ve missed a half a dozen topics above and I know I’ll have dozens of other topics to write about in a couple of months. Actually, there are no real conclusions here – only open subjects. There’s much to be investigated and learnt. I’m sure I’m not completely right in some of the above topics and I would love to get your feedback, pointing me on the right directions where I got it wrong. I can only hope that most of the stuff I pointed above won’t look as bad in a couple of months as it looks now. Or that browser vendors shake hands and decide to stop fragmenting the web. Maybe they could all be friends and adopt the same rendering engine and VM (_giggles_). For example, Google Dart. (_yeah, right_…)
Original post:? https://plus.google.com/109047477151984864676/posts/CVGJKLMMehs? (please try to keep comments on the original post, of possible)
Veja o suporte dos browsers às novidades de html5, css3 e javascript
Hoje eu reencontrei um site muito útil que eu já havia visto algum tempo atrás mas havia perdido o link. O site se chama “When can I use…” e contém diversas tabelas comparativas mostrando o suporte dos principais browsers ? s novidades de CSS, HTML5, SVG, Javascript e outros.

Clicando nos links das funcionalidades é possível ver as tabelas comparativas de suporte dos browsers e também é possível mudar os filtros para exibir outras funcionalidades.
As tabelas de comparação contam também com alguns browsers de smartphone, mas o Windows Phone não consta na lista (tem apenas iOS, Android, Opera Mini e Opera Mobile). Mas isso não é um problema pois o IE do Windows Phone usa a mesma engine de renderização do desktop, com a única diferença de que não suporta plug-ins, então basta olhar a versão do IE normal na lista para ver se suporta a funcionalidade desejada. O IE do Windows Phone 7.0 (versão lançada na Europa e EUA em 2010) usa a engine do IE 7 e o Windows Phone 7.1 (Mango, lançado em 2011, inclusive no Brasil) usa a engine do IE 9.

Se você estiver trabalhando em um projeto usando HTML5, este site com certeza será muito útil para ajudar a identificar os pontos críticos do projeto do ponto de vista de suporte e portabilidade entre plataformas.
Desenvolvendo para iOS utilizando Phonegap
Hoje existem diversas plataformas no mundo mobile e cada uma com uma linguagem específica, dessa forma, existe um custo elevado para portar uma mesma aplicação para todas as plataformas, esse custo elevado no desenvolvimento de projetos acaba criando uma barreira muito grande para que pequenas empresas possam usufruir desse ambiente que cresce exponencialmente a cada [...]
Mudanças para 2012

2012 será mais um ano de ascensão dos dispositivos mobile em todo o mundo. Mesmo que aqui no Brasil tudo seja mais lento, com preços mais altos, estamos seguindo em frente. Já temos frameworks javascript adaptados ? s telinhas, como o Sencha, ? e o jQueryMobile, além do Flex Mobile, claro. Outras tecnologias estão crescendo a cada dia, e a quantidade de informação que é “jogada” para nós programadores aumenta em um ritmo alucinante. Seguindo esta tendência, estamos também nos adaptando, e para que tudo fique bem claro ao leitor, decidi comentar as principais mudanças do site neste post.
Neste novo ano estaremos adotando algumas mudanças que visam melhorar a qualidade de nossas obras. As principais mudanças que estão por vir são:
1)? Fim do suporte por email: Nestes quatro anos de suporte por email, pude observar diversos prós e contras, e sempre tentei agradar a “gregos e troianos”. Nunca fiz nenhuma distinção de quem comprou ou quem não comprou meus livros, sempre respondendo as dúvidas em menos de 48 horas. Todo esse tempo foi um aprendizado enorme, e agora tenho a necessidade de “lapidar” este processo de suporte. Observei que muito das dúvidas dos leitores eram repetidas e que sempre respondia ? s mesmas questões. Observei também que, ? s vezes, dava prioridade a alguém que não tinha comprado um livro, e deixava “na fila” uma outra pessoa que tinha dúvidas relativas aos livros. Também cheguei ao ponto de responder 10, 15 e-mails por dia, tornando uma tarefa bastante trabalhosa. Neste contexto, estarei “movendo” o suporte para um fórum especial, aberto a qualquer pessoa e destinado a sanar dúvidas dos livros. Falarei mais deste fórum em um outro post, mas deixo claro que, para quem é leitor, terá como sempre o suporte 100% garantido.
2)? eBOOKs serão predominantes: Todo o processo de criação/distribuição de um ebook é perfeito aos olhos do autor se não fosse a pirataria. Realmente encontrar meus livros que consumiram várias horas de preparo e trabalho nos torrents por aí não é uma sensação boa. Mas eu quero acreditar que isso é possível! Eu quero acreditar que o brasileiro é gente honesta, que deseja pagar por um conteúdo útil sem ser “assaltado”. Por isso, em 2012, eu vou priorizar o desenvolvimento de eBooks, cobrando um preço justo, e com a meta de criar muito mais ebooks do que já foi criado atualmente.
3)? Flex não será prioridade: Nestes últimos quatro anos tenho me dedicado muito ao Flex. Fui o primeiro a escrever um livro sobre Adobe Flex no Brasil e desde então foram quase 10 livros abordando o tema. Sei que está chegando o momento em que eu terei que “dissipar” o meu conhecimento para outras áreas, pois o tema Flex já está bastante difundido, felizmente hoje em dia existe bastante conteúdo dedicado a cultura Flex e só não aprende quem não quer. Veja que, para quem escreve livros, as tecnologias saturam, mas não morrem. Este é o caso do Flex, o conteúdo está saturado, eu não tenho muito mais a escrever, por isso o foco será distribuído para outras áreas. O livro “Adobe Air em Ação” será o último livro a ser escrito para a tecnologia Flex, e não haverá mais edições previstas. O suporte continuará normalmente para quem comprou qualquer livro sobre Flex.
4)? Mobile será prioridade: Daremos certa prioridade ao desenvolvimento mobile, e dependendo de novas tecnologias que deverão surgir, estaremos pesquisando e publicando material sobre elas. Isso significa que determinados livros poderão conter menos páginas, por exemplo, 100, mas que expliquem um conceito ou tecnologia emergente.
5)? Tendências serão prioridade:? A rapidez com que uma tecnologia emerge abre uma lacuna de desinformação para nós tupiniquins. E a? idéia? é preencher esta lacuna com um livro. Por exemplo, ainda não temos um livro sobre SENSHA, muito menos EXTJS. Um livro sobre HTML 5, custa nada mais, nada menos que 73 reais. Nem temos um livro sobre a linguagem SCALA ou sobre DJANGO. Enfim, existe muito assunto para se escrever.
6)? Site flex.etc.br deixa de conter informações sobre os livros:? Todas as informações estarão no site danielschmitz.com.br. O blog flex continua, mas aos poucos deixará de ser atualizado.
Resumindo:
- Vamos publicar ebooks com qualidade e a preços atraentes, sobre diversos temas. Contamos com a aprovação de vocês, enviando críticas e sugestões, .
- Haverá um fórum dedicado ao suporte dos livros.
- Estaremos em breve publicando quais serão os primeiros eBooks a serem lançados e contamos com a sua opinião. Mande ideias !
JQuery: Compatibilidade de CSS com utilização de cssHooks.
Introdução
Um desafio de todo desenvolvedor html é manter o seu site compatível com todos os browsers ( em especial o Internet Explorer ), devido as limitações e detalhes na implementação de cada um, isso é um fato inegável, e qualquer um que ja tentou um dia desenvolver alguma coisa em html sabe disso.
Em projetos pequenos podemos tomar conta disso sem a necessidade de nenhuma ferramenta extra, entretanto com o? crescimento? do projeto? a tendência ? é que estes trechos de códigos para manter a compatibilidade fiquem tão grande quanto o código do próprio site em si, tornando difícil de manter e etc.
jQuery
Nesta hora é importante conhecer as ferramentas que existem para ajudar o desenvolvimento, e utiliza-las de maneira correta. Uma ferramenta importante no desenvolvimento html é o jQuery.
Para quem não sabe o que é, o jQuery é uma biblioteca javascript que facilita a manipulação do DOM ( Document Object Model ) html, ou seja, facilita a manipulação da sua página html.
Para entender melhor do que este post se trata é necessário ter um conhecimento básico da biblioteca jQuery
Hooks
Muitos dos métodos get e set do jQuery podem ser extendidos para casos especiais, estas extensões são conhecidas como hooks. O namespace $.cssHooks permite extender o método .css(), permitindo criar novas propriedades de CSS.
Os hooks podem ser utilizados como uma solução elegante para a compatibilidade de CSS em diferentes browsers, por exemplo, a propriedade text-shadow do CSS3 não é suportada pelo Internet Explorer, portanto o código abaixo não funcionará no IE:
-
$(document).ready(function()
-
$(‘h3′).css(text-shadow: ‘#00ff00′);
-
});
Este código aplica um glow verde em todos os elementos H3 do documento HTML, porém não funciona no IE.
CSS Hooks
Mas nós podemos criar uma nova propriedade css, e internamente tratar o caso do IE. Vamos chamar a nova propriedade de glowColor:
-
(function($)
-
var div = document.createElement(‘div’);
-
$.support.textShadow = div.style.textShadow === ”;
-
$.support.filter = div.style.filter === ”;
-
div = null;
-
-
if ($.support.textShadow)
-
$.cssHooks.glowColor =
-
set: function(elem, value)
-
if (value == ‘none’)
-
elem.style.textShadow = ”;
-
-
else
-
elem.style.textShadow = ’0 0 2px ‘ + value;
-
-
}
-
};
-
}
-
else
-
$.cssHooks.glowColor =
-
set: function(elem, value)
-
if (value == ‘none’)
-
elem.style.filter = ”;
-
-
else
-
elem.style.zoom = 1;
-
elem.style.filter =
-
‘progid:DXImageTransform.Microsoft’ +
-
‘.Glow(Strength=2, Color=’ + value + ‘);’;
-
-
}
-
};
-
}
-
})(jQuery);
Este código cria uma propriedade dentro do namespace .cssHooks chamada glowColor, esta propriedade possui uma função set específica para o caso do IE e outra para o caso dos outros browsers. A lógica deste código é basicamente, verificar se possui suporte ao textShadow, caso sim,? define? uma função set que altera o atributo elem.style.textShadow com a cor do parâmetro, caso não, define uma função que altera a propriedade elem.style.filter com um filtro especifico utilizando a cor do? parâmetro.
Agora podemos aplicar o efeito através do código
-
$(document).ready(function()
-
$(‘h3′).css(glowColor: ‘#00ff00′);
-
});
Conclusão
O lado bom de criar um cssHook no jQuery para o problema de descrito é que o código que trata a compatibilidade fica oculto do desenvolvedor, ele não precisa se? preocupar? com isso, o foco é no código que? constrói? a pagina unicamente. Esta? estratégia pode ser aplicada para outros diversos efeitos e manipulações, criar uma serie de hooks para tratar este tipo de coisa e etc. O lado ruim no meu ponto de vista é que estamos criando propriedades novas, que são desconhecidas pelos outros desenvolvedores e etc, portanto um novo desenvolvedor iria demorar para aprender todas customizações e suas funções, uma dica é tentar manter os nomes semelhantes ao padrão.
Por @thiagoofelix
Referências
Comprimir arquivos Javascript
Olá pessoal, Depois de alguns anos trabalhando com Adobe Flex, estou de volta ao Javascript e CSS. Interessante voltar a esse ambiente, bastante desafiador, diga-se de passagem. Nesse artigo, quero comentar com vocês algumas dicas sobre como comprimir seus arquivos Javascript para uma otimização na hora de distribuir sua app ou seu site. O artigo [...]
Introdução ao jQuery
O jQuery é uma biblioteca JavaScript poderosa que está quase se tornando quase “sinônimo” do próprio JavaScript.
A apresentação de slides a seguir é de uma palestra introdutória do jQuery, que destaca praticamente todos os seus recursos e que mostra algumas modificações na versão mais recente da biblioteca (1.7).
E para quem quiser se aprofundar no assunto, o último slide aponta para um livro gratuito de jQuery: jqfundamentals.com.
(Registro aqui o agradecimento ao Erko Bridee por compartilhar esse conteúdo)
Posts relacionados
- Livro: Google Android“>Livro: Google Android (0)
- Instalando sua aplicação Rails/RestfulX (e as gems) na DreamHost Installing your Rails/RestfulX app (and its gems) at Dreamhost“>Instalando sua aplicação Rails/RestfulX (e as gems) na DreamHost Installing your Rails/RestfulX app (and its gems) at Dreamhost (2)
- CRUD com o RestfulX – aplicação funcionandoCRUD with RestfulX – live application“>CRUD com o RestfulX – aplicação funcionandoCRUD with RestfulX – live application (2)
- CRUD com o RestfulX: Parte 1/2 – RetrieveCRUD with RestfulX: Part 1/2 – Retrieve“>CRUD com o RestfulX: Parte 1/2 – RetrieveCRUD with RestfulX: Part 1/2 – Retrieve (7)
- Protesto: falha em sistema da Orizon expõe dados sigilosos de pacientes“>Protesto: falha em sistema da Orizon expõe dados sigilosos de pacientes (0)
- Balsamiq Mockups: solução entre protótipos de alta e baixa fidelidade“>Balsamiq Mockups: solução entre protótipos de alta e baixa fidelidade (8)
- Erro “bad line length character” no Git“>Erro “bad line length character” no Git (1)
- Windows e Office: novidades da Microsoft“>Windows e Office: novidades da Microsoft (4)
- Firefox Plugin – visualizar trace de SWFs“>Firefox Plugin – visualizar trace de SWFs (2)
© Elvis for Elvis Fernandes, 2011. |
Permalink |
Nenhum comentário |
Adicione ao
del.icio.us
Tags: AJAX, Desenvolvimento, JavaScript, jQuery, web
CoffeeScript, lidando com JavaScript sem sofrimento
Como estou retornando ao mundo do HTML+JS ? inevit?vel ter que voltar a codificar em JavaScript, certo? Bom, talvez n?o… para isto temos o CoffeeScript que apresenta uma proposta bem interessante de sintaxe e codifica??o que no final o resultado gerado ? JavaScript.
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
O que achei interessante nessa apresenta??o foi a apresenta??o dos demais geradores de JavaScript, como GWT em java, entre outros, bom ao final dessa apresenta??o achei bem interessante e consider?vel o uso do CoffeeScript para gerar o JavaScript, utilizando uma sintaxe melhor e obviamente n?o apenas uma nova sintaxe, pois o CoffeeScript possui algumas facilita??es de codifica??o bem interessantes.
No pr?prio site do CoffeeScript possui alguns exemplos e um local onde voc? pode escrever um coffeescript e ver o javascript resultado.
Um fato que me chamou aten??o o compilador do CoffeeScript est? vinculado ao NodeJS.
Aten??o: vale lembrar que o CoffeeScript nada mais ? que uma maneira diferente de codificar JavaScript, ou seja, caso queria utilizar jQuery ou outra lib JavaScript codificando via CoffeeScript ? poss?vel (How CoffeeScript makes jQuery more fun than ever).
Links ?teis para instala??o do CoffeeScript:
How To Install CoffeeScript On Mac OS X
5 Steps to Get Started with CoffeeScript (Mac OS X)
Node.js and CoffeeScript on Windows, Redux
CoffeeScript compilador para windows (GitHub)
Installing CoffeeScript on Ubuntu
Segue alguns links de introdu??o ao CoffeeScript:
Simple CoffeeScript Introduction
A brief introduction to CoffeeScript
Introduction To Coffeescript & Node.Js By Pedro Teixeira
Plugin para os editores de c?digo:












