Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Show a new window/image on close

I'm lost again, probably on the wrong track. Any help is appreciated.

A new window (winB) is shown when the device is shaken. And there is a close button to go back to the previous window (winA). Now this winA is an imageView showing shake1.png.

What I would like to have is that, after I close the modal of winB, shake2.png is shown. How can I create that?

var win = Titanium.UI.currentWindow;
win.hideNavBar({animated:false});
hidden = true;

var opening = Titanium.UI.createImageView({
    width:320,
    height:432,
    top:0,
    image:'images/shake1.png',
    disableBounce:true
});

win.add(opening);

Ti.Gesture.addEventListener('shake',function(e)
{
    var w = Titanium.UI.createWindow({
        barColor: '#000000'
    });

    var b = Titanium.UI.createButton({
        title:'Close',
        style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN
    });
    w.setLeftNavButton(b);
    b.addEventListener('click',function()
    {
        w.close();
    });
    w.open({modal:true});

    var webview = Titanium.UI.createWebView({
        url:'randomquotes.html',
        });

    w.add(webview);

So which code do I need where to have shake2.png shown when the modal winB is closed? I'm stuck.

— asked October 18th 2010 by Jeroen Onstenk
  • close()
  • imageview
  • iphone
  • mobile
0 Comments

1 Answer

  • lsten to the 'win close' event instead of blur and focus. That worked for me.

    — answered October 19th 2010 by Peter Lum
    permalink
    2 Comments
    • Thanks for your reply, but you got me confused. Blur and focus?

      — commented October 19th 2010 by Jeroen Onstenk
    • He's talking about events on the window object, where close is one possible event and blur is another. In your case, try adding something like:

      w.addEventListener('close', function() { opening.image = 'images/shake2.png'; });
      

      — commented October 19th 2010 by Jonathan Harlap
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.