Difficulties to apply JS on multi embeds

flo
07-12-2005, 12:19 AM
Hello,
I load 5 svg in 5 <embed> and a JS is called in the <body onload="()"> of my HTML page. The JS, for each <embed> (embeds[i]), change the currentScale and currentTranslate values.

The problem is that the transforms are applied for all the SVG except one, and it's never the same !!! and sometimes all the svg are changed...

JS problem ?

I've tried to set some timeout but it's not the solution.

Thanks

Hacc
07-27-2005, 10:46 AM
Hi Flo
Can you post you code?

Hello,
I load 5 svg in 5 <embed> and a JS is called in the <body onload="()"> of my HTML page. The JS, for each <embed> (embeds[i]), change the currentScale and currentTranslate values.

The problem is that the transforms are applied for all the SVG except one, and it's never the same !!! and sometimes all the svg are changed...

JS problem ?

I've tried to set some timeout but it's not the solution.

Thanks

flo
08-05-2005, 03:09 AM
function minimizeMspCard(){
var i = 0;
var cx = null;

while (i < document.embeds.length){

SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();

if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}

if (zoomer(SVGRoot,0.9)){
if (paner(SVGRoot, -cx+275 ,0))
i++;
}
}
}

function zoomer(SVGRoot, k){

var old_taille=SVGRoot.currentScale;
new_taille=old_taille*k;
SVGRoot.currentScale=new_taille;
return true;
}
function paner(SVGRoot, x, y){

SVGRoot.currentTranslate.x = x;
SVGRoot.currentTranslate.y = y;
return true;
}

Hacc
08-10-2005, 12:55 AM
Hi Flo
I can't see anything wrong with your code. The only part that is confusing to me, is the if around i++...can you explain it to me? If you aren't increasing i, the while loop won't check all the svg documents...

Regards,

function minimizeMspCard(){
var i = 0;
var cx = null;

while (i < document.embeds.length){

SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();

if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}

if (zoomer(SVGRoot,0.9)){
if (paner(SVGRoot, -cx+275 ,0))
i++;
}
}
}

function zoomer(SVGRoot, k){

var old_taille=SVGRoot.currentScale;
new_taille=old_taille*k;
SVGRoot.currentScale=new_taille;
return true;
}
function paner(SVGRoot, x, y){

SVGRoot.currentTranslate.x = x;
SVGRoot.currentTranslate.y = y;
return true;
}

flo
08-10-2005, 09:01 AM
Hi Hacc
The if around i++ were used to test some things, but i have tried with a simplier code like this :

function minimizeMspCard(){
var i = 0;
var cx = null;

while (i < document.embeds.length){

SVGDocument=document.embeds[i].getSVGDocument();
SVGRoot = SVGDocument.firstChild();

if (cx == null) {
var lastPoint = SVGRoot.getElementById("lastPoint");
cx = lastPoint.getAttribute("cx");
}

zoomer(SVGRoot,0.9);
paner(SVGRoot, -cx+275 ,0);
i++;
}
}

and it's still doesn't work...i do not know why the process is not applied to all the SVG ???

Hacc
08-11-2005, 12:17 AM
Hi Flo
Is it possible to email me all your code, so that I can test in on my side?
My email address is cahayter@yahoo.com

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum