Animation based on ImageClip : Image Clip « Ajax Layer « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » Ajax Layer » Image Clip 
Animation based on ImageClip


http://dynapi.sourceforge.net/
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
<html>
<head>
<title>DynAPI Examples - ImageClip</title>
<script language="Javascript" src="./dynapisrc/dynapi.js"></script>
<script language="Javascript">
  dynapi.library.setPath('./dynapisrc/')
  dynapi.library.include('dynapi.api')
  dynapi.library.include('dynapi.fx.MotionX')
  dynapi.library.include('dynapi.fx.TimerX');
  dynapi.library.include('ImageClip');
</script>
<script language="Javascript">

  var img1 = dynapi.functions.getImage('./dynapiexamples/images/penguin_red.gif');
  var img2 = dynapi.functions.getImage('./dynapiexamples/images/penguin_blue.gif');

  vp=new DynLayer(null,10,65,500,300,'#FFFFFF');
  vp._overflow = 'hidden';

  redpenguin= new ImageClip({x:100,y:100,w:64,h:64,clipImage:img1,cols:11,rows:2,speed:150});
  bluepenguin= new ImageClip({x:400,y:200,w:64,h:64,clipImage:img2,cols:11,rows:2,speed:150});

  tree=new DynLayer(null,150,60,207,214)
  tree.setHTML('<img src="./dynapiexamples/images/tree.gif">')

  evn= {
    ontimer : function(e){
      // timer event
      var me,xx=0,yy=0;
      me=e.getSource();
      xx=Math.random()*430;
      yy=Math.random()*200;

      me.lpengx=me.x;
      me.lpengy=me.y;
      me.pengx=xx;
      me.pengy=yy;
      me.slideTo(xx,yy,null,50);
    },
    onmove : function(e){
      var me=e.getSource();
      var fn=0,col=0

      if (me.pengx<=me.x) {col=0}else{col=2}
      fn=me.fm
      if (fn==1){fn=2}else{fn=1}
      me.setFrame(fn+col);
      me.fm=fn

      if (me.pengx==me.x && me.pengy==me.y) {
        if (Math.floor(Math.random()*10)==5) {
          me.playAnimation(false,'17>18,17<18,17>18,22')
        }else if (Math.floor(Math.random()*10)==3) {
          me.playAnimation(false,'21>22,21<22,21>22')
        }else {
          me.setFrame(22)
        }
      }
    }
  }

  redpenguin.addEventListener(evn);
  bluepenguin.addEventListener(evn);
  redpenguin.startTimer(2000);
  bluepenguin.startTimer(1500);

  vp.addChild(redpenguin);
  vp.addChild(bluepenguin);
  vp.addChild(tree);

  dynapi.document.addChild(vp);

</script>
</head>
<body>
<p><font face="Arial" size="4">ImageClip Widget</font></p>
<script>
  dynapi.document.insertAllChildren();
</script>
</body>
</html>

           
       
dynapi.zip( 791 k)
Related examples in the same category
1.Image Clip and animation
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.