Wednesday 13 July 2011

The mouse wheel scroll with VGroup and Scroller is not smooth and it jumps abnormal points

adobe flex4.0 AS3.0


This is happening when you have photos in the VGroup, the Scroller jumps the photos each time in order to be viewed whole and not cut. This sometimes is not working well or we don’t want it.

What we have to do is to get the mousewheel event and calculate by our own the vertical scroll position.

1. implement the event like above:

protected function scroller1_mouseWheelHandler(event:MouseEvent):void{
  //calculate the new position 
  vgroup.verticalScrollPosition+=(event.delta*-20);            
  //stop the event’s bubbling
  event.stopPropagation();
}

2. add the event listener by your own! Because we want to get it before calculate the vertical scroll position. In event’s world… "we want to capture it", and this could be done only is we add the listener by our own, note the underlined true argument, so do:

scroller.addEventListener(MouseEvent.MOUSE_WHEEL,scroller1_mouseWheelHandler,true);

That's all

Tuesday 5 July 2011

How to make visible the comments of your own function, on insight feature pressing the dot, as help of the function


With this way you may give help to the object user about how your function works.

Simply put your remarked text with /** */ above of the function. Do not use /* */ or //, only /** */ you should use for this usage.


/**x is the X coordinate and y is the Y coordinate of the image*/
//TODO: this function might have a bug… I have to check if the image is null!
public function locatePictureAt(x:int,y:int):void{
                image.x=x;image.y=y;
}

In Flex IDE, when you will press the dot to go to the specific function, it will show as help of this function the text placed in /** */. The “TODO” text will be not appered, either if it was placed in /* */.

Monday 4 July 2011

required steps in order to dispatch your own events

problem

adobe flex AS3.0
required steps in order to dispatch events
good luck :)
---
> page dennis
difficulty level

5/10 :)
compatibility

step1
the class where dispatch event, should extends the EventDispatcher object
example: public class MDlogin extends EventDispatcher

step2
create some (stupit) public strings… where will be the events (id)
example:public var Event_LoginSuccess:String='Event_LoginSuccess';

step3
in order to dispatch an event call the dispatchEvent method (where is coming from EventDispatcher)
example: dispatchEvent(new Event(Event_LoginSuccess));

step4
create your own custom Event object where will be dispatched.
The Listeners, should get your Event object and not the Flex’s Event, in order the Listener to be able to get the additional public variables and functions of your custom events!
- create a new Actionscript Class (file and so on) that extends the flash.events.Event class
- add you public variables and functions where will be available for the listener (do not make it have, instead, give easily a reference of the object where dispatch the event)

Conclusion
An Event object is nothing more than a silly object that is useful because the runtimer can dispatch it! It is nothing more! It is a cabinet that can gives ready information to the listener (some public variables or much better only getters).
If Flex’s world and in general OOP’s world, the Events are the only professional communication way between different and maybe unknown objects.