#1
  1. No Profile Picture
    Shrill Digital God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Raleigh, NC
    Posts
    64
    Rep Power
    14

    Question movie loads when _y is at a specific position?


    I need some advice on the best way to use a function to detect a clip's position while it is moving, and execute a loadMovie to a target when the desired _y position is reached.

    I have a function on the timeline and movie clips with onClipEvents on each keyframe (or 'page' in the context of the site) that call this function. The clips pass a variable to the function which is supposed to determine the right content movie to load when the condition is met:

    onClipEvent (load) {
    category = "home";
    _root.moveMe(category);
    }

    Function moveMe itself looks like this:

    function moveme(category) {

    currenty = getProperty("_root.presentation", _y);
    speed = 5
    toLoad = category;
    if (toLoad == "home") {
    if (currenty<20 && currenty>-20) {
    loadMovie ("home.swf", "_root.content");
    }
    }
    else if (toLoad == "biography") {
    if (currenty<-321 && currenty>-361) {
    loadMovie ("biography.swf", "_root.content");
    }
    }
    else if (toLoad == "bookings") {
    if (currenty<-662 && currenty>-702) {
    loadMovie ("bookings.swf", "_root.content");
    }
    }
    else if (toLoad == "contact") {
    if (currenty<-1000 && currenty>-1043) {
    loadMovie ("contact.swf", "_root.content");
    }
    }
    else if (toLoad == "discography") {
    if (currenty<-1344 && currenty>-1384) {
    loadMovie ("discography.swf", "_root.content");
    }
    }
    else if (toLoad == "journal") {
    if (currenty<-1685 && currenty>-1725) {
    loadMovie ("journal.swf", "_root.content");
    }
    }
    else if (toLoad == "tracks") {
    if (currenty<-2026 && currenty>-2066) {
    loadMovie ("tracks.swf", "_root.content");
    }
    }
    }

    Problem: the function seems to be loading the wrong pages when it's called. It doesn't wait for the sliding clip to reach the desired _y position before loading the movies. When the sliding clip reaches the desired position, the movies that are loaded will disappear and there will be nothing loaded. It looks like the function is doing this when the sliding clip reaches the desired _y position for each possibility in the logic.

    Do I need a for loop?

    What's happening? I'm at my wit's end!!!!
    I'm not impatient, I just have a low tolerance for boredom.
  2. #2
  3. No Profile Picture
    Shrill Digital God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Raleigh, NC
    Posts
    64
    Rep Power
    14

    Solution


    // This function detects the _y position
    // of a movie clip, and loads a movie
    // into a target. I call it with onClipEvents
    // on the scrolling object

    category = "home";
    load = "";
    function trigger (movieclip, category) {
    currenty = Number(getProperty(movieclip, _y));
    // home
    if (currenty>-35 && currenty>=-15 && category == "home") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // biography
    } else if (currenty<=-325 && currenty>-357 && category == "biography") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // bookings
    } else if (currenty>-698 && currenty<-666 && category == "bookings") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // contact
    } else if (currenty>-1039 && currenty<-1007 && category == "contact") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // discography
    } else if (currenty>-1380 && currenty<-1348 && category == "discography") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // journal
    } else if (currenty>-1725 && currenty<-1685 && category == "journal") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    // tracks
    } else if (currenty>-2066 && currenty<-2026 && category == "tracks") {
    if (load == "" || load != category) {
    loadMovie (category+".swf", "_root.content");
    load = category;
    }
    }
    }
    I'm not impatient, I just have a low tolerance for boredom.

IMN logo majestic logo threadwatch logo seochat tools logo