Archive for 2008
Detect ActionScript 2/3 in TextMate
I made
a very rough tmplugin
(TM 1.x OSX 10.4+ UB) to search the word “package” in the beginning of first 20 lines of .as file to determine whether it’s AS3 or AS2, then select a proper bundle. It’s modified from
TabMate
.
You should have
ActionScript
and
ActionScript 3
tmbundle before install this tmplugin.
Growl notification for 1G1G.com
It’s a
Fluid
SSB user script.
// ==UserScript==
// @name 1G1G
// @namespace http://fluidapp.com
// @description Show Growl notification when song changes
// @include *
// @author freewizard gmail.com
// ==/UserScript==
(function () {
if (window.fluid) {
window.lastTitle = "亦歌-自由自在听音乐";
setInterval(function() {
if (document.title == window.lastTitle) return;
window.lastTitle = document.title;
window.fluid.showGrowlNotification({
title: "亦歌",
description: window.lastTitle,
identifier: "www.1G1G.com"
});
}, 1000);
}
})();
Quick filter by mail topic in Microsoft Entourage
Save the following AppleScript code as ~/Documents/Microsoft User Data/Entourage Script Menu Items/Quick FiltercF
on ltrim(someText)
repeat until first character of someText is not in {" ", tab, ASCII character 10, return, ASCII character 0}
set someText to text 2 thru -1 of someText
end repeat
return someText
end ltrim
on run
tell application "Microsoft Entourage"
--activate
set msgs to the current messages
if msgs is {} then return
repeat with msg in msgs
set subj to get the subject of msg
end repeat
set AppleScript's text item delimiters to {":"}
set tpc to last text item of subj
end tell
set tpc to my ltrim(tpc)
set the clipboard to tpc
tell application "System Events" to tell process "Entourage"
delay 0.1
keystroke tab
delay 0.1
keystroke "v" using command down
keystroke tab
end tell
end run
Make sure quick filter is turned on (Cmd-Shift-L);
Click one item in the messages list;
Click script menu and select our script.
Show unread mails in Skype mood text
Cross-domain classes in ActionScript 2.0
Yes, you are right that we still live in a world with ActionScript 2.0 somewhere.
As described by
Adobe
, content loaded from different domains belong to different sandboxes, and you can make them communicate to each other by calling System.security.allowDomain(”*”).
However, this only permits you calling methods in the swf from the other domain, not the class definitions. In order to create an instance of a class from the other domain, you have to:
// http://domain1/a.swf _global["Tier"] = _root._parent.GetClassTier(); var t = new Tier();
and
// http://domain2/b.swf
class Tier {
//...
}
function GetClassTier() {
return _global.Tier;
}
Ok, now you are able to create a cross-domain instances. Then what about extending from a cross-domain class? The key is letting b.swf to load from a “proxy” class.
// http://domain3/c.swf
class Hund extends Tier {
//...
}
and
// http://domain3/c_proxy.swf _global["Tier"] = mc._parent.GetClassTier(); // call MovieClipLoader to load c.swf here
The reason you must have a proxy is bc AVM1 executes class definition in initClip stage when the loadee MovieClip is not available yet to access the loader MovieClip. If you try to extend from a class which was not in _global yet, it will never get a proper super value.
It’s ugly that you have to do such hack, while not so bad ‘cz you’re survived!
Cross-domain bug inside ActionScript 2.0
I believe it’s a bug: you turned off security check, it still tells you there’s a security violation when two swf read varibles from each other in certain way; however you end up finding that’s only a warning, you can still do it as is.
a.fla:
import System.security;
System.security.allowDomain("*");
function onLoadInit( mc:MovieClip ){
mc.test({test:"test"});
}
mcl = new MovieClipLoader();
mcl.addListener( this );
mcl.loadClip( "http://127.0.0.1/b.swf?"+Math.random(),
this.createEmptyMovieClip( "_container", this.getNextHighestDepth() ) );
b.fla:
import System.security;
System.security.allowDomain("*");
function test(o) {
trace("test func");
for(var i in o) { // violation happen here before any trace() below
trace(i);
}
}
Type http://localhost/a.swf, now you’ll get the buggy dump in log.In fact, there are an other couple of way to reproduce this, such as read/write an undefined member in a cross-domain object.
This blog has been switched to AppEngine
A new player to the desktop RIA playground?
With the release of
GTalk Lab Ed
, an desltop version of
GTalk Gadget
, Google has showed up its achievement of
WebKit
engine embedding. After Adobe AIR, Mozilla Prism and
some announcement
from m$, the search giant maybe also silently joined the Desktop RIA game. Will the
gears
finally become a
Porsche? Let’s guess…
Developer Platform Comparison: MySpace vs. Facebook
MySpace China
has opened its
developer platform
to some beta testers. Similar to
Facebook Platform
,
the dev zone has a list of APIs, some language wrappers(only
ActionScript for now) for the API and a test console. Detailed
comparison follows:
| MySpace | ||
|---|---|---|
| RESTful API | yes | yes (see below) |
| Query | FQL | n/a |
| Markup | FBML + FBJS | n/a |
| Test Console | yes | yes |
| Authentication | own protocol | OAuth |
| SDK | 15+ | 1 for now |
Generally,
I appericiate their picking up of OAuth. But the number of objects and
functions accessible via API is too much fewer than Facebook’s.
OpenSocial API to push activities is still on its way either.
Well, for MySpace, opening is a big step, but too early to give them a bravo.
OAuth Core 1.0 Final in Chinese
Official Document in English
and
My Translation in Chinese
(中文版附录暂未翻译)
The OAuth protocol enables websites or applications (Consumers) to access Protected Resources from a web service (Service Provider) via an API, without requiring Users to disclose their Service Provider credentials to the Consumers. More generally, OAuth creates a freely-implementable and generic methodology for API authentication.
OAuth协议致力于使网站和应用程序(统称为消费方)能够在无须用户透露其认证证书(译注:如登录密码)的情况下,通过API访问某个web服务(统称为服务提供方)的受保护资源。更一般地说,OAuth为API认证提供了一个可自由实现且通用的方法。