By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,349 Members | 1,307 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,349 IT Pros & Developers. It's quick & easy.

Using WZ JsGraphics with Mootools

P: 2
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. }
  10.  
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.

PLS HELP ME :)
Dec 6 '07 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Have you tried calling it without using mootools?
Dec 7 '07 #2

P: 2
Yes it works really fine the only problem is calling it within mootools.
Dec 8 '07 #3

truefontfamily
P: 4
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.