Instead of doing while(currentX<500), you have to make your code do a callback using something like window.setInterval() or window.setTimeout(). There's a good generic Javascript animation tutorial at http://www.schillmania.com/content/projects/javascript-animation-1/ .
His examples use DHTML instead of SVG, but for scripted animation the concepts are the same. --- In [email protected], Diego Gibellino <[EMAIL PROTECTED]> wrote: > > Thank you for your answer, I tried with Adobe SVG and FireFox the following > (I will insert the script version only) > > <script type="text/ecmascript"> > <![CDATA[ > // global variables here > var clickCount = 0.; > var currentX = 0.; > var currentY = 0.; > var currentW = 0.; > var currentH = 0.; > var MyRect = null; > function resizeLocal(evt) > { > MyRect = evt.target > clickCount++; > //if (clickCount==1) > //{ > currentX=parseInt(MyRect.getAttribute("x"),10); > currentY=parseInt(MyRect.getAttribute("y"),10); > currentW=parseInt(MyRect.getAttribute("width"),10); > currentH=parseInt(MyRect.getAttribute("height"),10); > //} > if(clickCount%2==0) > { > while(currentX<500) > { > currentX=currentX+2.0; > currentY=currentY+1.0; > currentW=currentW-2.0; > currentH=currentH-1.0; > MyRect.setAttribute("x",currentX); > MyRect.setAttribute("y",currentY); > MyRect.setAttribute("width",currentW); > MyRect.setAttribute("height",currentH); > } > } > else > { > while(currentX>1) > { > currentX=currentX-2.0; > currentY=currentY-1.0; > currentW=currentW+2.0; > currentH=currentH+1.0; > MyRect.setAttribute("x",currentX); > MyRect.setAttribute("y",currentY); > > MyRect.setAttribute("width",currentW); > MyRect.setAttribute("height",currentH); > } > } > } > > And I declared my shape like this: > > <rect onclick="resizeLocal(evt)" x="500" y="250" width="500" height="250" > fill="red" stroke="red"/> > > This works fine but how can I show the animation to the user (the rect > enlarging/reducing width and height) ? > > Using animation it is actually simpler enlarging or reducing the rect size > but how may I altrernate this behavior at each user click? > > > 2006/2/17, Robert Russell <[EMAIL PROTECTED]>: > > > > Do you have any examples of what you tried that didn't work? Which > > platform (Batik, Firefox, Opera, Adobe, ...) did you try it on? > > > > If you want to do it declaratively (in SMIL, the way the spec shows > > it) then it's a totally different approach than you'd take from doing > > it procedurally (in Javascript or another language). > > > > > > --- In [email protected], "ilgibe" <d.gibellino@> wrote: > > > > > > Hi, > > > I would like to resize with an animation a rect from 50x50 to 200x200 > > > (for i.e.) when it is clicked. Then when the rect reaches the new > > > dimension a new click resizes it again to the previous width and > > > height and so on (enlarging and reducing). > > > I tried with animation (but I was not able to implement the two > > > different behaviors) and with script (but I was not able to show the > > > animation of the rect that changes width and height). > > > > > > May you help me please? > > > > > > Thank you and Best Regards, > > > > > > Diego > > > > > > > > > > > > > > > > > ----- > > To unsubscribe send a message to: > > [EMAIL PROTECTED] > > -or- > > visit http://groups.yahoo.com/group/svg-developers and click "edit my > > membership" > > ---- > > > > > > > > SPONSORED LINKS > > Xml format<http://groups.yahoo.com/gads?t=ms&k=Xml+format&w1=Xml+format&w2=Svg&w3=Format&w4=Data&c=4&s=47&.sig=VBa7nBOoFldLj1xsnDMzkQ> > > Svg<http://groups.yahoo.com/gads?t=ms&k=Svg&w1=Xml+format&w2=Svg&w3=Format&w4=Data&c=4&s=47&.sig=a1u0zJydFxGsmrBvlURQ4w> > > Format<http://groups.yahoo.com/gads?t=ms&k=Format&w1=Xml+format&w2=Svg&w3=Format&w4=Data&c=4&s=47&.sig=sfOdgu_KzJjmF4YOGYLFuw> > > Data<http://groups.yahoo.com/gads?t=ms&k=Data&w1=Xml+format&w2=Svg&w3=Format&w4=Data&c=4&s=47&.sig=aV25K06F7rKa6A2bKQrzpA> > > ------------------------------ > > YAHOO! GROUPS LINKS > > > > > > - Visit your group "svg-developers<http://groups.yahoo.com/group/svg-developers>" > > on the web. > > > > - To unsubscribe from this group, send an email to: > > [EMAIL PROTECTED]<[EMAIL PROTECTED]> > > > > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of > > Service <http://docs.yahoo.com/info/terms/>. > > > > > > ------------------------------ > > > > > [Non-text portions of this message have been removed] > ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

