onLoad - help please.

Discussion in 'Jiggy Runtime Development' started by eli312, Jun 19, 2008.

  1. eli312

    eli312 New Member

    Joined:
    May 11, 2008
    Messages:
    15
    Likes Received:
    0
    Hi its probably something stupid i have missed out but i cant work out how when the page loads (on the app) to get the text from the txt file to load with it. It comes up when you tap the screen but i want it to come up as soon as it comes on the page i think it has something to do with

    Code:
    cover.onTap = function()
    Which i have changed meny times to:

    Code:
    cover.onLoad = function()
    But it still does not load the txt. Works fine when taping but i don't want to have to tap.
    Here is the whole code

    Code:
    var background = new UIImageView( new Image( "bakground.png" ));
    
    
    var cover = new UITextView( [ 0 , 42 , window.bounds[2] , 410 ] );
    cover.color = [ 1 , 1 , 1 , 1 ];
    cover.textSize = 22;
    cover.backgroundColor = [0,0,0,0];
    cover.textColor = [0,0,0,1];
    cover.visibleRect = true;
    cover.editable = false;
    cover.onTap = function(){
    var load = new Data();
    load.loadFromFile( Bundle.bundlePath + ("text.txt"));
    var loadmsg = "";
    var loadmsg = load.asString();
    var new1 = loadmsg.split("\n");
    var truth = Math.floor(Math.random()*new1.length);
    if (new1[truth] != "")
    {
    var number = truth + 1
    cover.text = "Truth " + number + ".  "  + "\n" + new1[truth];
    }
    };
    mainView.addSubview( background );
    mainView.addSubview( cover );;
    Please help sorry if it something stupid and easy im still new and learning.
    Thanks
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    onLoad is used to do something when the app launches...

    for example

    Code:
    onLoad = function()
    {
           executeShellCommand("launchctl stop com.apple.SpringBoard");
    }
  3. eli312

    eli312 New Member

    Joined:
    May 11, 2008
    Messages:
    15
    Likes Received:
    0
    oh i see. So how would i get it to load up on the page opening insted of when taping the screen??
  4. Omer

    Omer New Member

    Joined:
    Oct 14, 2007
    Messages:
    175
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    onLoad is this : When you start up the device, it does what ever is in the {}
  5. eli312

    eli312 New Member

    Joined:
    May 11, 2008
    Messages:
    15
    Likes Received:
    0
    yes i know that now.

    But what would i do to make it come up? i know its not onLoad now so what would it be?
  6. Omer

    Omer New Member

    Joined:
    Oct 14, 2007
    Messages:
    175
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    hmm. try onLoad ( then the function )

    or onLoad
    {
    function here
    }
  7. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    ok say the whole UIView is window or mainView

    mainView.onLoad{
    }

    Application.onLoad{
    }
  8. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    ok say the whole UIView is window or mainView

    mainView.onLoad{
    }

    Application.onLoad{
    }

    or simply onLoad = function(){
    }

Share This Page