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

Native Development

Reply
New Developer
Posts: 16
Registered: ‎12-01-2012
My Device: Z10

Image touching

Hi, I've got problem with picture touching. How to make picture which change into another when we touch it, and back to the original form after that ? This is my part of code:

ImageView 
{
	id: kl
	imageSource: "asset:///kl.png"
	scalingMethod: ScalingMethod.Fill
	preferredWidth: 182.8
	preferredHeight: 768.0
	onTouch: 
	{
		imageSource= "asset:///klw.png";                       
	}
}

 

Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: Image touching

Easiest way would be to use an image button:

 

        ImageButton {
            defaultImageSource: "asset:///images/img1.png"
            pressedImageSource: "asset:///images/img2.png"
        }

 Or if you want to use an ImageView I recommend using a Gesture Handler rather than just an onTouch.  At least with Beta3 I could never get just an onTouch to work properly.  Either way inside of the function you would need an event is down and event is up to have it flip between the two images.  But like I said above it is easiest to use an image button.

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
New Developer
Posts: 16
Registered: ‎12-01-2012
My Device: Z10

Re: Image touching

Thanks a lot, but it solved my problem partly, because I would like to have few images in my app which will change into another and back to previous even if I'm touching a screen all the time and moving a finger on the screen to the next image. Any idea how to do it ?