Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
Posts: 15
Registered: ‎12-15-2010
My Device: Not Specified

Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

 

Hi everyone,

 

I had my app almost done when the new SDK came out, and now I'm facing a strange problem.

 

Before, the sdk update, I hade a sprite with a listener on MouseEvent.DOUBLE_CLICK. Everything was fine (yes I did activate the doubleclick with this.doubleClickEnabled = true).

 

And now since the update, it doesn't work at all, it seems that the event is not triggered (I put a trace in the even listener, and nothing...)

 

Did you guys also had this error?

 

And the real question is : is it a SDK bug? or is it the 'new normal' way of doing, that is don't use double click or even don't use MouseEvent, but instead a TapEvent ?

 

I'm kinda lost, thank you in advance for your help.

 

Benjamin

Developer
Posts: 43
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

Have you by vhance changed your flex sdk to hero?

---------------------
a) If you like my response/post, please provide a Kudo (white star to the left).
b) If my post solved your problem please click on the Accept as Solution button.
----------------------
New Developer
Posts: 15
Registered: ‎12-15-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

no I don't think so, here is the information I found about my flex sdk in the flex-sdk-description.xml:

 

<flex-sdk-description>
<name>BlackBerry Tablet OS SDK 0.9.2 for Adobe AIR</name>
<version>4.1.0</version>
<build>20110111</build>
</flex-sdk-description>

 

Should I upgrade to Hero (4.5.0 if I'm correct) ?

 

 

 

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

[ Edited ]

TouchEvents have a lot more overhead than MouseEvents and you wouldn't be able to test your application in the simulator with TouchEvents.

 

can you post some sample code?


PlayBook Applications:
Drop Swatch
New Developer
Posts: 15
Registered: ‎12-15-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

Here is a test case that failed on me:

 

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.Event;

    [SWF(height="600", width="1024", frameRate="30", backgroundColor="#BBBBBB")]
    public class TestEvent extends Sprite {

        private var testSpriteSmiley Frustratedprite = new Sprite();

        public function TestEvent() {

            testSprite.graphics.beginFill(0x336699);
            testSprite.graphics.drawCircle(100,100,30);
            testSprite.graphics.endFill();
            testSprite.doubleClickEnabled = true;
            addChild(testSprite);

            this.addEventListener(MouseEvent.DOUBLE_CLICK, function(event:MouseEvent):void {
                trace ("Double Clicked?");
                testSprite.x += 10;
                addChild(testSprite);
            });

        }

    }
}

 

 

Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

[ Edited ]

you're adding the doubleClickedEnabled property to your testSprite, but your listening for it on TestEvent.

 

try:

 

this.doubleClickedEnabled = true; 

 or simply:

 

doubleClickedEnabled = true;

writing "this" to me is so AS2, but it's just a matter of preference as writing it or not writing it has the same result.

 

alternatively, you can add your double click event listener to testSprite rather than TestEvent.

 

finally, function closers, as you have in your event listener, are generally... well... they're ghetto.  but more importantly, they can lead to difficult debugging and remove updatability and/or refactorability (is that a word?)... plus they just look really ugly.


PlayBook Applications:
Drop Swatch
New Developer
Posts: 15
Registered: ‎12-15-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

[ Edited ]

Thanks for your quick answer, and you are totally right, this was a typo in my testcase

 

I changed it (and even put the event on the main sprite and the circle one, but still nothing triggered...

 

 

the new code is (without closure):

 

 


package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.Event;

    [SWF(height="600", width="1024", frameRate="30", backgroundColor="#BBBBBB")]
    public class TestEvent extends Sprite {

        private var testSprite:Sprite = new Sprite();

        public function TestEvent() {

            testSprite.graphics.beginFill(0x336699);
            testSprite.graphics.drawCircle(100,100,30);
            testSprite.graphics.endFill();
            testSprite.doubleClickEnabled = true;
            addChild(testSprite);

            testSprite.addEventListener(MouseEvent.DOUBLE_CLICK, testEventFunction);

            doubleClickEnabled = true;
            addEventListener(MouseEvent.DOUBLE_CLICK,testEventFunction);

        }

        private function testEventFunction(event:MouseEvent):void {
            trace ("Double Clicked?");
            testSprite.x += 10;
            addChild(testSprite);
        }

    }
}

 

 

Highlighted
Developer
Posts: 409
Registered: ‎12-10-2010
My Device: PlayBook
My Carrier: N/A

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

[ Edited ]

interesting.  i can't get it to work either.  if there is no solution (if it's a bug) you could simply create your own double click event by using getTimer().

 

 

package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.utils.getTimer;
	
	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#BBBBBB")]
	public class PlayBookTest extends Sprite
	{	
		private static const DOUBLE_CLICK_SPEED:Number = 250;
		
		private var testSprite:Sprite = new Sprite();
		private var mark:Number;
		
		public function PlayBookTest()
		{	
			testSprite.graphics.beginFill(0x336699);
			testSprite.graphics.drawCircle(0, 0, 30);
			testSprite.graphics.endFill();
			testSprite.x = testSprite.y = 100;
			testSprite.addEventListener(MouseEvent.CLICK, clickEventHandler);
			
			addChild(testSprite);
		}
		
		private function clickEventHandler(evt:MouseEvent):void
		{
			if	(mark != 0 && getTimer() - mark <= DOUBLE_CLICK_SPEED)
			{
				doubleClickEventHandler(evt);
				mark = 0;
			}
			else
			{
				mark = getTimer();
			}
		}
		
		private function doubleClickEventHandler(evt:MouseEvent):void
		{
			trace("Double Click");
		}
	}
}

 

 


PlayBook Applications:
Drop Swatch
Developer
Posts: 43
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

Have you tried listening on a single click (instead of double and keepin everything else the same) to see if it is catched successfully?

Re sdk, are you on fb burritto?
---------------------
a) If you like my response/post, please provide a Kudo (white star to the left).
b) If my post solved your problem please click on the Accept as Solution button.
----------------------
New Developer
Posts: 15
Registered: ‎12-15-2010
My Device: Not Specified

Re: Problem with DOUBLE_CLICK event on sprite since the new SDK 0.9.2

@kefayati: Single click works perfectly, and I dont use any fb, I'm using the command line and a good editor.

 

@TheDarkIn1978: kudos for the double_click custom code, I will use that if there is no other solution.