Titanium Community Questions & Answer Archive

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

Passing a variable to a newly created window

Ideally, I'd like this sequence of events to happen:

  1. Window opens up camera, picture is taken
  2. Confirmation window slides in and shows thumbnail of picture just snapped, and various text fields for the user to fill in, user clicks submit button.
  3. Confirmation window slides in thanking them.

Right now, I can't pass the image from the camera into the confirmation window. I get the 'red screen of death' saying it can't find the variable. I attempted the solution suggested here with no success. Anyone have any advice?

Here is my camera code:

Titanium.Media.showCamera({
    success:function(event)
    {
        var image = event.media;
        win = Titanium.UI.createWindow({
            url:'upload_confirmation.js',
            title:'Confirmation',
            backgroundColor:'#fff',
            barColor:'#111'
        });
        win.image = image;
        Titanium.UI.currentTab.open(win,{animated:true});
    },
    saveToPhotoGallery:true,
    allowImageEditing:true
});
— asked March 23rd 2010 by Christopher Webb
  • camera
  • iphone
  • mobile
  • scope
  • variable
  • window
0 Comments

1 Answer

  • Hi!

    Not sure if my answer will be of use but ill try! :)

    You could set a global variable by using the following command, then on the new window retrieve this variable? I retreieve the variable with an onfoucs event so whenever the window is focused it gets the current number in the variable!

    Titanium.App.Properties.setInt('globalselectedStation',selectedStation);
    Titanium.API.info('Selected Station ID:' + selectedStation);

    window.addEventListener('focus',function()
    {
    var stationid = Titanium.App.Properties.getInt('globalselectedStation');
    if (stationid > 0) {`

    — answered March 23rd 2010 by Scott Robinson
    permalink
    0 Comments
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.