Results 1 to 6 of 6
  1.    #1  
    Hi all,

    In my app, i parse a parameter from Scene1 to Scene2.

    This parameter is correctly declared In Scene2.
    Here is the code of Scene2:
    function Scene2Assistant(param) {
    this.param1 = param;
    This parameter is used to display a picture in Scene2 when Scene2 is activated

    Here is the code :
    Scene2Assistant.prototype.activate = function(event) {
    	this.myCountryDivElement.mojo.centerUrlProvided('images/'+ this.param1 +'.jpg');
    All works fine when an image file corresponding to the parameter exists.

    what i want to do is to check if the file corresponding to the parameter parsed exists.
    If Yes, then the value of this.param1 is take into account
    If No, then i want to set a default value.

    Is this test must be coded in protoype.setup as below ?
    Scene2Assistant.prototype.setup = function() {
    	var file = Mojo.appPath + 'images/' + this.param1+'.jpg'

    I browse the forum but not find something relevant.
    What is the code to do it ?

    Thanks for your help.
  2.    #2  
    Up ! Anyone ?
  3.    #3  
    I tried a lot of syntaxes, read guidelines, ... but not fixed my problem.

    In this large and friendly community, is there a guru to help me ?

    Any help would be really appreciated.
  4. PreGame's Avatar
    540 Posts
    Global Posts
    550 Global Posts
    you would have to use one of palm's API's to do that. You can TRY to do an Ajax.Request('/path/to/file',...); to see if it returns data. But other than that javascript cannot really open files without the use of activex.
    MyFlashlight - The Original Palm Pre Flashlight Application
    fileCoaster - The Original On Pre Application Installer

    Donations are greatly appreciated and can be donated HERE!. Again thank you ALL for your continued support!

    Follow us on Twitter @vertigoapps
  5.    #5  
    Thanks PreGame.
    Ajax.Request function seems to be the solution

    First of all, i try to display the path but am having trouble to figure out.
    var url = Mojo.appPath + 'images/' + this.param1;
    this.showDialogBox('Path', url);

    In which section of the scene the test must be coded ?
    I tried in prototype.setup and prototype.activate but it don't work.

    Any help ?
  6.    #6  
    Ajax.Request is the solution. Thanks PreGame

    Here is the code for whom who are interested in:

    Considering that :
    this.param1 is an argument parsed from Scene1
    This code is to test if a jpg file exists in the app path.

    var file = Mojo.appPath + this.param1 +'.jpg';
    	var request = new Ajax.Request(file, {
            	method: "get",
            	onSuccess: this.OnSuccess.bind(this),
            	onFailure: this.OnFailure.bind(this)

    If the file exists then the correct jpg is displayed
    Scene2Assistant.prototype.OnSuccess = function(transport){
    	this.myCountryDivElement.mojo.centerUrlProvided(this.param1 +'.jpg');

    If the file not exists then a default jpg is displayed
    Scene2Assistant.prototype.OnFailure = function(transport){
    Hope this helps

Posting Permissions