Esse post está em inglês e português.
This post is in english and portuguese.
Drag n´drop operations in Flex are piece of cake. When we´re using ListBase we dont even have to get our hands dirty with any code… When we dont have a ListBase control… well, it remains simple enough… Albeit, I think I have the right to complain about somethings I dont like as the lack of standatrization for the hasFormat() argument: why in earth it has to be “items”! It seems lazy… Another issue is: why didnt they code to an interface when writting Flex and AIR Managers? For those who are not keen to DD operations: Flex and AIR have different ways of manipulating dragged data. Flex uses DragManager and AIR uses NativeDragManager. Theres a lot of info – either in the web and in the docs – about it, but, come on, it´s a pain… Theres also creacog´s (elegant) solution, but… I dont want to raise all those classes to do a simple thing…
The last item in my complain list is probably due to my mistake, but the only way I could make the drag operation from the Canvas back to the List was overriding a ListBase method that kept on throwing an error beacuse my dragSource.dataForFormat was null. The case is: it´s NOT and Array!! So I overwrote it and it works…
Pretty easy, hun?
Anyways, check it here. The AIR version is posted here.
/******************************************************/
Drag n´drop no Flex é muito simples. Quando estamos usando controls baseados em ListBase não tem sequer que sujar as mãos com código … E quando não temos um control baseado em ListBase … Bem, continua bastante simples … Porém, acho que tenho o direito de reclamar de algumas coisas que eu não gosto, como a falta de padronização do argumento hasFormat () : por que diabos tem que ser “itens”! Parece preguiçoso … Outra questão é: por que eles não programaram para uma interface quando escreveram os managers do Flex e do AIR? Para aqueles que não estão familizarizados com operações DD: Flex e AIR tem diferentes formas de manipulação de dados arrastados. Flex utiliza DragManager e AIR usa NativeDragManager. Há um monte de informações – na web e nos docs – sobre isso, mas, por favor … Há também a solução (elegante) do creacog, mas … Eu não quero levantar todas essas classes para fazer uma coisa simples …
O último item na minha lista de queixas é provavelmente devido a algum erro meu, mas a única maneira que eu consegui fazer a operação de arrastar de um Canvas de volta para um List foi sobrescrever um método de ListBase, que ficava dando um erro porque o meu dragSource.dataForFormat era nulo (ListBase.dragDropHandler, l:9212). O caso é: não é e Array! Então eu sobrescrevi e ele funciona …
Muito fácil, hun?
Enfim, veja o app aqui. A versão AIR está aqui.
/****************************************************/
That´s the pice of code Im talking bout:
[code lang="actionscript"]
for (i = items.length - 1; i >= 0; i--) //it´s NOT an Array! It doesnt have lenght!!!!
[/code]




Recent Comments