Log in

No account? Create an account
Flash - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Flash [Jun. 2nd, 2001|06:34 pm]
Brad Fitzpatrick
I'm taking a break from studying to learn Macromedia Flash. I noticed they had a free download of the authoring software on their website.


Update: That was fun for, like... 5 minutes almost. Need to get back to studying. I'll resume making ghost symbols and scaling and rotating them after finals.

[User Picture]From: firelegend
2001-06-02 09:31 pm (UTC)

Re: ah the wonders of flash..

yeah yeah i was freakin coping and pasting outa ma
movie MO FO!!!!!!! You always pickin on me :P

yeah clicked = new String("down") works, though some would say declaring the new string is good form.. but ya don't have to do it.. I dunno!
(Reply) (Parent) (Thread)
[User Picture]From: bradfitz
2001-06-02 10:05 pm (UTC)

Re: ah the wonders of flash..

Allow me to pick on you more....

clicked = new String()

is not a declaration. In fact, you seem to not declare "clicked" at all. A declaration is a statement that assigns a type to a symbol within a namespace.


clicked = new String();
clicked = "up";

is actually more wasteful than:

clicked = new String("up");

Because in the prior case, you call the constructor of the String class and it sets its length member to 0, and depending on how efficient it is, allocates a zero length string for it. Then, on the next line the constructor is called again, since in most languages like that assignments of string literals are overloaded in the language spec to be assignments to a new construction of a String with the string literal as the arguement to the constructor.

That is, this:

foo = "bar";

is changed to:

foo = new String("bar");

at compile-time. (where by compile-time I don't care if it's an interpretted language... it's still compiled into some form before being interpretted)

So, your way of doing it in two lines is equivalent to:

clicked = new String();
clicked = new String("up");

But... you don't handle memory management in ActionScript do you? So that means the clicked symbol has a reference count on it... the old empty String you had assigned to it now has to be discarded, so your way is not only an extra line, but it's either slower (if the free happens immediately), or bloated (if the extra instance of the string object lives on for awhile, before a garbage collecting thread comes along and cleans up)

If you want to discuss languages, compilers, or any other geeky CS topic, you know where to find me. :)

(Reply) (Parent) (Thread)