03-28-2011 05:41 PM
I would guess data is not set.
if (data == null) {
trace("no data");
}
03-28-2011 05:44 PM
That's an interesting thought actually. If no variables are passed, maybe the data parent as a whole is never even initialized. I'll check that and report back.
03-28-2011 05:58 PM - edited 03-28-2011 06:04 PM
hey,
when pasing data via the navigator's push view method, you need to refer to the data in the new view as simply "data" as and not the actual variable name u sent into it from the other view. hope that clears things up. good luck!
Edit: Here is what the method structure looks like:
public function pushView(factory:Class, data:Object = null, transition:spark.effects:ViewTransition = null):void
03-28-2011 06:07 PM - edited 03-28-2011 06:10 PM
Okay, sorry, Flash Builder decided that the password to the simulator was suddenly wrong so I had to reboot the simulator. So, data is always defined, not just when I pass a variable, so that way of checking won't work.
Also, JRab, I tend to listen to you over most, but I'm not sure that's true. All the examples (all like 3 I found) showed data.<variablename> as the method to retreive. When running data.toString() through the trace, I get [object Object] as the output. data.selectedWeek shows the proper output when it's set though. Also, you could send multiple variables that the data object would contain, so there has to be some way to differentiate them. I bet data[0] would work though if that's what you mean.
Edit: No, data[0] doesn't work either. I thought it might put it in an array or something. Looks like the only way I see to do it is the way I have now. Pass null unless you're passing a variable, then you can check if it's defined.
03-28-2011 06:12 PM
Ok. scratch what I said about the default parameter. I didn't realize you were using a built in method. My bad for not carefully reading the post.
03-28-2011 06:14 PM
hey ajerman,
i just double checked and the data field is in fact referred to as "data". What tutorial are you looking at? and also this is what you posted in your earlier post:
navigator.pushView(viewEnterTime,selectedWeek);
so whatever you send into there, is what you will get in return. it doesnt add that variable to any foreign data object as a property. so if you send in selectedWeek, thats what data becomes in the new view.
03-28-2011 06:27 PM
Ahh, JRab, I figured it out now. I think the confusion came from the fact that the things I read showed them passing the variable like: navigator.pushView(viewEnterTime,{selectedWeek:sel
Not sure how I could use that though. data isn't null if I don't send a variable. It prints it's value as [object Object] if nothing is passed, so I probably could still use that as a check if it's set if I knew how to check that, but I'm not sure since it's not just a != null or != "" type thing and I'm new to this language.
As long as one way works though, I'm fine with passing a null. I just don't know about what I mentioned earlier about a pop, but that makes no difference in my app.
03-28-2011 06:42 PM
hey,
i dont like things unsolved ![]()
alrite so in the event that you arent passing any data value to the new view, how does your pushView method look like?
also how does it look when you do send data? we are going to tackle this. good luck!
03-28-2011 07:10 PM - edited 03-28-2011 07:11 PM
Oh, it's working now. To make it work, I'm just sending a null variable if I don't need to pass something...
In the event that I'm not sending data, I call the view like this:
navigator.pushView(viewEnterTime,{selectedWeek:nul l});
And when I do need to pass data, I just do:
navigator.pushView(viewEnterTime,{selectedWeek:sel ectedWeek});
Then I can check if data.selectedWeek is null or not.
This works well enough since I really only have two places that call that view, one sends a variable, one doesn't. In a different app that may or may not be the best solution, but for this app it works fine so I'm not too worried about it. I just initially wanted a way to call pushView without having to do anything for a variable if I didn't need one, and I think you were getting there with the suggestion of passing the variable without a label then just using "data" as my passed variable, but I don't know how to differentiate between it's unassigned "[object Object]" and an assigned value of what I passed to it, since neither are null.
Honestly though, either way works fine. I've got too many other things to fix up before the deadline as I cut it incredibly close, so I'll just leave it as is for now probably. I appreciate the help from everyone though. Learning with barely any documentation is difficult! ![]()
03-28-2011 07:12 PM
haha im just a nitpick ![]()
if you do run into the same problem or wondering about its efficiency and want to figure it out make sure to post about it in the forums. good luck on the rest of your app!