A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: need help to find good path to images

  1. #1
    Junior Member
    Join Date
    Sep 2006
    Posts
    22

    need help to find good path to images

    Here is another question :
    I constantly have the following output :
    Error opening URL "file:///C|/Documents%20and%20Settings/user/Desktop/SITEFINAL/images/travel/undefined".
    I don't understand why because It does find the path to my images when applicated to other objects ( here initThumb). If you take the time to read the code, you'll see that I use the same path for both .
    What do I do wrong ????I am lost.

    Here is the critical part of my code :

    xmlPhotos.ignoreWhite = true;
    xmlPhotos.load("travel.xml");

    var premierPic = 0;
    var allPics = 78;
    var xmlPhotos:XML = new XML();
    var initThumb:Object = new Object();
    xmlPhotos.onLoad = function() {
    for (var i:Number = 0; i<xmlPhotos.firstChild.childNodes.length; i++) {
    initThumb.photo = (xmlPhotos.firstChild.childNodes[i].attributes.photo);
    initThumb.titre = (xmlPhotos.firstChild.childNodes[i].childNodes[0].firstChild);
    initThumb.count = (xmlPhotos.firstChild.childNodes[i].childNodes[1].firstChild);

    }
    };
    initThumb.onRelease = function() {
    mcLargePhoto.loadMovie("images/travel/"+this.photo+"");
    txtCount.text = this.count;
    txtDesc.text = this.titre;
    mcScroller._alpha = 0;
    };

    Previous_btn.onRelease=function(){
    previousPic();
    }

    function makeAThumb(num) {
    thumbname = "mcThumb"+num;
    mcScroller.attachMovie("thumb", thumbname, num, initThumb);
    mcScroller[thumbname].mcPhoto.loadMovie("images/tthumb/"+mcScroller[thumbname].photo+"");

    }
    function previousPic(){
    if ((premierPic+1)>=allPics) {
    premierPic = 0;
    } else {
    premierPic++;
    }
    mcLargePhoto.loadMovie("images/travel/"+this.photo+"");
    txtCount.text = this.count;
    txtDesc.text = this.titre;
    }
    this.createEmptyMovieClip("mcScroller", this.getNextHighestDepth());
    Previous_btn.addEventListener("click", previousPic);

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    what does a trace reveal -

    trace(this.photo); // undefined ??
    trace("images/travel/"+this.photo+""); // undefined ??

    mcLargePhoto.loadMovie("images/travel/"+this.photo+"");

  3. #3
    Junior Member
    Join Date
    Sep 2006
    Posts
    22
    hello nice Avatar !
    yes it indeed the output is undefined for both traces.

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try pushing your xml nodes into an associative array -
    Code:
    arr = new Array();
    xmlPhotos.onLoad = function() {
    
    for (var i:Number = 0; i<xmlPhotos.firstChild.childNodes.length; i++) {
    var initThumb:Object = new Object();
    initThumb.photo = (xmlPhotos.firstChild.childNodes[i].attributes.photo);
    initThumb.titre = (xmlPhotos.firstChild.childNodes[i].childNodes[0].firstChild);
    initThumb.count = (xmlPhotos.firstChild.childNodes[i].childNodes[1].firstChild);
    arr.push(initThumb);
    }
    use List Variables to show how the array is compiled
    use your counter to loop through the array -
    Code:
    var premierPic:Number = 0;
    
    initThumb.onRelease = function() {
    trace(arr[premierPic].photo);
    mcLargePhoto.loadMovie("images/travel/"+arr[premierPic].photo);
    txtCount.text = this.count;
    txtDesc.text = this.titre;
    mcScroller._alpha = 0;
    };
    untested, but the logic is sound

    EDIT - object moved to inside of loop

  5. #5
    Junior Member
    Join Date
    Sep 2006
    Posts
    22
    well it gives me now a strange output...
    Error opening URL "file:///C|/Documents%20and%20Settings/user/Desktop/SITEFINAL/images/tthumb/undefined"
    strange because this is the path of the makeAThumb function...

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    tthumb with 2 't's, typo?

    gparis

  7. #7
    Junior Member
    Join Date
    Sep 2006
    Posts
    22
    yes 2 ts, it is the folder to the thumbs and it was working ok until I decided to modify the code to create the previous and next function...

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    if using the array method as i posted above -

    trace(arr[premierPic].photo); // what is the output ?

    mcScroller[thumbname].mcPhoto.loadMovie("images/tthumb/"+arr[premierPic].photo);

  9. #9
    Junior Member
    Join Date
    Sep 2006
    Posts
    22
    hi there again
    I just posted another thread...I am still stucked.
    Well I try right now for the output and let u know.
    But just a fast question : it seems that your solution is related to the initThumb Object...that's may'be why I have the first output mentionned in my previous thread ( images/tthumb etc...)

  10. #10
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    sorry, you have lost me with this one,
    best to stick with one thread otherwise we all end up confused
    can only suggest that you plaster traces all over your file to
    find the flaws in your logic.

    good luck

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center