110 users online (0 members and 110 guests)  

  Results 1 to 2 of 2


  1. CSS 3.0 animation features    Forum: CSS Forum
    Replies: 0
  2. basic animation    Forum: Javascript Forum
    Replies: 1
  3. HELP!Animation with perl    Forum: CGI Perl Forum
    Replies: 2
  4. problems with animation    Forum: Graphics Forum
    Replies: 1
  1. #1
    dawkim's Avatar
    New User

    Join Date
    Jan 2004

    Angry Animation problem

    I cannot seem to load the images needed for an animation of some gif images. Here is the code:

    <TITLE>Animated Helicopter</TITLE>
    <SCRIPT LANGUAGE="JavaScript">

    anims = new Array(35);
    var frame = 0;
    var timeout_state = null;

    function imageLoad() {
    for(var i = 0; i<35; i++) {
    anims[i] = new Image();
    anims[i].src = "anim" + i + ".gif";

    function animator() {
    document.animImage.src = anims[frame].src;
    frame = (frame + 1);
    if(frame >= 35) {
    frame = 0;
    timeout_state = setTimeout("animator()", document.animForm.Speed_Setting.value);

    function buttonCheck() {
    if(document.animForm.animButton.value == "Start") {
    document.animForm.animButton.value = "Stop";
    } else {
    document.animForm.animButton.value = "Start";
    timeout_state = null;
    function anim_findObj(n, d) {
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=anim_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    function anim_validateForm() {
    var i,p,q,nm,test,num,min,max,errors='',args=anim_vali
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=anim_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
    if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R') { num = parseFloat(val);
    if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
    if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
    min=test.substring(8,p); max=test.substring(p+1);
    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.anim_returnValue = (errors == '');

    <BODY onLoad="imageLoad()" BGCOLOR="#FFFF33">
    <P><img src="http://protectplus.net/images/anim0.gif" width="1133" height="219" name="animImage">
    <FORM NAME="animForm">
    <div align="center"><font color="#FF6600"><b><font size="6">Flying Helicopter
    Animation</font></b></font> </div>
    <p align="center"> </p>
    <p> </p>
    <li><font size="5">Click Start to start the helicopter in motion.</font></li>
    <li><font size="5">Click Stop to stop the helicopter.</font></li>
    <p align="center">
    <INPUT TYPE=button VALUE=Start NAME="animButton" onClick=buttonCheck()>
    <INPUT NAME="Speed_Setting" TYPE=text id="Speed_Setting" onBlur=" anim_validateForm('Speed_Setting','','RinRange25:4
    00');return document.anim_returnValue" VALUE=175>
    Speed Setting </p>
    <p align="center"><font color="#009900" size="5">Adjust the speed by changing
    the number in the Speed Setting box.</font></p>
    <p align="center"><font color="#009900" size="5">The lower the number the faster
    the helicopter flies.</font></p>
    <p align="center"><font color="#000000" size="4">(Numbers must be between 25 and 400)</font></p>
    <p align="center">
    document.animForm.animButton.value = "Start";
    document.animForm.Speed_Setting.value = 175;

    <p align="center"> </p>

    The gif images are residing in images directory in public_html.
    The page is at http://www.protectplus.net/Lab5.html
    I have a function imageLoad() to preload the images but it doesn't seem to work.
    Anyone have an idea that would help?

  2. #2
    QuietDean's Avatar

    Join Date
    Oct 2000
    Bournemouth, UK
    Just while glancing at your code, are your images all named anim1.gif, anim2.gif etc? thats the way the script is calling them.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

Tags for this Thread