View Full Version : delegates oninit help
theRGB
04-03-2006, 09:53 AM
Ok, I'm trying to make a loading screen that displays the name of the subnodes as it loads. The only problem is that it will only load the first window or view, says that it loads the second (though its not visible), and then stops altogether. Here's a snippet of the code:
<class name="splashscreen">
<method event="oninit">
i = 0;
parent.subnodes[i].completeInstantiation();
for(i=1; i<parent.subnodes.length; i++){
this.loadDelegate = new LzDelegate(this, "load", parent.subnodes[i-1], "oninit");
</method>
<method name="load">
parent.subnodes[itr].completeInstantiation();
...
this.itr+1;
</method>
</class>
Can anyone offer any suggestions? This code is in a class and itr is a class attribute that starts out at 1 and increments each time "load" is called. I have all the parent.subnodes that are views/windows set to "defer". Parent in this instance is the canvas.
Thanks.
bfagan
04-03-2006, 03:26 PM
You might want to take a look at my reply in this thread: http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=5110&highlight=splash
theRGB
04-04-2006, 04:33 AM
bfagan,
Thanks for your reply. That thread is actually what initially got me started on my project. And i had actually used that method previously, i just didn't like having to use the lztimer, and was hoping i could just do it with delegates alone, as some objects take longer to load than others.
Is there something i'm doing wrong in the delegate syntax? The flow of control in my program is entirely nonsensical, here's from the debugger:
NOW LOADING: view1 component # 1 next is view2
(win1 oninit) This is win1
NOW LOADING: view1 component # 1 next is view2
::loaded:: (not null): view1
component 1 / 10 loaded
::loaded:: (not null): view2
component 2 / 10 loaded
Now you see, that is all just in one method, but the first object is getting called twice, and then the second object once, but its skipping over the actual instantiation on round 2 (ie. it should say NOW LOADING, ::loaded component 1:: NOW LOADING ::loaded component 2::). It makes NO sense to me.
Here's the full code attached if anyone would please take a look. Thank you for all your help, you guys are great.
theRGB
04-04-2006, 05:15 AM
The really funny thing is that my flash screen is supposed to say "Loading view1/view2/etc" as the different objects load, but it only says "Loading..." (the default value).
HOWEVER, if i turn the debugger on, then it says "Loading view1" and then stops at "Loading view2." That really doesn't make any sense!
theRGB
04-06-2006, 05:04 AM
No more replies? I guess I'm just stuck with timers then? By definition it seems that using delegates to call a method when an object loads should work just fine... anyways, here is my source if anyone else would like to take a crack at it, or modify it for their own use.
bfagan
04-06-2006, 05:37 AM
The only timer in mine allows the status bar animation to complete before the window closes.
theRGB
04-06-2006, 06:13 AM
bfagan,
Again i would like to thank you for taking time to reply. Your code is fine indeed, i just wanted my loading app to be entirely self-sufficient, save for having to set initstage="defer" in the objects that are going to be loaded. In yours, i'm assuming that you have something like initstage="late" and oninit="this.objectInit()" in all of the objects you want instantiated.
I was hoping that by using the delegates i could avoid having to add in the code to call methods from the objects themselves... I apologize if i'm just being stupid here, but all things splash-screen aside, i really just want to know what im doing wrong with the delegates.
bfagan
04-06-2006, 06:23 AM
If you REALLY want to do it that way...
Consider writing an addSubview() method into your 'parent' classes. Read the LZX reference on view:
addSubview()
LzView.addSubview(s)
Called when a subview is added to the view.
Parameters
s - LzView - The new subview
theRGB
04-06-2006, 06:41 AM
I will certainly look into it, and post my findings. Thank you for your help.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.