Professional Web Applications Themes

load a .jpg into an .swf via .xml - Macromedia Flash

I've been working on this for a while now; maybe someone has an answer or better idea. Trying to load a .jpg into an .swf via .xml . There is no on press, or next, or previous buttons; there are no buttons used for this movie. the code below works so far; but only for the first childnode However i'm still trying to get it to call the individual .jpg by only the "Id" attribute in each childnode; any suggestions? thanks to all for any help. James -------------- actionscript -------------- images_xml = new XML(); images_xml.onLoad = ViewImage; images_xml.load("images.xml"); images_xml.ignoreWhite = ...

  1. #1

    Default load a .jpg into an .swf via .xml

    I've been working on this for a while now; maybe someone has an answer or better idea.
    Trying to load a .jpg into an .swf via .xml .

    There is no on press, or next, or previous buttons; there are no buttons used for this movie.

    the code below works so far; but only for the first childnode
    However i'm still trying to get it to call the individual .jpg by only the "Id" attribute in each childnode; any suggestions?

    thanks to all for any help.
    James

    --------------
    actionscript
    --------------
    images_xml = new XML();
    images_xml.onLoad = ViewImage;
    images_xml.load("images.xml");
    images_xml.ignoreWhite = true;
    function ViewImage(success) {
    if (success == true) {
    rootNode = images_xml.firstChild;
    Image = rootNode.firstChild;
    updateImage(Image);
    }
    }
    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }

    -----
    XML
    -----
    <?xml version="1.0"?>

    <Images>
    <image Id="000" jpegURL="images/image1.jpg"> </image>
    <image Id="001" jpegURL="images/image2.jpg"> </image>
    <image Id="002" jpegURL="images/image3.jpg"> </image>

    <Images>
    ROKKSTAR Guest

  2. #2

    Default Re: load a .jpg into an .swf via .xml

    Hi James,

    I wonder that your actionscript works, because the images_xml.onLoad
    handler should use
    the this keyword to reference to images_xml itself, not images_xml (as
    images_xml is not a property of images_xml)...

    I suggest you store id's and images in an array within the onLoad handler,
    and call your updateImage() function with the appropriate id whenever you
    want to update the image.
    updateImage() would take care of scrolling through that array and find the
    imagePath to the id, and then load the image.

    e.g.

    -------------- actionscript --------------
    // Array for imagePath and id
    _global.imageArray = new Array();

    // XML object
    var images_xml = new XML(); images_xml.onLoad = ViewImage;
    images_xml.load("images.xml"); images_xml.ignoreWhite = true;
    function ViewImage(success) { if (success) { var rootNode =
    this.firstChild;
    // Climb the XML tree and push the images id/path onto our array.
    for (var i=0; i < rootNode.childNodes.length; i++) {
    var currentId = rootNode.childNodes[i].attributes.Id;
    var currentImagePath = rootNode.childNodes[i].attributes.imagePath;
    _global.imageArray.push({id:currentId, imagePath:currentImagePath});
    }
    } }

    function updateImage(id) { for (var i=0; i < _global.imageArray.length;
    i++){
    if (_global.imageArray[i].id === id){
    image_area.loadMovie(_global.imageArray[i].imagePath);
    return; }
    } }

    Hope this helps, Herb


    On Wed, 2 Jul 2003 10:24:02 -0400, ROKKSTAR <jamesmail.toyboxxprod.com>
    wrote:
    > I've been working on this for a while now; maybe someone has an answer or
    > better idea. Trying to load a .jpg into an .swf via .xml .
    >
    > There is no on press, or next, or previous buttons; there are no buttons
    > used for this movie.
    >
    > the code below works so far; but only for the first childnode However i'm
    > still trying to get it to call the individual .jpg by only the "Id"
    > attribute in each childnode; any suggestions?
    >
    > thanks to all for any help. James
    >
    > -------------- actionscript -------------- images_xml = new XML();
    > images_xml.onLoad = ViewImage; images_xml.load("images.xml");
    > images_xml.ignoreWhite = true; function ViewImage(success) { if (success
    > == true) { rootNode = images_xml.firstChild; Image = rootNode.firstChild;
    > updateImage(Image); } } function updateImage(Image) { imagePath =
    > Image.attributes.jpegURL; image_area.loadMovie(imagePath); }
    >
    > ----- XML ----- <?xml version="1.0"?>
    >
    > <Images> <image Id="000" jpegURL="images/image1.jpg"> </image> <image
    > Id="001" jpegURL="images/image2.jpg"> </image> <image Id="002"
    > jpegURL="images/image3.jpg"> </image>
    >
    > <Images>
    Herb Guest

  3. #3

    Default Re: load a .jpg into an .swf via .xml

    Herb,
    Thanks for taking the time to answer my call.
    unfortunately I couldn't get your script to work.
    Being a photographer and not a "real" coder I can't make heads or tales of
    where to put the "Id" value of "000".
    You said:
    "call your updateImage() function with the appropriate id whenever you want
    to update the image."
    however when I add the value to this:
    function updateImage(000)
    I get error MSG's

    I would love to learn from your coding perspective; so feel free to
    clarify.
    And I was also able to get answers from:
    Nostroom in the Ultrashock.com boards - test_option-01
    &
    Niouze from the Macromedia.com boards - test_option-02
    both can be found here:
    [url]http://www.anicespot.com/test/test.rar[/url]

    thanks again
    James / NYC.




    "Herb" <herbmraz.at> wrote in message news:oprrpeqjiqpccq1tnews.aon.at...
    > Hi James,
    >
    > I wonder that your actionscript works, because the images_xml.onLoad
    > handler should use
    > the this keyword to reference to images_xml itself, not images_xml (as
    > images_xml is not a property of images_xml)...
    >
    > I suggest you store id's and images in an array within the onLoad handler,
    > and call your updateImage() function with the appropriate id whenever you
    > want to update the image.
    > updateImage() would take care of scrolling through that array and find the
    > imagePath to the id, and then load the image.
    >
    > e.g.
    >
    > -------------- actionscript --------------
    > // Array for imagePath and id
    > _global.imageArray = new Array();
    >
    > // XML object
    > var images_xml = new XML(); images_xml.onLoad = ViewImage;
    > images_xml.load("images.xml"); images_xml.ignoreWhite = true;
    > function ViewImage(success) { if (success) { var rootNode =
    > this.firstChild;
    > // Climb the XML tree and push the images id/path onto our array.
    > for (var i=0; i < rootNode.childNodes.length; i++) {
    > var currentId = rootNode.childNodes[i].attributes.Id;
    > var currentImagePath = rootNode.childNodes[i].attributes.imagePath;
    > _global.imageArray.push({id:currentId, imagePath:currentImagePath});
    > }
    > } }
    >
    > function updateImage(id) { for (var i=0; i < _global.imageArray.length;
    > i++){
    > if (_global.imageArray[i].id === id){
    > image_area.loadMovie(_global.imageArray[i].imagePath);
    > return; }
    > } }
    >
    > Hope this helps, Herb
    >
    >
    > On Wed, 2 Jul 2003 10:24:02 -0400, ROKKSTAR <jamesmail.toyboxxprod.com>
    > wrote:
    >
    > > I've been working on this for a while now; maybe someone has an answer or
    > > better idea. Trying to load a .jpg into an .swf via .xml .
    > >
    > > There is no on press, or next, or previous buttons; there are no buttons
    > > used for this movie.
    > >
    > > the code below works so far; but only for the first childnode However i'm
    > > still trying to get it to call the individual .jpg by only the "Id"
    > > attribute in each childnode; any suggestions?
    > >
    > > thanks to all for any help. James
    > >
    > > -------------- actionscript -------------- images_xml = new XML();
    > > images_xml.onLoad = ViewImage; images_xml.load("images.xml");
    > > images_xml.ignoreWhite = true; function ViewImage(success) { if (success
    > > == true) { rootNode = images_xml.firstChild; Image = rootNode.firstChild;
    > > updateImage(Image); } } function updateImage(Image) { imagePath =
    > > Image.attributes.jpegURL; image_area.loadMovie(imagePath); }
    > >
    > > ----- XML ----- <?xml version="1.0"?>
    > >
    > > <Images> <image Id="000" jpegURL="images/image1.jpg"> </image> <image
    > > Id="001" jpegURL="images/image2.jpg"> </image> <image Id="002"
    > > jpegURL="images/image3.jpg"> </image>
    > >
    > > <Images>
    ROKKSTAR Guest

  4. #4

    Default Re: load a .jpg into an .swf via .xml

    Some of your code is out of order and of wrong syntax. Put it in this order....

    ---------------------------------

    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }

    function ViewImage(success) {
    if (success == true) {
    rootNode = images_xml.firstChild;
    Image = rootNode.firstChild;
    updateImage(Image);
    }
    }

    images_xml = new XML();
    images_xml.ignoreWhite = true;
    images_xml.onLoad = ViewImage;
    images_xml.load("images.xml");

    ---------------------------------

    You must set the ignoreWhite attribute immediately and certainly before you load the XML or it won't ignore whitespace until after the XML is loaded and pd.

    --
    Shane Elliott
    [url]www.timberfish.com[/url]


    "ROKKSTAR" <jamesmail.toyboxxprod.com> wrote in message news:vg5qjrrl9fgkadcorp.supernews.com...
    I've been working on this for a while now; maybe someone has an answer or better idea.
    Trying to load a .jpg into an .swf via .xml .

    There is no on press, or next, or previous buttons; there are no buttons used for this movie.

    the code below works so far; but only for the first childnode
    However i'm still trying to get it to call the individual .jpg by only the "Id" attribute in each childnode; any suggestions?

    thanks to all for any help.
    James

    --------------
    actionscript
    --------------
    images_xml = new XML();
    images_xml.onLoad = ViewImage;
    images_xml.load("images.xml");
    images_xml.ignoreWhite = true;
    function ViewImage(success) {
    if (success == true) {
    rootNode = images_xml.firstChild;
    Image = rootNode.firstChild;
    updateImage(Image);
    }
    }
    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }

    -----
    XML
    -----
    <?xml version="1.0"?>

    <Images>
    <image Id="000" jpegURL="images/image1.jpg"> </image>
    <image Id="001" jpegURL="images/image2.jpg"> </image>
    <image Id="002" jpegURL="images/image3.jpg"> </image>

    <Images>
    Shane Elliott \(timberfish.com\) Guest

  5. #5

    Default Re: load a .jpg into an .swf via .xml

    The script your noting in your example is the original that I no longer use; due to the 3 scripts some very kind people helped me out with.
    I don't understand why you say the script is out of order.

    the beginning of the script:

    images_xml = new XML();

    is just like every Flash book and tutorial specifies.
    and of course the end calls the image:

    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }
    // end of script!

    so why would you say that the syntax is wrong if the script works with out errors, and those that others have suggested in the last 6-8 weeks all put there code in the exact same order?
    beginning of script "top"
    end of script "bottom"

    your statement seems a bit odd to me.
    James




    "Shane Elliott (timberfish.com)" <privatetimber.com> wrote in message news:3QlNa.876$9t4.555newssvr16.news.prodigy.com. ..
    Some of your code is out of order and of wrong syntax. Put it in this order....

    ---------------------------------

    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }

    function ViewImage(success) {
    if (success == true) {
    rootNode = images_xml.firstChild;
    Image = rootNode.firstChild;
    updateImage(Image);
    }
    }

    images_xml = new XML();
    images_xml.ignoreWhite = true;
    images_xml.onLoad = ViewImage;
    images_xml.load("images.xml");

    ---------------------------------

    You must set the ignoreWhite attribute immediately and certainly before you load the XML or it won't ignore whitespace until after the XML is loaded and pd.

    --
    Shane Elliott
    [url]www.timberfish.com[/url]


    "ROKKSTAR" <jamesmail.toyboxxprod.com> wrote in message news:vg5qjrrl9fgkadcorp.supernews.com...
    I've been working on this for a while now; maybe someone has an answer or better idea.
    Trying to load a .jpg into an .swf via .xml .

    There is no on press, or next, or previous buttons; there are no buttons used for this movie.

    the code below works so far; but only for the first childnode
    However i'm still trying to get it to call the individual .jpg by only the "Id" attribute in each childnode; any suggestions?

    thanks to all for any help.
    James

    --------------
    actionscript
    --------------
    images_xml = new XML();
    images_xml.onLoad = ViewImage;
    images_xml.load("images.xml");
    images_xml.ignoreWhite = true;
    function ViewImage(success) {
    if (success == true) {
    rootNode = images_xml.firstChild;
    Image = rootNode.firstChild;
    updateImage(Image);
    }
    }
    function updateImage(Image) {
    imagePath = Image.attributes.jpegURL;
    image_area.loadMovie(imagePath);
    }

    -----
    XML
    -----
    <?xml version="1.0"?>

    <Images>
    <image Id="000" jpegURL="images/image1.jpg"> </image>
    <image Id="001" jpegURL="images/image2.jpg"> </image>
    <image Id="002" jpegURL="images/image3.jpg"> </image>

    <Images>
    ROKKSTAR Guest

Similar Threads

  1. How can I load load Additional extensions ?
    By Dennis Lee in forum PHP Development
    Replies: 9
    Last Post: May 18th, 03:42 AM
  2. load flv using php
    By naughtymutt in forum Macromedia Flash Flashcom
    Replies: 8
    Last Post: November 9th, 09:28 PM
  3. Won't load
    By Eric_Durr@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 0
    Last Post: May 2nd, 05:43 PM
  4. RE-load mp3
    By joao bana in forum Macromedia Flash
    Replies: 0
    Last Post: December 10th, 01:56 AM
  5. getting cpu load
    By Kurtis D. Rader in forum UNIX Programming
    Replies: 1
    Last Post: July 29th, 08:49 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139