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
Developer
UberschallSamsara
Posts: 1,029
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Really weird sprite behavior

[ Edited ]

In a Dev Alpha targeted AIR app, using the Gold SDK, I am seeing some weird and maddening Sprite behavior.

 

I have a scrim sprite with an event listener attached listening for MouseEvent.CLICK.  The event handler

is supposed to toggle the scrim's alpha between 1 and 0.  If I change one little line of code, the behavior

on the Dev Alpha goes from irrational to rational.  I have a line of code that says:

 

e.target.alpha = 0.0;

 

In the particular execution branch this code lives in, the sprite refuses to change its alpha.  I know the

line is getting executed because:  1) I have trace comments inline right before and after it, and 2) When I

change it to read:

 

e.target.alpha = 0.01;

 it suddenly feels like cooperating, and turning the scrim's alpha down to 0.01.

 

What.  The.  Foo.

 

Anyone ever seen anything like this?  (And more importantly what is the "fix"?)

 

I want to set the alpha to exactly zero because I test its value along with the alpha values of several other

scrims elsewhere in the code.

 

Also, when I repeately tap one of the scrims with the code in its apparenly broken state (i.e. trying to set the alpha to identically zero), other code that is checking the scrim's alpha is indicating that the attempt to assign a value of zero failed succeeds according to the value read back from e.target.alpha, yet the scrim remains black (the scrim color value is 0x000000).

Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: Really weird sprite behavior

Not sure what is causing the problem, but you could try setting the alpha first to 0.01 then to 0.0 in two consecutive lines of code.

 

Are you 100% sure e.target is always a Sprite?

Are you 100% sure it is referring to the correct sprite?

What do you get if you trace out the alpha directly after setting it?

What do you see if you set a breakpoint on that line and inspect e.target?

 

Though the AS3 compiler & runtime do have occasional bugs, I've found this type of error is almost always caused by some faulty logic in the app, i.e. programmer error.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
UberschallSamsara
Posts: 1,029
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Re: Really weird sprite behavior

[ Edited ]

I'm assuming it is my error, however the things I have done as I describe to isolate it have left me at a dead end for now and I am going to have to shelve this app for a few days if not longer.  I did trace out the alpha immediately in a line of code after the line where I set it and it reads back as the value I set it to, however the Sprite itself on the device display refuses to go transparent.  Same behavior on the simulator.  I also tried using the Sprite "visible" property and got the same behavior.  I have traced out the e.target and it is indeed a Sprite.  The only lead I can think of is I am storing my sprites in an array and maybe somehow a dereferencing is getting dropped.

 

I use fdb for debugging and unfortunately it appears that you can't set breakpoints in fdb if you have ANE's packaged.  Google for it; apparently a bug in fdb that remains unfixed for two years.  If you know different though please let me know; I'd love to be able to set breakpoints.

Please use plain text.
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: Really weird sprite behavior

Could it be a GPU/CPU mode bug?

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Please use plain text.
Developer
UberschallSamsara
Posts: 1,029
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Re: Really weird sprite behavior

My understanding is that CPU render mode is supposed to be the most reliable - that's what I'm using.

Please use plain text.