月度存档: 7 月 2011

A funny game:)

]]>

as1,as2,as3的loading

如果创作的flash文件较大,就需要预加载。

可用性:ActionScript 1.0、ActionScript 2.0

Flash Player 4~8

示例

下列示例在加载所有帧后使用
_framesloaded

属性来启动 SWF 文件。如果尚未加载所有帧,则会按比例增大
bar_mc影片剪辑实例的_xscale 属性,以创建进度栏。

在时间轴的第 1 帧中输入下面的 ActionScript:

var pctLoaded = Math.round(this.getBytesLoaded()/this.getBytesTotal()*100);
//bar_mc._xscale = pctLoaded;
loadText=pctLoaded+"%";//use txt show progress

将以下代码添加到第 2 帧:

if (this._framesloaded < this._totalframes) {
this.gotoAndPlay(1);
} else {
this.gotoAndStop(3);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

可用性:ActionScript 3.0

Flash Player 9+
将您的loadText元件放在第 1 帧上。然后将以下代码添加到第 1 帧:

this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,myloadmovie);
this.loaderInfo.addEventListener(Event.COMPLETE,myover);
function myloadmovie(event:ProgressEvent):void {
var hl:Number=event.bytesLoaded/event.bytesTotal;
var n:Number=Math.round(hl*100);
loadText.text=n+"%";
}
function myover (event:Event):void {
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,myloadmovie);
gotoAndPlay(2);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

将您的动画内容放在第 3 帧上或其后。然后将以下代码添加到第 3 帧:

stop();

actionscript2的帮助文档地址

 

 

 

actionscript2的帮助文档地址

有时候看到一款精致的flash作品,解析后发现是as2&as1版本的,就有一种想把它转成as3的欲望,哈哈,转换过程免不了要用相关的文档了,就这个地址速度比adobe官方的那个快多了

 

 

as3 mp4

flash可以通过FLVplayback 组件来播放mp4, H.264 HD-quality videos.
但是通常而言,MP4的视频必须在下载完成后才能开始播放,幸运的是,现在有种方法可以边下载边播放:你要用到一个叫做 qt-faststart 的工具给你的MP4打个补丁,作用就是把headers信息从文件末尾移除,这样flash组件加载Mp4的时候就可以马上播放了,还没有加载的文件会在后台加载。

as3 clone

有朋友问我在as3中怎么克隆一个对象?我提供了个思路:就是获取当前对象的类,然后new一个新的对象出来,接着把当前对象的所有属性都赋值给新的对象的相应属性.9ria上也有一个办法用byteArray

各大网站登录地址

alexa排名
http://www.alexa.com/siteowners/claim
百度(中国最大的搜索)
登录口:http://www.baidu.com/search/url_submit.html
成功收录在1个月内
google
登录口:http://www.google.com/addurl/?hl=zh-CN&continue=/addurl
成功收录在1个月内

Dream_bookshelf

http://amyflash.duapp.com//swf/pic.swf

When I find the dream-bookshelf,I remember an ad: your stage is as big as your ambition.If you have no dream,no ambition,of course,you have no colorful life. Only if the man who has his dream can know the true meaning of life.

Everyone should have a dream, no matter how ridiculous your dream is. You have the chance to realize your dream that you never give up. the style of the dream-bookshelf in picture is cartoon,which is full with fun. You will remember so much
funny things in your life, so, if you like to have dream,then try to do a dream-bookshelf,maybe not only a bookshelf,which help you have a real ‘daydream’,:)
I like flash so much and flash is my dream,too.so I collect all the related pictures(which are from http://since1984.cn/) and push them into a flash you see at the first line.
]]>

用as3创建可拖动的进度条

如果你不知道怎么在flash里面创建可拖动的进度条,那么这篇文字就是为你写的。 首先, 我们要做的进度条是可以复用的, 它可以用于加载, 滚动条, 搜索框及图表功能. 另外,使用自己做的进度条替代flash里面的进度条组件有助于减小文件体积。

实例效果如下:

http://amyflash.duapp.com//swf/dragbar.swf

文件设置

在flash里面创建一个新的ActionScript 3.0文件, 590x300px为舞台大小, 文件命名为progressBar.as。 我们的Progress Bar将包含 2 个元件 – bar skin(你马上会看到)和 track skin (可拖动的); 关联这两个图像, 然后创建一个新的元件, 命名为 percentBar.

拖动的时候, 你想在某处展示进度并使用该值去滚动或者做些别的事情. 为了达到目的,我们需要创建一个 info box, 用来展示百分比.首先,你得在舞台上创建一个实例名为boxInfo的元件, 再在该元件里面添加一个动态文本,并命名为 txt.

DraggableProgressBar.as

创建一个名为DraggableProgressBar.as的文件, 把progress bar里的元件全部声明为公有变量:

public var trackSkin:MovieClip;
public var barSkin:MovieClip;
public var percent:int = 0;

当trackskin被拖动的时候,percent变量将发生变化.初始函数里面我们做了如下事情:

  • 设置progressbar为buttonMode;
  • 设置 trackSkin的宽度为 0;
  • 侦听鼠标的 DOWN 和 UP事件;
private function init(e:Event = null):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            trackSkin.width = 0;
            buttonMode = true;
            mouseChildren = false;

            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            addEventListener(MouseEvent.MOUSE_OUT, onMouseUp);
        }
当鼠标按下的时候,我们添加了一个enterframe的侦听器,因此在拖动的时候,
我们可以根据鼠标的x坐标知道trackSkin的大小为多少,当鼠标弹起的时候,移除侦听。
private function onMouseDown(e:MouseEvent):void
{
    addEventListener(Event.ENTER_FRAME, stateBar);
}

private function onMouseUp(e:MouseEvent):void
{
    removeEventListener(Event.ENTER_FRAME, stateBar);
}

让我们看看stateBar函数长啥样:

trackSkin.width = Math.min(mouseX, barSkin.width);
percent = (trackSkin.width / barSkin.width) * 100;
dispatchEvent(new Event(Event.COMPLETE));

第一行根据mouseX增加或者减少trackSkin的宽度, 不会超过最大值; 第2行计算百分比; 第三行向主类发送一个事件,通知主类百分比发生变化了。

Main Class

创建主类Main.as:

package {
import flash.events.Event;
import flash.display.MovieClip;
public class Main extends MovieClip {
public var boxInfo:MovieClip;
public var progressBar:DragBar;
public function Main() {
boxInfo.x=progressBar.x;
boxInfo.txt.text=progressBar.percent;
progressBar.addEventListener(Event.COMPLETE, getValue);
}
private function getValue(e:Event) {
boxInfo.txt.text=progressBar.percent;
boxInfo.x=Math.max(mouseX,Math.min(progressBar.x,progressBar.width));
}
}
}

保存,搞定!