Skip to main content

Microsoft Silverlight

Unanswered Question bug with increasing the size of imageRSS Feed

(0)

brightstar
brightstar

Member

Member

406 points

185 Posts

bug with increasing the size of image

Hello every body!

I have the two next listings:

This example DOESN'T WORK!

1    <script>
2    
3    function oleg()
4    {
5    	var a = document;
6    	
7    	var b = a.pic1.width;
8    	
9    	if( b == 200 )
10   	{
11   		a.pic1.width = b + 20;
12   		setTimeout("oleg();", 5);
13   		
14   		if(b == 500)
15   		{
16   			a.pic1.width = b;
17   		}
18   	}
19   }
20   
21   </script>
22   
23   <img src ="./1.jpg" width ="200" name ="pic1" onMouseOver ="oleg();">
 

And, if I shall change in line:9 from "if( b == 200 )" to "if( b > 0 )"
the effect will work!

I want to know, why it doesn't work?

I set at <img> the value of width: 200px.

And in the script logic, I check if ( b == 200) and you can see that the variable `b` equals 200 at <img> indeed.

Why the version with b = 200 doesn't work and if I change it to b < 0 , the effect will work?

Can somebody help me?

 

Best Regards,

Oleg

 

mokarom
mokarom

Member

Member

123 points

23 Posts

Re: bug with increasing the size of image

 I'm not sure why its not working with you. I copied your code and its working fine with me.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script>

        function oleg() {
            var a = document;

            var b = a.pic1.width;

            if (b == 200) {
                a.pic1.width = b + 20;
                setTimeout("oleg();", 5);

                if (b == 500) {
                    a.pic1.width = b;
                }
            }
        }
   
    </script>

</head>
<body>
    <img src="score.bmp" width="200px" name="pic1" onmouseover="oleg();" />
</body>
</html>

If I put if(b == 200), it increases the img width once to 220 and in the next run it stops increasing the width as it finds b=220. If you wanna let the image width grow as long as the mouse is over the image and until it is 500, try putting if(b>=200) instead.

Hope this helps.

 

 

 

mokarom

"if this post answers your question, please mark it as answer."

sl.ayer
sl.ayer

Participant

Participant

856 points

166 Posts

Re: bug with increasing the size of image

How is this Silverlight related?

brightstar
brightstar

Member

Member

406 points

185 Posts

Re: bug with increasing the size of image

I'm training to support Moonlight Smile, the part of Silverlight, but on GNU\Linux.
Becuase Moonlight works fine only with 1st version of Silverlight, which was XAML + JavaScript.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities