Loading...
 
[Show/Hide Right Column]

Blog: Development
Description: Related to the development of the various projects described on these pages.
Created by banister on 2008-09-03 16:11
Last post 2009-09-17 14:42
(20 Posts | 2327 Visits | Activity=2.00)

Find:
Reading my old (?) blog posts, it strikes me how easily one descends into the abyss of style that bloggers dwell in. Arrogance, self-righteousness, just general annoyingness. It's why I hate blogs and people who write blogs. I also hate the word "blog." That someone can answer the question "what do you do?" with the proud declaration "I'm a Blogger!" and smugly adjust their horn-rimmed glasses and go home and make all kinds of money and justify themselves to sleep at night just... just buttons my britches. Buttons them right up!

Somebody should have stopped me. In fact, somebody still needs to stop me. All this unbridled outpouring of uninformed opinion. So unseemly. Such self-righteousness and manipulative language. Such overuse of exclamation points. Hateful in the extreme!

In other, more relevant news, I'm starting the process of installing Flex on my new computer, and sooo dreading it. I came here to find my documentation on the installation process, only to realize that I did not make said documentation. Always document! Now I have to revisit that, and relearn it, and all I remember from a year ago is that I did not enjoy the process.


Some things about Flex just seize my heart and fill me with despair.

The ComboBox control, for example. To do it right, you connect the combo box to a dataprovider, basically an array of some kind. Then you tell it what field of the data to show in the display. If there's nothing selected then it just shows a blank. That's great.

But when you need to select nothing in the combo box, that's when your life of misery begins. See, it's all well and good to start with selectedItem == null, but there's no way for the user to set selectedItem = null. You can do it programmatically, though, so you could add a button to your GUI just for the purpose of deselecting items in the combobox. I think Jef Raskin descends from the heavens to award you 10,000 IEEE style points for doing this. It's brilliant.

You know, I've actually seen people solve the problem that way. But that's insane. You have a control that starts in a certain state, and no way to get back to it. But it's a valid state! And it might be, I don't know, ABSOLUTELY CRUCIAL in order for your (read: my) application to work.

I got the solution(external link) (?) from adobe. You need to create a new dataprovider (ArrayCollection) that adds a selection for nothing selected. Then you detect your dummy item and set your null manually. This is a total hack. Especially considering the user cannot select all the valid states of the control without it. You'll notice the solution is from Flex 2. So they knew about it for a while and have decided not to fix it, and likely will not fix it. Absurd.

All told, I spent several hours of my life trying to work around this ridiculousness. Why.
Okay, this is getting ridiculous. FLEX not only does not allow method overloading, but DOES NOT ALLOW CONSTRUCTOR OVERLOADING. So, you'd better choose the right prototype the first time, because YOU ONLY GET ONE CHANCE.

This is ridiculous. If you can't implement method overloading then you have no business making a language. I now require from Adobe:
  1. A well-reasoned explanation why they have chosen to be total morons about this.
  2. An apology.

I have an object which I instantiate with XML data. I pass the data directly into the constructor and everything's great. But now I find that in one place I will need to clone this object, and Flex has no clone method. They have a deep copy, which is great, but once you've deep-copied your class you can't cast it back to the original class (I wouldn't mind an apology for this, either).

So you have to write your own clone method. That's fine, but I've already used my one constructor in the world and it relies on XML data. BUT IF I DON'T HAVE ACCESS TO THAT XML DATA NOW THAT'S LIKE 100 YEARS IN THE PAST. At this point it would be nice to be able to write a second constructor. Even a private one. TOO BAD.

I aint going back into the code and changing every place that uses the old constructor. So, now I'm faced with the necessity of adding what amounts to a childish, amateurish hack. In other words,


public function myObject(myXML:XML):void {
  if (myXML==null) return;
  ...
}



Isn't that fantastic? I love it.

Really, this is not winning me over.
So I built a little language for substituting strings, meant for passing arguments into actions. It has two features:

  1. $[n[ ... ]] operator prints one string if an argument is present, prints another one otherwise (or print nothing);
  2. ${n} substitutes arguments for placeholder variables.

For example, "I have $[1[${1}$||no]] problems$[2[ but a ${2} aint one]]" , with the arguments {"99", "Regular Expression") becomes "I have 99 problems but a Regular Expression aint one." With the arguments {"99"} it is just "I have 99 problems." With no arguments, it is "I have no problems." This becomes practical when you have a string like "dictionary.php$[1[?word=${1}]]" , which would allow you to use one action for going to a dictionary page and passing the word to lookup in as an argument, instead of defining actions for every word you want to lookup on the page. This is a good thing.

Speaking of good things, here's a silent round of applause for regular expressions. They've saved my butt on any number of occasions and never asked for nothing in return. On the other hand, shame on you, high-level programming languages, for adopting 20,000 different formats for specification of regular expressions and capabilities thereof. There is no way to effectively learn the differences between the way language x does regex and the way language y does it. Trying to learn one is useless, since that knowledge will quickly be replaced or confused with knowledge from the other.

And shame on all those who fail to organize documentation for their regular expressions in a logical, tabular format (I'm looking at YOU, Adobe). Preferably INSIDE the API documentation. KTHX.
More suffering over labels in subtitles. Restructured inheritence to make more sense: previously, subtitles extended SutekiObject (a container with common methods available to interactive objects), containing labels with the subtitle text, put into SubtitleGroup, a container that attaches subtitles together. Now, SubtitleGroup itself extends SutekiObject, and Subtitle itself simply extends LinkButton. This makes much more logical sense, and makes things a lot easier. It also made action propagation a little harder, and there might be a better way to structure it, but for now it works okay. Spent a long time struggling with size of each subtitle. Flex seems to make controls excessively large, and I had the darndest time shrinking them. It's still not satisfactory. There are gaps between each chunk of linked text. This is a problem if you're linking each individual letter in a word (it ends up looking like "h e l l o w o r l d"). However, this is only a problem in English. I figure it will be okay for Japanese, where a gap between each character won't be so bad. To get around this I will need to write my own layout code, and I fear getting bogged down in that. So I'm moving on now. Anyway, subtitles are working pretty well.

And Japanese text works, which is a very good thing.


... is evil. For example, let's say my SWF requests an XML file from the server in order to get video information, which it then receives and operates on. Well, there's no guarantee that file is the latest file, as browsers seem to not even bother checking if a new one needs to be downloaded and just use the cache instead. Let's then go ahead and say that someone (me) is going to be editing that XML file A LOT because that's where all the important video and interactive object information is stored. The SWF isn't going to see any of those changes because the browser is too stupid do grab the right file.

Unbelievably, the fix is this:


	var url:String = "myXMLFile.xml" + "?" + new Date().getTime()

	var loader:URLLoader = new URLLoader();
	var request:URLRequest = new URLRequest(url);
	loader.load(request);




Does anyone else find this incredibly idiotic? So to get an XML file named "myXMLFile.xml" you need to request "myXMLFile.xml?1225568783273" or whatever. And does that mean the browser is caching like 500 different versions of myXMLFile, one for each call?

Other, more ridiculous solutions have included generating a random number and appending that to the url. Why should we have to do this?

(plus my mouse is malfunctioning and double-clicking when I single-click. Hateful in the extreme!)


Overloading methods in Flex is NOT supported. There's a strange mix of strong typing and loose typing (a holdover from an ecmascript base?) going on. It seems it's possible to pass like as many arguments into a method as you want, but god forbid you establish different methods to handle it. So you have to set up overloading manually.

The basis for this comes from Farata systems(external link) and Darron Schall(external link). In this project, I use it for showing the current time of the video plus the status (playing/paused/seeking/etc):


	private function updateStatus( ... rest ):void {
		if (rest.length > 0){
			baseStatus = rest0 + "";
		}

		tf.text = video_screen.formattedTime + " " + baseStatus;
	}



"... rest" allows any number of comma-delimited variables. So in this case, if an argument is passed in we change the baseStatus string and then write it to the screen via the tf Text control. Otherwise we just update the time.

No guarantees about the awesomeness of this code, sorry.

(Now, what if you want to specify precisely what variables are allowed, and configurations thereof, instead of just some pot luck array? Well, you can't. Too bad.)



I've been storing a lot of the stuff that should go in here in the work logs instead. This week has been particularly bad. I might move some of it to this blog if I get a chance before the code release.
Delivered a presentation for the second sprint review. Presented a working demo that approximates NicoNicoDouga. It worked for the presentation, which is a good thing. I just copied the Flash Player onto Dr. Beck's laptop and open the SWF with it and it ran fine. It has been confirmed by Ebi that it works on the website as well, which is also good news.

It's not too pretty, but that's not really the point. One problem that I will need to look into is choppiness (is that a word?) of text movement. Right now I have an event listener for frame changes in the video - and the video runs at 30 frames per second. So we need to do some math for each comment each time this event gets called. Maybe that's an unreasonable load, but it looks like not every frame is causing an update.

This could be because the update time is too long and more frames have passed while we were doing the math. Or maybe it's inherent to the event model itself. But it will matter in the long run. Do I need to look into a multi-threaded implementation? Does ActionScript support that?

Another solution could be to make animations between each discrete x position.

Links to Code Release items:

Now I shall deliver much-needed sleep to my body.
I think I'm becoming addicted to Google Tech Talks.

http://www.youtube.com/user/googletechtalks(external link)

But not enough time in my life to watch 926 of them...
Page: 1/2
1 2