dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Builting Navigation in a flash site

  1. #1
    Member
    Join Date
    Feb 2008
    Posts
    34

    Builting Navigation in a flash site

    I'm havin' trouble to built it the way I want to. Here's what i have done till now:

    On a background flash file i've put 4 buttons and a content-less movie wit the instance name "content". I want that, when the user pushes a button, a movie clip gets loaded under content, pretty simple at this point.

    But (ow hell there's always the but)...

    Each movie clip that shall be loaded have a intro and "goin out" exit, and i have no ideia how to tell flash to wait the movie end to load the new one >_<.
    I do think I need somethin like doLater or setInterval, on the button, something like:


    on (release) {
    _root.content.gotoAndPlay(50);
    "hey flash, if there is no content juz go to next action, if there is already content loaded wait X time"
    _root.content.loadMovie("portfolio.swf",2);
    }

    I just don't think flash will understand the hey part ^^'''''.

    If anyone can help I'll be thankfull forever =O

    thanks for readin'! ^_^

  2. #2
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483

    Please clarify?

    Let's see if I understand you correctly.

    When a button is pressed, an external movie must load dynamically into your 'content' Movie Clip and start playing the intro. If another button is pressed, the currently playing intro must end first before loading the new movie.

    Is this correct?
    "A day without laughter is a day wasted." - Charlie Chaplin

  3. #3
    Member
    Join Date
    Feb 2008
    Posts
    34
    hm
    when pushin the button, let's say home, home.swf is loaded and plays 15 frames (intro) and stops, it contains another 15 fps exit with an unload from content code in last frame.
    so what i need is that, when other button is pushed, it needs to resume the playback of movie loaded on content, wait to it unloads from content, and then load the clip from the button the user have pushed.

  4. #4
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    You have to use variables. For example:

    on Frame 1 of the timeline, add:
    var nextScreen:Number = 0;

    Create an empty Movie Clip on the stage with instance name "swfloader"

    Assuming that a page loads initially, use:
    _root.swfloader.loadMovie("myswf0.swf", loadedscreen);

    Now, add this to each button's onPress/onRelease action:
    //for button1
    nextScreen = 1;
    loadedscreen.gotoAndPlay(16);
    //for button2
    nextScreen = 2;
    loadedscreen.gotoAndPlay(16);
    //for button3
    nextScreen = 3;
    loadedscreen.gotoAndPlay(16);
    //for button4
    nextScreen = 4;
    loadedscreen.gotoAndPlay(16);

    On the last frame of each swf, add:
    if(nextScreen == 1){
    _root.swfloader.loadMovie("myswf1.swf", loadedscreen);
    }
    if(nextScreen == 2){
    _root.swfloader.loadMovie("myswf2.swf", loadedscreen);
    }
    if(nextScreen == 3){
    _root.swfloader.loadMovie("myswf3.swf", loadedscreen);
    }
    if(nextScreen == 4){
    _root.swfloader.loadMovie("myswf4.swf", loadedscreen);
    }

    Hope this helps.
    "A day without laughter is a day wasted." - Charlie Chaplin

  5. #5
    Member
    Join Date
    Feb 2008
    Posts
    34
    Hi thanks for the reply
    I got the coding but somethin doesn' work well yet.
    I'll explain the full situation

    first a splash flash loads
    in it's playback end
    i've add
    stop();
    loadMovieNum("background.swf", 1);
    so it loads a new flash, the one with the navigation, in level 1.

    Then i tried adding ur code, i supose the variable worked cause when i push any of the buttons the respective movie loads.

    What doesn't work is the load of a new movie in the end of a previous one.
    Since i was usin the background in level 1 i set the contents to load on level 2, so my loading codes ended like this:

    if(nextScreen == 1){
    _root.swfloader.loadMovie("myswf1.swf", 2);
    }


    If i try just a simple load to test, without the if, the loading works thou.

    Ps: I don't understand why the "loadedscreen"

  6. #6
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483

    Explanation

    _root.swfloader.loadMovie("myswf0.swf", loadedscreen);

    The above code means: Load the external movie 'myswf0.swf' into the Movie Clip on the stage which has the instance name 'swfloader'. Give 'myswf0.swf' the instance name of 'loadedscreen'.

    You have to give the loaded swf an instance name so that you can refer code to its timeline e.g. loadedscreen.gotoAndPlay(16);

    Now that I look at it, the code should look like this:
    _root.swfloader.loadedscreen.gotoAndPlay(16);

    Why don't you just have your background Movie Clip on the bottom layer from the start. Just give it an instance name e.g. "myBG" and then put this code on the first frame:
    _root.myBG._visible = false;

    When your splash playback ends add:
    _root.myBG._visible = true;
    "A day without laughter is a day wasted." - Charlie Chaplin

  7. #7
    Member
    Join Date
    Feb 2008
    Posts
    34
    Thanks for helping.
    I'm loading the backgroun 'cause of color issues.
    The main problem seems to be that the loaded movie doesn't get the variables value =.=. I'm havin' no issue to control the loaded movie or play it or load a new one over it, all this actions work fine as long as they doesn't depend on a variable value.

    For example, if in the end of a loaded movie i add this

    _root.contents.loadMovie("home.swf");}
    (just a simple load)


    instead this

    if(nextScreen == 1){
    _root.contents.loadMovie("home.swf");}


    It works, the error seem in defining the variable value or getting it.

    So all i did with the variable was:

    In a point before the buttons load i set:
    var nextScreen:Number = 0;

    My code for each button is a bit diferent, since i don't load a movie under contents (swfloader) initially:

    on (release) {
    if(nextScreen == 0)
    {nextScreen = 1;
    _root.contents.loadMovie("home.swf");}
    else
    {nextScreen = 1;
    _root.contents.gotoAndPlay (50)}

    }

    this 2 actions seems to be performed corrrectly.

    Then in the end of a movie loaded under contents:

    if(nextScreen == 1){
    _root.contents.loadMovie("home.swf");}

    if(nextScreen == 2){
    _root.contents.loadMovie("portfolio.swf");}


    Here is where it fails. Reforcing that if I set just a load here, without a if, the loading takes place.

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