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

Java Development

Posts: 376
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Animation in a bitmapfield

Nelow is my code for Animated BitmapField.Here the entire screen is fading IN-OUT.I want that only the portion in which i add BitmapField should fade IN-OUT and rest of the screen should not.How can i achive it.


package mypackage;
import java.util.Timer;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.BitmapField;

public class AnimBitmapField extends BitmapField {
	Timer animTimer = new Timer();
	Bitmap animBitmap;
	int alpha;
     AnimBitmapField(Bitmap myBitmap, long flags)
    	 super(myBitmap, flags);
    	 animBitmap = myBitmap;
    	 alpha = 0;
     void setAlpha(int newAlpha)
    	 alpha = newAlpha;
     protected void paint(Graphics graphics)
	 graphics.drawBitmap(0, 0, getWidth(), getHeight(), animBitmap, 0, 0);
     protected void onDisplay()
    	MyScreen.getTimer().schedule(new AnimTimerTask(this), 0,18); // 20 ms gives a full 10 seconds cycle for fade in/out    	 
     protected void onUndisplay()

 Please help

Please use plain text.
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Animation in a bitmapfield

i would try to store the current alpha, set it, draw the bitmap and then restore alpha to the previous value.
global sounds like it would be used on all drawing operations, even on another graphics object.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.