Removing objects / components

Flash, Flex 4 Comments »

This is pretty easy, but also pretty usefull.

It removes all the children of a given object. You can use with Flex or Flash.

/**************************************/

Muito fácil, mas também muito útil.

Remove todos os filhos de um dado objeto. Você pode usar com Flex ou Flash.

Read the rest of this entry »

LocalToGlobal?

Flash, Flex No Comments »

These (localToGlobal and globalToLocal) are very useful methods that might be not as well known as they should. As now I’m a blogger, and I just wrote code using it, I took some time to draw a (I think) very didactid image about it. There’s no source, no code. Just read the figue and you should be able to understand.

And a warning: there are other pair of methods in Flex (globalToContent and contentToGlobal), which are intended to be used when your containers have borders.

Check also this amazing link: http://rjria.blogspot.com/2008/05/localtoglobal-vs-contenttoglobal-in.html

Enjoy.

localToGlobal

And here we have another example:

localToGlobal second picture

onPress orphan… is it only me?

Flash, Flex No Comments »

I am an onPress orphan. Now I said it… How do you know your user is efectively pressing something? Of course, you say, there is the MOUSE_DOW, but noooo, I want to know he is pressing all the time he is pressing.

So, here’s my ugly hack for me beloved onPress.

/******************************/

Sou uma órfã do onPress. Pronto, falei… Como você sabe que seu usuário está efetivamente pressionando alguma coisa? É claro, você pensa, tem o MOUSE_DOWN, mas nããããão, eu quero saber enquanto ele pressiona.

Por isso, aqui está meu POG para o amado onPress.

[code lang="actionscript"]package examples{
import flash.events.MouseEvent;
import mx.containers.Canvas;

public class PressMe extends Canvas    {

private var somecanvas:Canvas= new Canvas();

public function PressMe()        {
super();

addChild(somecanvas);
somecanvas.setStyle("backgroundColor", 0xFFFFFF);
somecanvas.width=100;
somecanvas.height=100;
somecanvas.addEventListener(MouseEvent.MOUSE_DOWN, start);
}

private function start(evt:MouseEvent):void{
somecanvas.startDrag();
somecanvas.addEventListener(MouseEvent.MOUSE_UP, stop);
}

private function stop(evt:MouseEvent):void{
somecanvas.removeEventListener(MouseEvent.MOUSE_UP, stop);
somecanvas.stopDrag();
}
}
}[/code]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in