Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-16
5
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

610 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