Thursday, 11th March 2010.

Posted on Wednesday, 10th June 2009 by chris

发现了一些FlashPlayer 9 与FlashPlayer 10之间的不一样之处,很是怪异。

处理XML:

在Flash 10中将播放器设为Player 9后下面代码执行结果为

<site>
<p>world</p>
</site>

而设为Player 10后执行结果为

<p>world</p>

//以下为代码

1
2
3
var xml:XML = <config><site></site></config>;
xml = xml.site[0].appendChild("<p>world</p>");
trace(xml);

而下面这个代码的执行结果确又是一样的

//代码

1
2
3
var xml:XML = <config><site></site></config>;
xml = xml.site[0].appendChild(<p>world</p>);
trace(xml);

结果都是
<site>
<p>world</p>
</site>

有点晕,不知道是何原因。所以为了防止播放器的不一致,遇到这种appendChild()里面放置字符串的情况还是改用类似下面的写法,算Flash狠了。

1
2
3
var xml:XML = <config><site></site></config>;
xml = xml.site[0].appendChild(new XML("<p>world</p>"));
trace(xml);

这样,两个播放器也就一致了。

代码的执行顺序:

这个很有问题,如果两个代码执行顺序不一致,那可能运行的效果就完全不一致。不过两个版本确实在这方面存在差异。

如果我们只是简单地新建一个Flash文件,在里面新建一个MovieClip并且在其第一帧上增加下面的代码:

1
2
3
trace("onframe1 before call gotoandplay 10");
gotoAndStop(10);
trace("on frame 1 after call gotoandplay 10");

在其第10帧处插入下面的代码:

1
trace("now on frame 10");

把文件的设置中的播放器设成 Flash Player 9 或者 Flash Player 10 其执行结果是一致的,都是:

onframe1 before call gotoandplay 10
on frame 1 after call gotoandplay 10
now on frame 10

也就是说是执行完第一帧上的所有代码后再执行第十帧上的代码,这一点应该是跟我们想像的一致的,也没什么异议。

但是我们改一种写法,删除刚才这个文件中的这个MovieClip中的第一帧的代码,将这个MoiveClip的Class设置成TestMC,并且新建一个TestMC.as的文件,内部代码为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package
{
import flash.display.MovieClip;
 
public class TestMC extends MovieClip
{
public function TestMC()
{
stop();
trace('[use class]before gotoAndStop 10');
gotoAndStop(10);
trace("[use class]after gotoAndStop 10");
}
}
}

这样一来,在播放器设成 Flash Player 9时执行的结果是:

[use class]before gotoAndStop 10
[use class]after gotoAndStop 10
now on frame 10

跟刚才的上面的顺序也是一致的,不过在将播放器设成 Flash Player 10时,执行结果却是:

[use class]before gotoAndStop 10
now on frame 10
[use class]after gotoAndStop 10

也就是说这样一来,先执行被调用的帧上的代码,然后再继续现有的代码,等于是把“gotoAndStop”到的相应帧上的代码插入到现有的代码中执行,这个顺序跟之前的是完全不一样的。到底是哪一种执行的顺序是更合理的?不是很好说,不过作为一个专业级的程序员,一个好的习惯是尽量少在帧上写代码。

点击此处下载与此相关的测试文件。

Tags: ,
Posted in ActionScript, Flash | Comments (7)

Posted on Friday, 5th June 2009 by chris

最近很忙啊,不过这两天终于把http://www.dickies.com.cn 忙得差不多了,今天算是正式上线了,下午还是发现了几个小的bug,给改了一下,可能还会有一些,以后发现再改吧。
这次这个网站继续使用自己的这个网站框架,也进一步完善了这个框架,下一步要解决的就是框架资源占用的问题。如何能够在不依赖本地缓存又不增加内存使用的情况下保留已经加载过的文件,不至再到服务器上下载,这个看来还是个难题啊。

Tags: ,
Posted in 网站 | Comments (6)

Posted on Thursday, 28th May 2009 by chris

http://www.mailchimp.com/blog/background-images-and-css-in-html-email/

We’ve noticed a few people having issues with background images in their HTML email designs, so we thought we’d post some quick tips here.

Lots of email applications (especially the browser-based ones, like Yahoo!Mail, Hotmail and Gmail) strip out your , and tags. It kinda makes sense, if you think about it. They’re displaying your email inside their web page. They don’t want your page settings (like background colors, files, CSS, etc) to interfere with their overall interface. So they strip it all out.

That means you’ll kinda have to rig your HTML email to make certain things work…

Background Images and colors in HTML Email

If you want to set a background image or color in your HTML email, you can set it in your BODY tag, where it usually goes. That’ll work ok for some desktop email applications, like Microsoft Outlook.

But to make it work across more email applications, you need to “rig” your code so that your entire email is set inside a big TABLE WRAP. Just set a big table that’s 100% wide, then specify your background color and image there. We recommend doing it the old-fashioned “bgcolor” or “background=”” way. If you prefer doing it with CSS, be sure to read the “CSS” tips below. As with all images in HTML email, they need to be hosted on your server, and you need to point to them with absolute (not relative) paths.

Once you’ve created the big TABLE WRAP with your background color or image, place your actual newsletter code inside, and you’re good to go.

If you’re a very experienced web designer, this will no doubt make you feel dirty, and make you want to take a shower immediately afterwards. But HTML email isn’t as reliable as web pages are (yet) and there are way too many email apps out there that display HTML differently. Until all the various email apps get a little more consistent, you’re going to have to get used to “rigs” like this.
CSS in HTML Email

There are all sorts of “CSS tips and tricks for HTML email.” But the main thing to remember is that the and tags get stripped when HTML email is displayed in browser based applications. So that means you can’t link to an external CSS file from the portion of your email. You’ll need to use embedded or inline CSS in HTML email instead. And, if you take the embedded approach, be sure to place all your code BELOW the tag. Place it just above your content. Feels dirty, I know. But it’s the only way to get CSS to work (reliably) in email.

Periods = “Stop Email!”
If you start any line in your email with a “period,” some email servers interpret that as “end of message” and they’ll stop it right there. D’oh! So this affects how you need to code your CSS. When you embed your CSS, be careful with the little “dots” or “periods” that are used to define styles. If you start your line of CSS with “.header” for instance, that’s exactly where some email servers will cut your message off. So in your CSS, add a space before every single line that starts with a period.

It’s not just a CSS thing. It’s any line that starts with a period (see our previous post). But the CSS portion of your email is more likely to have lines that start with periods, so it’s good to mention it here.

Tags: ,
Posted in CSS, HTML | Comments (1)

Posted on Saturday, 16th May 2009 by chris

http://www.hesido.com/web.php?page=customscrollbar

Tags:
Posted in CSS | Comments (0)

Posted on Sunday, 26th April 2009 by chris

.FLV files are already the best method for publishing video on the web, and are sure to become even better with the new enhancements in Flash 8. When serving .flv files off of a Windows Server 2003 (or any other Windows server I would imagine) requires setting up the MIME type on the server first (it isn’t one of the native MIME types on MS servers).

You can figure out easily if your server is configured to support .flv files by posting a .flv file on a server and navigating to the URL of that .flv in a browser. If you see a LONG string of garbage on the screen, your server isn’t set up for .FLVs and needs to have the MIME type set up.

Adding .flv MIME type in IIS

1) Select the site to configure in IIS, right click and select “Properties”
2) Under HTTP Headers Tab, select “File Types” under the MIME Map section and select “New Type”
3) Type “.flv” as the associated extension and “video/x-flv” as the content type.
4) Select “OK” and you’re ready to fly!

Tags:
Posted in Flash | Comments (3)