Solved

Load a gif to run then after it has ran 2x load default image

Posted on 2013-05-16
5
245 Views
Last Modified: 2013-05-20
I would like to run a homerun gif file 2x then load LayoutField.png back

it's like if("HR" == $(d.find('Batter')).attr("Action") imgDiamond = 'homerun.gif';
if ($(d.find('Batter')).attr("Action") === "HR") { 
                //  clearInterval(myVar); //stop refreshing the page every two seconds
               //   imgDiamond.src = 'homerun.gif';
                ///  var t = setTimeout(function(){ //imgDiamond.src = 'LayoutField.png'; myVar = //setInterval(loadData, 2000); }, 5000); 

Open in new window


Attached is a xml file with homerun set in xml AND HOMERUN.GIF AND LAYOUTFIELD.PNG
Diamond3.htm
Homerun.gif
LayoutField.png
38086.xml
0
Comment
Question by:powerztom
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 39174108
if ($(d.find('Batter')).attr("Action") === "HR") {
  imgDiamond.src = 'homerun.gif';
  var t = setTimeout(
     function() {
       imgDiamond.src = 'homerun.gif';    
       var u = setTimeout(function() {
           imgDiamond.src = 'LayoutField.png';    
        },1000);
    },1000);
}

or use jQuery QUEUE
0
 

Author Comment

by:powerztom
ID: 39174923
I made a simple web page with baseball diamond and Homerun.gif doesn't display I set xml to action ="HR" Am I missing somethingattached are necessary files for simple page page

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
.topcell {  text-align: center;
  vertical-align: top;
}
</style>
</head>
<script type="text/javascript">
$.ajax({
                    type: "GET",
                    url: "38086.xml", // xmlPath+"/"+xmlGameID+".xml",
                    dataType: "xml",
                    success: function(data){
                        var d = $(data);
                        
						if ($(d.find('Batter')).attr("Action") === "HR") { 
  imgDiamond.src = 'homerun.gif';
  var t = setTimeout(
     function() { 
       imgDiamond.src = 'homerun.gif';     
       var u = setTimeout(function() { 
           imgDiamond.src = 'LayoutField.png';     
        },5000);
    },5000);
						
						 }
                    }
                });
 
            
			
            error: function() {
                    //counterXml = -1;
            }
        
    

</script>
<body>
<span class="topcell"><img src="LayoutField.png" alt="" name="imgDiamond" width="186" height="162" id="imgDiamond"></span>
</body>
</html>

Open in new window

LayoutField.png
Homerun.gif
Test.html
38086.xml
0
 

Author Closing Comment

by:powerztom
ID: 39176119
Works except it doesn't go back to default image it runs homerun.gif back stays on that file
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39176635
I would expect code like this

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
.topcell {  text-align: center;
  vertical-align: top;
}
</style>
</head>
<script type="text/javascript">
$(function() {
   $.ajax({
     type: "GET",
     url: "38086.xml", // xmlPath+"/"+xmlGameID+".xml",
     dataType: "xml",
     success: function(data){
       var d = $(data);
       if ($(d.find('Batter')).attr("Action") === "HR") { 
         $("#imgDiamond").attr("src","homerun.gif");
         var t = setTimeout(
           function() { 
             $("#imgDiamond").attr("src","homerun.gif");
             var u = setTimeout(function() { 
               $("#imgDiamond").attr("src","LayoutField.png");     
             },5000);
          },5000);
			 }
    },
    error: function() {
      //counterXml = -1;
    }
  });
});
</script>
<body>
<span class="topcell"><img src="LayoutField.png" alt="" name="imgDiamond" width="186" height="162" id="imgDiamond"></span>
</body>
</html>

Open in new window

0
 

Author Comment

by:powerztom
ID: 39181126
Thanks Bro I'll try it.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now