I am developing a simble but with involved Flex program and I would like to know what it happens before the final result is shown on the page. Is there some way to write some logs or show alerts to check at least whether the control passes in certain parts?
it depends on what exactly you're trying to debug,
If you are looking to get into some internals of e.g. component you could for example overwrite its "dispatchEvent" method to add your own trace there and then run in debug mode, e.g.:
override public function dispatchEvent(event:Event):Boolean
That way you could see what events are dispatched in which order.
Do not use alerts, use "trace" if possible and run your content in debug mode. It is more unobtrusive (sometimes "alerts" affects your code execution flow in unexpected ways).
See doc on how to use Flash Builder to debug: