PDA

View Full Version : [CLOSED] launch function does not run automatically



baushaug
6 Apr 2012, 1:00 PM
I attempting to create a global or application specific array with in my launch:function().



launch: function() {

BrookshireBrothersMobile.globals = { enduser: '', dummy: 35 }; Ext.create('BrookshireBrothersMobile.view.Main', {fullscreen: true});
}

When I attempt to retrieve either of these variables I get a TypeError


TypeError

arguments: Array[2]

0: "enduser"
1: undefined
length: 2
__proto__: Array[0]

get message: function getter() { [native code] }
get stack: function getter() { [native code] }
set message: function setter() { [native code] }
set stack: function setter() { [native code] }
type: "non_object_property_load"
__proto__: Error


I placed an console.log and alert() within my launch function and neither fired.

Has anyone else had this problem ?

aflx
8 Apr 2012, 4:27 AM
I had the same problem and moved the code to the init function of my application controller.

baushaug
8 Apr 2012, 12:45 PM
@aflx

I'm using Sencha Designer 2 and it apparently structures code somewhat differently as I'm having trouble locating an init method. In fact I searched the entire code base for the word "init" it found nothing.

Jamie Avins
9 Apr 2012, 8:41 AM
I'm going to move this to the Designer forum. They should be able to point you in the right direction.

jjohnston
9 Apr 2012, 12:35 PM
@baushaug: In Designer 2 you can add an init method to a controller by finding the "init" item in the config pane and clicking its + button to add the method; you can then select the method and edit its code.

I just tried creating a touch project with a launch function and it does get executed as expected, are you getting any other errors that might be preventing it from firing?

baushaug
9 Apr 2012, 12:45 PM
@jjohnston, not that I can see. I have several warnings because of multiple components with identical "id"(s) but not errors. You can view the app that I'm developing here http://mobilenew.brookshirebrothers.com/designer.html

I (http://mobilenew.brookshirebrothers.com/designer.html) will try adding an init as you suggested and see if that fixes my issue.

jjohnston
9 Apr 2012, 2:04 PM
Oh wait, your launch function has to be fired because that's what creates your main view. If it weren't firing then your app would be blank.

Perhaps the problem is related to when you're trying to access the globals object, is it possible you're trying to access it before the launch function has been executed?

baushaug
10 Apr 2012, 6:54 AM
OK, I figured out what's going on. Sometime last week, I got an update for the Sencha Designer and the default web page used by the designer changed from designer.html to app.html and the "Application Entry Point" code changed from being stored in designer.js to app.js.

jjohnston
10 Apr 2012, 7:28 AM
Ah, that makes sense. Glad you figured it out! :)