469,602 Members | 1,725 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Using WZ JsGraphics with Mootools

Greetings to all coders.

I am new to js and my development is based on using frameworks such as Mootools and libraries such as Wz_jsgraphics. Recently working on my school project I have met with a problem of calling my function to draw something:

Expand|Select|Wrap|Line Numbers
  1. var jg = new jsGraphics();
  2. function drawArrow()
  3. {
  4.   jg.setColor("#ff0000"); // red
  5.   jg.drawLine(10, 113, 220, 55); 
  6.   jg.setColor("#0000ff"); // blue
  7.   jg.fillRect(110, 120, 30, 60);
  8.   jg.paint();
  9. }
from within Mootools block window.addEvent('domready', function() { .....

Does anyone has any suggestions pls ?
I know that jg.paint(); is the problem. Everytime the I call the function from within the mootools block the page freezes.
I have also tried everything that came up my mind such as calling it through other functions and stuff.

Dec 6 '07 #1
3 3898
16,027 Expert Mod 8TB
Welcome to TSDN!

Have you tried calling it without using mootools?
Dec 7 '07 #2
Yes it works really fine the only problem is calling it within mootools.
Dec 8 '07 #3
Maybe jg.paint() changes the DOM which then causes another call to the domready, resulting in an infinite loop.

Try replacing jg.paint() with this line:

Expand|Select|Wrap|Line Numbers
  1. if ( confirm( 'Continue?' ) ) jg.paint();
Now you need to confirm the paint() before it is called, so you can see if it is called again and again. Just cancel the 'Continue?' when it is called more than once.
Dec 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Seth Illgard | last post: by
4 posts views Thread by noagbodjivictor | last post: by
1 post views Thread by Piotr Kaleta | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.