SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: xLibrary help

  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xLibrary help

    I'm trying to get started with cross-brower.com's xLibrary... I've read all the Get Started files and have looked at the source code for the demos, but I don't know how to actually inset the script into my webpage.

    Well, that's not total true... I have copied and pasted the code from the source code sections along with all their dependancies onto an internal script (e.g <script='javascript' type=... > ) and I've reset the CSS for the objects (due to the demo using an external CSS that I can't find in the download)
    and I've got the demo to work on my webpage... but, as soon as I try to put the code into an external .js file, the code doesn't work.
    This is because I can't seem to reference the external js functions with the internal window.onload = function() ...

    I've been trying to solve my problem for a week now and I'm not sure which path to take ... I'm currently trying to do a new window.onload function that var xAnim1 = getElementById('dc1') for each of the 3 divs and then pass the new variables to the old window.onload (which is now in the external file and calls for "new xAnimation(xAnim)" ) which would hopefully run the animation... I haven't finished it because my javascript knowledge is in its fledgling years.

    But, I can't imagine that this is what Michael Foster had intended... what should I do to put the script into an external file and then call the function?

    Ohhh... by th way, I'm trying to use the xAnimation's xOpacity with xResize aka xAniSize functions)...

    I really want this to work because Michael Foster's work at cross-browser.com is superb.

    Thank you in advance to anyone who replies.

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Hughman, welcome to SPF, and thanks very much for the kind comments! I'm headed out to my daughter's basketball game right now but when I get back I'll address your question asap

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thank, much appreciated

    Just wanted to say thank you for the speedy reply...
    I hope your daughter plays well and her team comes out on top.
    Hugh Proctor

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Hugh,

    I should have mentioned earlier for you to provide a link to your page. After reading your post there's really not much I can say until I see your code.

    Btw, our team lost, but my daughter played really well

  5. #5
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mike,
    ummm... thats going to be difficult because the site is not on the web yet and it's in asp with a master page and custom controls. I run it off Visual Studio's inbuilt server emulator.
    but what I've done is to download you xLibrary package... on the Library Viewer goto xAniSize and view the pages source code.

    I have to say, I don't fully understand how to implement your libraries onto my web page. The structure is very understandable and I understand your code (more or less)...

    This is taken from xAniSize source code

    <script type="text/javascript" src="../x_core.js"></script>
    <script type="text/javascript" src="../x_dom.js"></script>
    <script type="text/javascript" src="../x_event.js"></script>
    <script type="text/javascript" src="../lib/xopacity.js"></script>
    <script type="text/javascript" src="../x_animation.js"></script>

    <script type="text/javascript" src="../lib/xgetcssrules.js"></script>

    <script type='text/javascript'>
    window.onload = function()
    {
    new xAnimation('de1');
    new xAnimation('de1');
    new xAnimation('de2');
    new xAnimation('de2');
    startDemos();
    initBtns();
    xAddEventListener(window, 'resize', winOnResize, false);
    }
    window.onunload = function()
    {
    xGetElementById('btnK').onclick();
    }
    function winOnResize()
    {
    if (!winOnResize.tmr) {
    xMoveTo('de1', -2, -2);
    xMoveTo('de2', -2, -2);
    xResizeTo('de1', 2, 2);
    xResizeTo('de2', 2, 2);
    xGetElementById('btnP').onclick();
    winOnResize.tmr = setTimeout("startDemos();winOnResize.tmr=null;", 500);
    }
    }

    But the line 'new xAnimation('de1');' doesn't not work because it can't open the x_animation.js file to the locate the relevant functions.

    What am I doing wrong? why can I not call the function?

    I'm sorry to hear about your daughters team loosing, maybe next time... I'm running around today, have got to go to my wife's cousin's wedding which is in 3 hours!!!! and my wife has left her make-up in the car which is here at the apartment, and she's on the otherside of the city at the hair dressers...

  6. #6
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hugh,

    As a test, I unzipped the X distribution file into a temporary folder. I then copied this file and this file into the "x/examples" folder. I loaded "xanisize.html" into a browser, and it worked.

    Showing me my code is not going to help me help you. You'll have to show me your code.

    But the line 'new xAnimation('de1');' doesn't not work...
    What error message do you get?

  7. #7
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeh, I know... sorry.
    and there's definitely nothing wrong with your code...
    I am just looking in the examples file from my download... and I don't have the xanisize.html file but a link that returns to your web page, but then you know that....
    ummm...
    The error message that I get is "Line 29 ... 'xAnimation' is undefined"

  8. #8
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike, thanks for your help... I found out that I am an idiot... I was trying to link to you code with this...

    <script type='text/javascript' src='../Javascript/cross-browser.com/x/x_animation.js'></script>

    I should know better than this!!! Thank you again...

    I was thinking about what can be achieved with javascript code... I was wondering if a jigsaw could be made... in the fact that you have images with a jigsaw shape but that you move, drag and drop the pieces... which can be easily done with some of you script... but that the pieces individually can be rotated... this I know can also be done but to 90 degree angles (I don't know if you've got it in your library)...
    can pictures be rotated to other angles?
    do you think it can be done?

    I'm going to create the basic idea but without the rotation and then see what you think....

  9. #9
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One last question...

    do you what the effects are of the scripts upon web page performance? How much slow down is expected, etc?

  10. #10
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't worry about it - we all make silly mistakes sometimes I'm glad you got it going.

    I remember a couple of other people making jigsaw puzzle games - but those pages aren't there any more.

    AFAIK there is no way to rotate an image only with Javascript. It could probably be done server-side with PHP.

  11. #11
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Puzzle created - but not Jigsaw

    I have a script to create puzzles from images, but I am using squares for each piece rather than actual jigsaw pieces. It seems to me that the additional memory overhead for 500 individually rounded pieces meant to fit together properly would be tremendous.

    Check out my puzzle at http://www.unitorganizer.com/puzzles

    Also, FYI the script lets you save the position of the pieces using cookies, <s>but I can't for the life of me figure out how to get the save functionality to work properly in IE6.</s> actually wait a minute it works fine in IE6 at work, just not on the version of IE6 that I have at home...hrmmm. Must be a settings thing.

    Dave

  12. #12
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Dave, Great work!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •