Monday, November 17, 2008
Tables for Layout?
Monday, July 28, 2008
Variable Scope Issues
Again, here's a new link to my latest project. http://www.cs.drexel.edu/~asc38/Projects/CdlC/
I think it's actually pretty fun, so I hope you try it out.
The only major issue left to tackle is the high score board. When the game ends, you can submit your score to the online scoreboard (I'm currently in first place, go figure.) It was a chance for me to play around with flash's internet communication abilities. It works pretty decently as well, if you ask me. The problem is that, for some reason, the scoreboard only shows up the first time you play it (per page refresh). What that means is that if you press the "Play again" button, play the game, end the game, and submit your score, you won't see the scoreboard. I'm completely scoobied as to why that is. The code to update the scoreboard is as such:
trace(event.target.data);
htmltext = event.target.data;
scoreBox.htmlText = htmltext;
If you're not familiar with flash, trace is a command that outputs things to a special "output" window. Therefore, the event.target.data variable should be shown on my screen. The problem is that despite the fact that I do get the correct text outputted to me by the trace call, the scoreBox.htmlText doesn't reflect what it was given on anything other than the first time through the game. I had a similar issue (in fact it was the only real major "bug" in the first iteration) with the images from the last scoop being present on replays as well, and that was fixed by making sure that everything was reset properly at the appropriate time.
My guess is that this is a variable scoping issue, partially because that was the issue the first time, and partially because Flash's scoping is about as confusing as watching Memento when you're tripping acid. As far as I can tell, variables instantiated within a frame are scoped globally, unless they're within a loop or function. However, commands, or anything else for that matter, only apply at that specific frame. This kinda makes sense. You might want to use a variable you defined somewhere else in the program, and you don't want all of your code executing at once. The issue here is, when are objects (like the scoreBox) that are defined in the scene, not in the code, created? Are they global? Can I change their values before they're visible? I'm still trying to figure it out, so if anyone has any suggestions, feel free to leave them in the comments.
As far as I can tell, it's only used for debugging, as my experiences with the actual Flash debugger were about as pleasant as shaving with a rusty butter knife.
Wednesday, January 23, 2008
I Hate Scrollbars
I have a big post I'm working on about the Microsoft Sync Framework, but I'm working on some UI mockups right now, and realized that I have something to rant about.
In general, I HATE scrollbars. I hate including them in my UI designs, because in my mind, they represent a failure to display all the necessary information in a neat, compact manner. Don't get me wrong, in many instances, they're perfectly acceptable, but with what I'm working on (rich interet applications,) if your user has to scroll, and it's not because of their content (and sometimes even if it is,) you've probably messed up somewhere. The extra effort a user has to exert by scrolling better be worth it, and in many cases, it isn't.
Prime example: Blogger. My browser is fullscreened, on a monitor with a resolution of 1280x1024. There's tons of whitespace to the right of and below the edit window. However, by the time I finish this line (* right there, actually,) I have not only a vertical scrollbar, but a horizontal one. Google has all sorts of Javascripty-Ajaxified coolness on this page. Why can't they resize the editing iframe? Or wrap properly.
Part of it is the inability of developers to come up with interesting ways to display information. That inability is partially from the fear that users will reject what is new and strange. That's bull. When I first started using Office 2007, for about the first week I had a hard time adjusting to the "Ribbon" UI. Nowadays, I can do what I need to a lot faster, and Office 2003 does nothing but remind me that sometimes Microsoft products DO get better with newer versions. Good UI will keep it's users, even if it's initially a little bit different.
That's the end of my first real rant, I'm sure there'll be more to come.
Labels: anecdote, interface, scrollbar, user experience, web
Friday, December 28, 2007
Adding Hidden Fields Programmatically With C#
Sorry it's taken so long to get another post up. The holidays, and the fact that I have a major project due tuesday, have been keeping me from my beloved blogzorz.
This is just something I ran across in my project, it stumped me for about 10 minutes, so I did a search for it, and nothing I saw explained it adequately, or even loaded properly. So here's what I came up with.
I need to add several hidden fields to a form, that contain data needed on the receiving end of a POST request I'll be sending. The values are not static, and need to be a) pulled from a database, and b) used in a crypto method, so obviously just posting HTML input tags just wouldn't cut it. So, I tried having the input tags, but couldn't access them from the codebehind. There are two easy ways to fix this.
1) The CodeBehind Way
In the codebehind, create a new HiddenField:
Hiddenfield field = new HiddenField();
Give it a value:
field.Value = value;
...and set it's ID
field.ID = idValue;
Then, all you have to do is add it to your form:
form.Controls.Add(field);
And it's there! One interesting thing to note, though, is that the ID value you give the HiddenField will be used in the HTML as both the id attribute, and the name attribute. So, if the name attribute is important to your reciever's code (which it is in my case,) make sure you set the ID properly.
2) The Even Easier HTML Way
Add runat="server" to the input tag. I had a face-palm moment when I realized this would work, but it does. The caveat with this method, though, is you have to give it an id attribute as well, or else you won't be able to access it from the codebehind. To set the value using this method, make sure that the HTML is like so:
Then you can edit it in the codebehind as such:
nametocodebehind.Value = hiddenvalue;
And that's it! To make up for not posting last week, I'll be posting again this week, most likely about jewelry and user experience.
Friday, December 14, 2007
URL Sanitization and Picnik
This is a much shorter post than the others have been, but I don't think that's going to be too terrible. ;-P
Anyways, I'm also working on integration with our product with Picnik, and just recently resolved an issue with them. Our images are (or will be) hosted with Amazon's S3 service (which is wicked sweet, if you know how to use it,) and we use secure URLs to access them, along with all the parameters that amazon requires to call a photo (securely.) They fixed the secure URL issue, but for some reason, the photos still would not load in. It turned out that the parameters in the Amazon URL were the problem. They needed to be sanitized (i.e. all "="s became %3D, etc. I found the conversions on this website.) before they'd work. After doing that, they worked fine. One important thing to note, though, is that if I write anything to generate URLs for S3-based images, there should be another one for creating the "editing" url, complete with the picnik url and sanitized S3 URL. Good thing to remember, and it was a reminder that little things like that really have to be watched for, since they happen to me far more often then I'd like to say.