用Javascript做flash做的事..才完成的一个类.Auntion Action var 0.1_javascript技巧

请注意example2.html 在firefox下效果没有在ie下圆润,其原因来源于兼容性.

以及触发动作过快会导致每一个li递增两次到三次的情况,这个原因跟类(Action.js)本身无关.原因来源于example2.html中的演示代码.
目前正在极力修改中.
咨询改版升级信息请关注 我的blog
http://auntion.blogbus.com
或者加我QQ询问:82874972
action.js

复制代码 代码如下:

/*
*

效果类

By Auntion

QQ:82874972

Blog:Auntion@blogbus.com

Email:Auntion@Gmail.com

版权没有,随便使用.

使用时请勿删除此部分注释.谢谢!

*
*/

ShowHide = Class.create();ShowHide.prototype = {status: expRs={},initialize: function(ob,endW,endH,effect,step){this.element=(typeof(ob)=='object') ? ob : $id(ob);if(expRs[ob.id]==null){ expRs[ob.id] = true; }if(expRs[ob.id]){this.width=this.element.offsetWidth;this.height=this.element.offsetHeight;this.endW=(endW != null)?endW.isZero():null;this.endH=(endH != null) ? endH.isZero():null;this.effect=(effect!=null)?effect:0;this.step=(step!=null)?step:0.075;this.now=[0,0];this.tryBug=this.step;this.method,this.goTo;expRs[this.element.id]=false;this.start();}},start: function(){switch(this.effect){case 0:{var method = this.judgment();this.base(method);}break;case 1:{var method = this.judgment();this.alpha(method);}break;default:{alert("错误: 不是一个可用的效果! 应为0和1,默认执行0");var method = this.judgment();this.base(method);}}},base: function(method){this.element.style.overflow = "hidden";this.goTo = this.create(method);},alpha: function(method,step,Opacity){alert("未完成的效果,自动用默认效果替代.");this.goTo = this.base(method);},allIs: function(){this.now[0] += this.expressions(0,this.endW,this.now[0],this.step);this.now[1] += this.expressions(0,this.endH,this.now[1],this.step);if((this.width > this.endW) ? (this.now[0] > (this.endW+this.tryBug)) : (this.now[0] < (this.endW-this.tryBug))){this.element.style.width = this.now[0]+"px";}if((this.height > this.endH)? (this.now[1] > (this.endH+this.tryBug)) : (this.now[1] < (this.endH-this.tryBug))){this.element.style.height= this.now[1]+"px";}else{clearInterval(this.goTo);this.element.style.width = (this.now[0]+this.tryBug)+"px";this.element.style.height= (this.now[1]+this.tryBug)+"px";expRs[this.element.id] = true;}},widthIs: function(){this.now += this.expressions(0,this.endW,this.now,this.step);if((this.width > this.endW) ? (this.now > (this.endW+this.tryBug)) : (this.now < (this.endW-this.tryBug))){this.element.style.width = this.now+"px";}else{clearInterval(this.goTo);this.element.style.width = (this.now+this.tryBug)+"px";expRs[this.element.id] = true;}},heightIs: function(){this.now += this.expressions(0,this.endH,this.now,this.step);if((this.height > this.endH) ? (this.now > (this.endH+this.tryBug)) : (this.now < (this.endH-this.tryBug))){this.element.style.height = this.now+"px";}else{clearInterval(this.goTo);this.element.style.height = (this.now+this.tryBug)+"px";expRs[this.element.id] = true;}},judgment: function(){if(this.endW != null && this.endH !=null){this.method = "all";this.now = [this.width,this.height];}else if(this.endW != null && this.endH == null){this.method = "width";this.now = this.width;}else if(this.endW == null && this.endH != null){this.method = "height";this.now = this.height;    }return this.method;},create: function(codeString){var ShowHideGoTo;switch(codeString){case "all" : ShowHideGoTo = setInterval(function(){this.allIs();}.bind(this),1);break;    case "width" : ShowHideGoTo = setInterval(function(){this.widthIs();}.bind(this),1);break;case "height": ShowHideGoTo = setInterval(function(){this.heightIs();}.bind(this),1);break;}return ShowHideGoTo;},expressions: function(num,end,now,step){var exec;switch(num){    case 0 : exec = (end - now)*step;break;            default : exec = (end - now)*step;break;}return exec;}};

language.js

复制代码 代码如下:

/*
*
语言扩展包

By Auntion

QQ:82874972

Blog:Auntion@blogbus.com

Email:Auntion@Gmail.com

版权没有,随便使用.

使用时请勿删除此部分注释.谢谢!

*
*/

var Class={create: function() {return function() {this.initialize.apply(this, arguments);}}};$id = function(i){return document.getElementById(i);};$name = function(i){return document.getElementsByName(i);};$class = function(className,baseId) {var fatherId = null;if(!baseId){fatherId = document;}else{var id = baseId;fatherId = $id(id);}var basic = fatherId.getElementsByTagName('*') || document.all;var child = null;var classNames = null;var aggregate = []; for (var i = 0; i < basic.length; i++) {child = basic[i];classNames = child.className.split(' ');for (var j = 0; j < classNames.length; j++) {if (classNames[j] == className) {aggregate.push(child);break;}}}return aggregate;};String.prototype.toInt = function(){return parseInt(this.replace(/[a-zA-Z]+/,''));};Number.prototype.isZero = function(){return (this < 0) ? 0 : this;};Function.prototype.bind = function(e) {var md = this;return function(){return md.apply(e,arguments);}};Object.prototype.attachEvent=function(method,func){if(!this[method]) this[method]=func;else this[method]=this[method].attach(func);};Function.prototype.attach=function(func){var f=this;return function(){f();func();}};

example.html

复制代码 代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>example1</title>
<script src="Language.js" language="javascript"></script>
<script src="Action.js" language="javascript"></script>
<style type="text/css">

*,body{
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
}

#main {
    margin:50px;
    padding:0px 0px 20px 0px;
    border:solid 1px #cccccc
}

#button {
    color:#0099FF;
}

#button li{
    margin-right:10px;
    padding:5px 0 0 0;
    width:104px;
    height:22px;
    border: solid 1px #cccccc;
    background-color: #eeeeee;
    float:left;
    text-align:center;
}

#demo{
    margin-top:20px;
    background-color:#CCCCCC;
    color:#f5f5f5;
    float:inherit;
    /*border:solid 1px #aaaaaa;*/
}

</style>
</head>
<body>

    <table border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
    <div id="button">
        <ul>
            <li id="a">恢复初始值</li>
            <li id="b">隐藏</li>
            <li id="c">宽 + 30</li>
            <li id="d">高 + 30</li>
            <li id="e">宽 - 30</li>
            <li id="f">高 - 30</li>
            <li id="i">宽600,高100</li>
        </ul>

    </div>
            </td>
          </tr>
</table>

    <table border="0" align="center" cellpadding="0" cellspacing="0">
      <tr><td align="center" valign="middle">
        <div id="demo" style="height:200px;width:200px;"></div>
  </td></tr></table>

<script language="javascript" type="text/javascript">
var element = $id("demo");

var width = element.offsetWidth;
var height= element.offsetHeight;

alert(width)

var step = 0.115

function now(){
    this.nowWidth = element.style.width.toInt();
    this.nowHeight= element.style.height.toInt();
}

    $id("a").onmousedown = function(){

        new ShowHide(element,width,height,0,step);

    }

    $id("b").onmousedown = function(){

        new ShowHide(element,0,0,0,step);

    }

    $id("c").onmousedown = function(){

        var test = new now();
        new ShowHide(element,test.nowWidth+30,null,0,step);

    }

    $id("d").onmousedown = function(){

        var test = new now();
        new ShowHide(element,null,test.nowHeight+30,0,step);

    }

    $id("e").onmousedown = function(){

        var test = new now();
        new ShowHide(element,test.nowWidth-30,null,0,step);

    }

    $id("f").onmousedown = function(){

        var test = new now();
        new ShowHide(element,null,test.nowHeight-30,0,step);

    }

    $id("i").onmousedown = function(){

        new ShowHide(element,600,100,0,step)

    }
</script>
</body>
</html>

时间: 2024-07-31 20:15:43

用Javascript做flash做的事..才完成的一个类.Auntion Action var 0.1_javascript技巧的相关文章

详解JavaScript对Date对象的操作问题(生成一个倒数7天的数组)_javascript技巧

问题描述: 使用JavaScript生成一个倒数7天的数组. 比如今天是10月1号,生成的数组是["9月25号","9月26号","9月27号","9月28号","9月29号","9月30号","10月1号"]. 这个难点就是需要判断这个月份(可能还需要上一个月份)是30天还是31天,而且还有瑞年的2月28天或者29天. 解答思路: 不需要那么复杂,在js中非常简单,

用Flash做电子地图实例讲解

关于flash,大家或多或少都有所了解.比如上网,到处都能看到flash的存在.flash的应用也是五花八门.今天我们讲的是用flash做电子地图. 现在在网上随处都能找到电子地图,其中大部分都是java来开发的,其实用flash也可以做电子地图.且界面还比较漂亮.现在网上已经有用flash做的电子地图了.且呈发展趋势.象"中国电子地图网"里面的地图就是用flash做的.还有九江,五邑等地图也都是用flash来完成的. 现在我们就来学习用flash做电子地图,首先要了解电子地图的功能,

安装完Ubuntu14.10后要做的7件事

安装完Ubuntu14.10后要做的7件事 1.看看有哪些新东西 虽然Ubuntu 14.10并没有带来特别重大的新功能,但是依然有值得期待的地方,Mozilla Firefox, Thunderbird,LibreOffice都升级到了新的版本,或许你可以看下他们与之前的版本有什么不同. 2.自定义你的桌面 每一个新版本的Ubuntu发布都会带来新的壁纸,你可以试下这些新的壁纸,并将自己喜欢的设置为桌面.也可以根据自己的喜好设置窗口菜单的位置,是否隐藏unity边栏,开机是否自动登录等等. 3

安装Linux Mint 17后要做的20件事

安装Linux Mint 17后要做的20件事 Linux Mint 17 Qiana Cinnamon Linux Mint 17已经发布,定名为Qiana.Mint是Linux最佳发行版之一,它定位于桌面用户,关注可用性和简洁.它携带了风格迥异的桌面环境,如Mate以及Cinnamon,并基于不同的发行版,如Ubuntu或Debian. 在本文中,我们使用的是Linux Mint 17的cinnamon版本.要获取更多关于Cinnamon版本的信息(包括下载链接),可以访问 - http:/

马云对话创业者:我不喜欢人工智能,机器应做人类做不到的事

3月23日下午,阿里巴巴董事局主席马云受邀在马来西亚环球转型论坛(GTF)演讲,与近3000名来自20多个国家的创业者和年轻人交流. 马云说:"我们无法选择出生在怎样的家庭,如果你碰巧出生在比尔?盖茨家族,你很幸运.当然这不可能.但我们可以决定我们死在何处.以何种方式死亡.如果你想死在监狱里,很简单.如果你想去世时有很多朋友,你必须交到很多朋友,你必须改变你的性格.价值观." 博尔特要马云和他来张自拍. 图片来源:博尔特Twitter 曾是英语教师的马云很擅长给年轻人忠告,马云自称&q

注意!PHP 7中不要做的10件事_php实例

切记,在PHP 7中不要做的10件事 1. 不要使用 mysql_ 函数  这一天终于来了,从此你不仅仅"不应该"使用mysql_函数.PHP 7 已经把它们从核心中全部移除了,也就是说你需要迁移到好得多的mysqli_函数,或者更灵活的 PDO 实现.   2. 不要编写垃圾代码  这一条可能易于理解,但是会变得越来越重要,因为 PHP 7 的速度提升可能会隐藏你的一些问题.不要仅仅满足于你的站点速度,因为迁移到 PHP 7 才让它变快.  为了理解速度有多重要,以及如何把事情做得更

注意!PHP 7中不要做的10件事

切记,在PHP 7中不要做的10件事 1. 不要使用 mysql_ 函数 这一天终于来了,从此你不仅仅"不应该"使用mysql_函数.PHP 7 已经把它们从核心中全部移除了,也就是说你需要迁移到好得多的mysqli_函数,或者更灵活的 PDO 实现. 2. 不要编写垃圾代码 这一条可能易于理解,但是会变得越来越重要,因为 PHP 7 的速度提升可能会隐藏你的一些问题.不要仅仅满足于你的站点速度,因为迁移到 PHP 7 才让它变快. 为了理解速度有多重要,以及如何把事情做得更好,请看一

Ubuntu 11.04 安装后要做的20件事

4.28日,Ubuntu 11.04 就发布了!本文将向你介绍Ubuntu 11.04 安装后快速配置需要做的20件事.  1.不喜欢Unity? 切换到Ubuntu gnome 经典桌面!  注销unity桌面环境,然后选择登录环境为"经典桌面"即可进入. 若是你喜欢Unity,可是你的显卡不给力3D不支持,怎么办呢?安装Unity-2D:  引用 sudo apt-add-ppa repository: unity-2d-team/unity-2d-daily sudo apt-g

bbqi教你做Flash动画:头,正面说话,大笑

flash动画 头部动画是我们最常遇到的课题,这里包括各种表情.讲话等等.一般来讲,头部都是作为单独一个s来运用的,即:做出整个影片中需要的所有头部,再和另外制作的身体联结.组合成完整的身体.可以说,头部的组合集中体现了Flash动画充分利用symbol的特色. 我们分析,在脸部的五官中,耳朵和鼻子是不动的.因此我们可以把它和"光秃的头部"连在一起制作.先建立一个3帧的s,根据造型原则,是一个蛋形,带有耳朵和鼻子,命名为"head_00",见图5.1.1-1. 图5