As you probably noticed (if you are reading this)
I have decided to add Gigya Socialize to my blog, (seemed only reasonable).
When you read a blog entry on my blog it will be reported to as an action you preformed and you can see both your friends actions and your own on the bottom of the right sidebar.
You can also read what was written about un in techrunch:
Gigya Socialize Goes Up Against Google Friend Connect.
Feel free to tell me what you think about this.
Thursday, May 29, 2008
Gigya socialize live example
Monday, April 28, 2008
Optimizing Actionscript 2.0 - a bytecode perspective - Part I
Lately I have beeing looking at ways to optimize some actionscript 2.0 code.
I had two goals, the first was to reduce the size of the .swf file and the second was to make some parts of it faster at runtime.
I will try and write a series of posts describing what I have learned and still am learning from this.
Generally speaking - in most cases optimizing for speed comes at the expence of space and vice versa. also there are isues with how easy the code is to maintain after optimizing. With all that in mind I started looking at my code.
At first I was looking at the code at the action script level, but very soon i decided that If I realy want to understand what is gooing on under the hood I will have to look at bytecode (or actually P-Code at that stage).
Tools
- FlashDevelop - As a development environment.
- FLASM
The first thing that drew my attantion when I looked at the flasm output .flm file for my .swf was the repeating pattern
push 'com'
getVariable
push 'name'
getMember
push 'space'
getMember
push 'parts'
getMember
push 'functionName'
getMember
that was allover the place.
could it be?
each type that I write com.name.space.parts.function() it does all that ?
but wait - I have an import statement - is it not chaching those refrences somehow ?
argh... is that the price for deveoping a nice heirarchical class library ?
o.k. - lets cool down - lets try a simple example.
Lets look at the .flm of a project that includes two classes:
class com.epeleg.utils.Debug {
public static function traceThis(s) {
trace(s)
}
}
and a Main class:
import com.epeleg.utils.Debug;
class Main
{
public static function main():Void
{
Debug.traceThis('hello');
Debug.traceThis('world');
}
}
Lets build (in release mode) this and look at the results:
The .swf was 425 bytes.
if you realy must (and if you are like me - you probably do) see the entire .flm that was created Click Here:
movie 'PATH_TO_MY_SWF.swf' compressed // flash 8, total frames: 1, frame rate: 30 fps, 800x600 px
defineMovieClip 20480 // total frames: 1
end // of defineMovieClip 20480
exportAssets
20480 as '__Packages.Main'
end // of exportAssets
initMovieClip 20480
constants 'Main', '_global', 'prototype', 'main', 'hello', 'com', 'epeleg', 'utils', 'Debug', 'traceThis', 'world', 'ASSetPropFlags'
push 'Main'
getVariable
not
not
branchIfTrue label1
push '_global'
getVariable
push 'Main'
function2 () (r:1='this', r:2='super')
end // of function
setRegister r:0
setMember
push r:0, 'prototype'
getMember
setRegister r:1
pop
push r:0, 'main'
function2 () (r:1='this')
push 'hello', 1, 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
push 'traceThis'
callMethod
pop
push 'world', 1, 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
push 'traceThis'
callMethod
pop
end // of function
setMember
push 1, NULL, r:1, 3, 'ASSetPropFlags'
callFunction
pop
label1:
end // of initMovieClip 20480
defineMovieClip 20481 // total frames: 1
end // of defineMovieClip 20481
exportAssets
20481 as '__Packages.com.epeleg.utils.Debug'
end // of exportAssets
initMovieClip 20481
constants 'com', 'epeleg', 'utils', 'Debug', '_global', 'Object', 'prototype', 'traceThis', 'ASSetPropFlags'
push 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
not
not
branchIfTrue label4
push 'com'
getVariable
not
not
branchIfTrue label1
push '_global'
getVariable
push 'com', 0, 'Object'
new
setMember
label1:
push 'com'
getVariable
push 'epeleg'
getMember
not
not
branchIfTrue label2
push '_global'
getVariable
push 'com'
getMember
push 'epeleg', 0, 'Object'
new
setMember
label2:
push 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
not
not
branchIfTrue label3
push '_global'
getVariable
push 'com'
getMember
push 'epeleg'
getMember
push 'utils', 0, 'Object'
new
setMember
label3:
push '_global'
getVariable
push 'com'
getMember
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
function2 () (r:1='this', r:2='super')
end // of function
setRegister r:0
setMember
push r:0, 'prototype'
getMember
setRegister r:1
pop
push r:0, 'traceThis'
function2 (r:2='s') (r:1='this')
end // of function
setMember
push 1, NULL, r:1, 3, 'ASSetPropFlags'
callFunction
pop
label4:
end // of initMovieClip 20481
frame 0
constants 'MTASC_MAIN', 'this', 'Main', 'main'
push 'MTASC_MAIN'
setRegister r:0
pop
push 'this'
getVariable
push 1, 'Main'
getVariable
push 'main'
callMethod
pop
end // of frame 0
end
otherwise (or afterwards) lets focus for a moment on the following:
push r:0, 'main'
function2 () (r:1='this')
push 'hello', 1, 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
push 'traceThis'
callMethod
pop
push 'world', 1, 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
push 'traceThis'
callMethod
pop
end // of function
this is the code that is generated by the compiler, yep - read it again...
now if I would go to optimize this by manipulating the code at this level I could probably do something like:
push r:0, 'main'
function2 () (r:1='this')
push 'world','hello', 1, 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
dup
push 'traceThis'
callMethod
pop
push 'traceThis'
callMethod
pop
end // of function
well, this might work for some people, personally - (at least now) I had no intentions for manipulating the code at this level - what I wanted was a way to change my actionscript to force the compiler to create something smarter.
Attempt 2
change the main class to:
a Main class:
import com.epeleg.utils.Debug;
class Main
{
public static function main():Void
{
var TR=Debug.traceThis;
TR('hello');
TR('world');
}
}
and looking at the appripriate section again (sorry - no full code again) we now have:
push r:0, 'main'
function2 () (r:1='this')
push 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
push 'traceThis'
getMember
setRegister r:2
pop
push 'hello', 1, r:2, UNDEF
callMethod
pop
push 'world', 1, r:2, UNDEF
callMethod
pop
end // of function
o.k. now this looks better, only thing is that the .swf is now 428 bytes.
this is reasonable beacuse we added the new variable to the constant pull.
also what is this UNDEF ?
lets try a different version for class main:
import com.epeleg.utils.Debug;
class Main
{
public static function main():Void
{
var DGB=Debug;
DGB.traceThis('hello');
DGB.traceThis('world');
}
}
swf size is still 428 bytes, but the ugly UNDEF is gone,
push r:0, 'main'
function2 () (r:1='this')
push 'com'
getVariable
push 'epeleg'
getMember
push 'utils'
getMember
push 'Debug'
getMember
setRegister r:2
pop
push 'hello', 1, r:2, 'traceThis'
callMethod
pop
push 'world', 1, r:2, 'traceThis'
callMethod
pop
end // of function
is This realy better - The Quick answer is No, actually the one with the UNDEF is better then the last one.
Why ? I will try and explain on the next Post where we wil take a closer look at the actual bytecode.
Thats all for now.
Monday, April 07, 2008
Configuring custom dynamic DNS (DDNS) agains ENOM on DD-WRT
I was messing around with my linksys trying to set up QoS and ended up resetting it,
loosing my DDNS settings and having to recreate them.
Took enough time for me to sit donw and write this down so that (my) next time would take less.
so here goes:
you would ususally have a single domain (e.g. dyn.yourdomain.com) that you would change dynamically and then have other domains that would map to it using CNAME entries.
If you have dynamic dns services provided by enom (I got mine when I moved to enom from registerfly) and you want your dd-wrt router to do the updating:
1) go to the web interface of your roter - ususally via 192.168.1.1
2) select the setup tab and the DDNS sub tab
3) in the DDNS Service combo choose Custom
4) DYNDNS Server should be set to dynamic.name-services.com
5) for some reason the UI does not allow you to leave out the User Name and Password so I just push _ in each of them
5)Hose Name should be set in our example to dyn.
6) URL should be set to /interface.asp?Command=SetDNSHost&Zone=yourdomain.com&DomainPassword=HEX_PASSWORD_YOU_GOT_FROM_ENOM&HostName=
[Update Aug 11th 2009: based on comment by Greg Bray]
6) URL should be set to /interface.asp?Command=SetDNSHost&Zone=yourdomain.com&DomainPassword=DOMAIN_ACCESS_PASSWORD_YOU_SET_UP&HostName=
To set up the DOMAIN_ACCESS_PASSWORD_YOU_SET_UP use the Domain Access Password field on the General Setting page of the Enom Control panel.
Greg was also kind enough to mention that:
Also, the URL that you listed will use the outgoing ip address as the value for updating the dns record. This should work in most cases, but if you want to specify the IP address for the record you need to include &Address=NEW_VALUE in the update url.[/Update]
the hostname(5) itself will be appended to the DYNDNS Server(4) and URL(6) to create the entire URL for the request.
if you wish you can set the Additional DDNS Options field to --verbose 5 - this will show a much more informative output in the DDNS Status frame below after you press "Save Settings".
Done ?
now go to the Administration tab and select "Backup" to back up your configuration.
one last information bit:
Dynamic DNS updates FAQ on ENOM
http://www.enomcentral.com/help/faq_dynamicdns.asp
Wednesday, January 23, 2008
Tuesday, December 04, 2007
The class 'com.your.class' cannot be imported because its leaf name is already being resolved to imported class 'com.your.class'.
While I was refactoring some ActionScript2 code, I ended up with the above error message.
I searched the web and what I came up with was mostly the information that such a message actually exists.
so after figuring out why I got that error I decided to write about it here for your benefit. (Leave me a comment if it helped you).
well it turns out that this was cause by the following proccess:
I have an adbode flash source .FLA file which had inside its _root code two #include statements:
lets say
#include "fileA.as"
and
#include "fileB.as"
now each of those file in its turn had an import statement
import MyClass
where MyClass.as was a file that was on the same directory as the .FLA, fileA.as & fileB.as.
It worked fine.
But when I started refactoring and moved MyClass to become com.whatever.MyClass
(with all the required changes to MyClass, fileA and fileB) I suddenly got
"The class 'com.whatever.MyClass' cannot be imported because its leaf name is already being resolved to imported class 'com.whatever.MyClass'".
The solution was to remove the import statements from fileA.as and FileB.as
and just place one import directly in the .FLA.
(the #include files are on thair way out as well...)
My recomendation: Try to avoid #include, most likely you can get better results by using a static class.
