Why SOMETIMES … (String == Number) ….

March 10th, 2008 by Jaap Kooiker

So I encountered a really weird, but probably “explainable” problem in AS2 yesterday.
We all know that
trace("200.1" == 200.1) //true
and
trace("200.2" == 200.2) //true
trace(”200.3″ == 200.3) //true


trace(”200.81″ == 200.81) //true
trace(”200.81″ != 200.81) //false

This above works fine…but the following is what scares me the most….
trace("200.82" == 200.82) //false
Why the hell is the above false ???? And the really weird thing is
trace("200.82" != 200.82) //false
also false ???
So… it is NOT the same and it is NOT NOT the same?…wtf is it. AS doesn’t seem to know what it is.

Ok, bear with me a second. The following:

trace(”200.83″ == 200.83) //true
trace(”200.83″ != 200.83) //false

…that seems alright

At this point, I tried to make some sense of it and applied the following rules….
If a string has one decimal….it turns out to work fine…
If a string has two decimals….it only works fine if the last digit is uneven…

The next thing to check is a string with three decimals and…there seems to be a different stupid rule here…check…

trace("200.811" == 200.811) //true
trace(”200.811″ != 200.811) //false

trace(”200.812″ == 200.812) //true (should be false according to last “rules”)
trace(”200.812″ != 200.812) //false

Hmmm, it seems that we can erase the above rules from our head. It works fine at this point…what is that about?

One more sample…the second decimal after decimal point is an even digit.

trace("200.821" == 200.821) //false
trace(”200.821″ != 200.821) //false

trace(”200.822″ == 200.822) //false
trace(”200.822″ != 200.822) //false

Oh my god…..the second digit after decimal point is even and it is always false?? I can’t seem to make sense of it….sorry…
I can probably go on and on with more samples (four / five / etc. decimal digits) but the point is clear….it’s fucked.

If I trace typeof, it all seems to be a Number

trace(typeof(parseFloat(”200.81″))) //number
trace(typeof(parseFloat(”200.82″))) //number
trace(typeof(parseFloat(”200.821″))) //number

Converting the String to a Number or use parseFloat doesn’t work….so don’t bother trying.

Maybe it has something (the way it parses a string to a number or visa versa) to do with rounding Numbers…see what Arno has to say

Jaap

Posted in Actionscript 2.0, Bugs, Flash 8, Flash CS3, Flex | 6 Comments »

Beta Test Version “Total Los” online !

January 7th, 2008 by Jaap Kooiker

This is one of the many products I’ve been working on in my spare -> spare -> spare time. It’s done totally free because it’s a local drumband wich can’t afford my hourly rate at the time (oh yeah, and my mother and sister are members of the band :) ).
Anyway this site is in Dutch and has no translation at the time. But the main idea will get clear when you see it.

Because this is a site with no hard deadline or cost target, I could spend my time learning new stuff and try something (almost) new (for me).
I have used 3d max to make a 3D environment and render the whole. Oh my god…I didn’t remember it was so complicated after the last - and only - time I used it four years ago.
Oh well… after a decade (it seemed like it) of tutorials and reading I started to make some 3D models and maps. The basic idea was to create some kind of an old hangar in wich the band does it’s practicing. I do realize I’m no expert (and maybe never will be) but I think the end result is pretty good.
After creating the hangar and stuff inside I went and created some camera’s and started to aminate the cam trough the hangar. This resulted in a flying cam from a fixed spot to the top of a specific bin and open the contents.
Making the camera go back after clicking home gives it some extra interactive feeling. One thing I intend to improve is when a bin is clicked and a book is showing, it needs to use all the screen width. This way (in case of large enough resolution) scrolling is not needed.

The final contents are not set yet… Let me know what you think of this beta release…

Edit:
Final Version : http://totallosameland.nl

Jaap Kooiker

Posted in 3D, Actionscript 2.0, Experiments, Flash 8, Flash Video, Social networking, websites | No Comments »

Dear Security Warning: Where are you….!

May 30th, 2007 by Jaap Kooiker

A couple of days ago I struggled with (at the time) seemed a strange problem.

I had a main application which on it’s part loaded new applications (sub swf’s). Both (the main and the sub) swf’s where on my local machine at the time of development and both swf’s used (besides many other classes) the same (from the same package) static class with static functions. Let’s say the Class had a counter which whenever called, a function called countUp() traced the current count, like so:

public static function countUp():Void{
trace(”current count: “+Sample.countUp++);
}

(output : current count: 1)
(output : current count: 2)
(output : current count: 3)
(output : current count: 4) and so on…

For now everything worked fine. So at the end of the day I uploaded all the swf’s to a test server. The next morning I started with a glimps at the victory I achieved the day before. I did this by compiling the main application and discovered it wasn’t working anymore. The output for an instance would be this:


(output : current count: 1)
(output : current count: 2)
(output : current count: 3)
(output : current count: 4)

and when the external loaded swf called the static method


(output : current count: 1)
(output : current count: 2)
(output : current count: 3)

After that the main application called the static method which resulted in this

(output : current count: 5)
(output : current count: 6)
(output : current count: 7)…

Somehow the two swf’s used a different static class??? At that time I had a big questionmark above my head and got up to get some coffee first.

While drinking my coffee I re-tested the whole on the test server and it worked fine…what the… After some struggeling I remembered that the XML for the main application had Urls to the sub swf’s. Of course these sub swf’s where comming from the server. Maybe that is the problem? I discussed this with a colleague of mine and we concluded flash does this (as in the sample above) for security reasons (of course). This way it is not possible for another external swf to manipulate the classes from another server. It’s all seems so logical now…

So from an interaction design point of view:

If there only was a Sercurity Warning in the flash output panel….

Jaap Kooiker

Posted in Actionscript 2.0, Did you know?, Experiments, Flash 8, Interaction Design | 1 Comment »

Adobe, you missed a chance by shipping the wrong components set with Flash CS3

May 14th, 2007 by Jaap Kooiker

I’m sorry to say the above out loud, but I just have to.
Personally I don’t like the standard flash components. Why? They are heavy and mostly unusable because we use flash to build custom interfaces and the standard components aren’t made to be custom easily. Take for instance a button and try to make a fade between off state and on state. Anyway, once in every couple of years I grab a component (as with the FLVPlayback in an earlier post) and start playing with it. The conclusion: I always get a little disappointed.

I know, I know, in a moment I’m going to tell you what I want, keep reading

Now with Flash CS3 Adobe has thrown away the one component that could be of any use and that’s the accordion component. Well that said…. I still think the components set shipped with Flash CS3 is wrong. I have my own custom AS2 components which do exactly what I want, when I want. I name a few: Button, DropDown, Accordion, List, Pane (which is Box in Flex), Scroll, Pager, and so on…. You noticed something? There are similarities in the standard Flash components set and mine! But I still (and many others out there) create my own, mine are very customizable and do exactly what I want. So for me the flash components are obsolete and ready to be thrown overboard.

So, what do I want…

…the basic, but apparently unappealing (I mean not selling) layout components (which are shipped with Adobe Flex Builder). I think these would be helpful. I know these would be heavy to, but at least they are usefull and I will use them. The layout components could have sober functionality and they probably do what I want anyway, layout other displayObjects. The great thing is that skinning is not needed. Though the components have to be somewhat extendable, like in Adobe Flex. A few important components I’d like to see in the standard Flash Components Library: Container, Box, VBox, HBox. Devider… So Adobe, if you please could make these suitable for flash (or tell me why they can’t, please), I would be a happy man. For now I will just create my own layout components…again.

Jaap Kooiker

EDIT

Here’s a button sample in reaction to Serge (my component isn’t in the swf because currently I don’t have them at home, but I tried to make it clear what I want: fading, state transition, etc.)

EDIT EDIT

I had comment from some people who worked in this branche for a long time now and which I respect. One day I hope to be one of them….
For now, there isn’t anyone saying this is a good idea, isn’t there enough information (maybe sitting around a table with a few guru’s and me helps :)). Or is it nearly impossible to create good layout “components”?

Posted in Actionscript 2.0, Actionscript 3.0, Components, Did you know?, Flash 8, Flash CS3, Flex, Interaction Design | 10 Comments »

The importance of queuing commands

May 5th, 2007 by Jaap Kooiker

As I mentioned earlier I use a MVC framework which we created at my work. Now for AS3 we wanted to revise this MVC framework and review the whole, although it is already pretty good. The discussion about queuing commands raised. Here are some reasons why I think queuing commands is a good practice. Now there are some things you have to consider when using queued commands, like for instance build a (failure-) timeout when executing a command. Otherwise your next command may never be executed.

  • You always know which result belongs to which command dispatched, because you can only execute one command at the time;
  • Browsers have connection limits which opposes a problem when you dispatch multiple commands at the same time;
  • You can use singletons instead of instances as commands, which makes is easier to create and manage EventListeners. It’s more likely you don’t build up countless EventListeners for each command (because it’s a singleton);
  • Starting up an application can be better directed. If you know you have to execute, for example, 20 commands you only have to know if the last command’s result (or fault) event is dispatched. Now you can continue your startup of the application

So these are some main reasons why I think you should use this construction.

Jaap Kooiker

Posted in Actionscript 2.0, Actionscript 3.0, Did you know?, Experiments, Flash 8, Flash CS3 | 6 Comments »

« Previous Entries