A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: arrays used with navigational decisions

Hybrid View

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    i have 6 buttons on my main navigation panel.

    Each button plays a movieclip that brings in text information and plays a 3D animation. The animation lasts for 20 frames from start to finish. The last frame is where all the information is displayed on the main stage.

    As i press any of the buttons i want Flash to check to see whether any of the other buttons have already been pressed (and the corresponding movieclip has played)

    If flash finds that any of the movieclips have already been played i have an instruction to rewind the clip and play the clip relating to the button that has just been pressed. If no buttons have already been pressed then flash only plays the movieclip relating to the button pressed.


    I have script that uses alot of "if" and "else if" statements looking at ._currentFrame positions and boleans set false if a clip is on frame 1 and true for any other frame.

    Should i be using arrays to sort through the data more efficiently.

    If so then can anyone direct me to a related tutorial or give me further instruction on the matter.

    Example code on one of the buttons


    //code starts here

    on (release) {
    if (_root.but2._currentFrame == 10) {
    _root.but2.play();
    play ();
    } else if (_root.but2.boolbut2 == true) {
    _root.but2.gotoAndStop(1);
    play ();
    } else if (_root.but3._currentFrame == 10) {
    _root.but3.play();
    play ();
    } else if (_root.but3.boolbut3 == true) {
    _root.but3.gotoAndStop(1);
    play ();
    } else if (_root.but4._currentFrame == 10) {
    _root.but4.play();
    play ();
    } else if (_root.but4.boolbut4 == true) {
    _root.but4.gotoAndStop(1);
    play ();
    } else if (_root.but5._currentFrame == 10) {
    _root.but5.play();
    play ();
    } else if (_root.but5.boolbut5 == true) {
    _root.but5.gotoAndStop(1);
    play ();
    } else if (_root.but6._currentFrame == 10) {
    _root.but6.play();
    play ();
    } else if (_root.but6.boolbut6 == true) {
    _root.but6.gotoAndStop(1);
    play ();
    } else {
    play ();
    }
    }

    //code ends here


    In this particular script there is no use of the code that plays the movieclip backward - all this does is see whether a clip is on frame 10 and if so then it plays the clip further - frame 10 onward in each clip is a reverse of the first 10 frames.


    Can any of this code be put into arrays and examined sequentially?

    Any ideas would be greatly appreciated

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    This is just one of many ways to solve that problem.

    set a variable to hold the info about which button pressed last. Say, we name that variable "clicked" and we put the following code in each button

    Code:
    on (press){
       rewindMovieClip();
       playMovieClip(thisMovieName);
       _root.clicked = thisMovieName;
    }
    Function rewindMovieClip will remove whatever movie played last using _root.click, if there none, then do nothing.
    Function playMovieClip will take parameter "thisMovieName" and play that movie. Finally you set _root.clicked = thisMovieName so next time you press any button, playMovieClip function will know which movie to rewind.

    hope this helps.

  3. #3
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    Thanks for that RapidCarbon

    I am not however that good at functions just yet, could you give me an example of how i would use my rewind movie clip code in a function and then how to call it.

    The rewind code is itself within an invisible movieclip

    2 layers 5 frames long

    layer 1 - invis button - on press gotoAndPlay ("rewind")
    layer 2 - Actions

    Actions layer
    frame 1 - stop
    frame 4 - labeled "rewind", then the code to rewind. Following is example code from this frame that controls a movieclip called instance "corp" within another movieclip instance "finalhex". It plays corp but also checks the condition of another movieclip, instance name "serv" also within "finalhex"


    if (_root.finalhex.serv._currentFrame<>1) {
    _root.finalhex.serv.gotoAndPlay(_root.finalhex.ser v._currentFrame-2);
    _root.finalhex.corp.play(2);
    } else if (_root.finalhex.serv._currentFrame == 1) {
    _root.finalhex.serv.gotoAndStop(1);
    gotoAndStop (1);
    _root.finalhex.corp.play(2);
    }




    frame 5 - gotoAndPlay ("rewind")



    so this script plays "serv" backward if neccessary. And will always play "corp"


    Sorry if this is confusing.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    hmm, yes it's kinda confusing. Can we look at your fla? I can help you better if I visually know how you set up your movie.

  5. #5
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    OK i have the file ready to send you but there is nowhere for me to attatch the file on the Flashkit email link.

    Could you give me your address and i will send the fla

  6. #6
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    here it is, dominicosavio@yahoo.com

  7. #7
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    The way you build your movie is very confusing. You should not put MC inside an graphic instance. Think of graphic instance and button are the lowest level in fla file. Anyway, I did add a layer "Functions" in your main timeline. I changed the code in your button movies, renamed hex movie instances. You can delete your array thing in each button

    Take care

  8. #8
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    One more thing, organize your library using folder will make it very easy to locate symbols.

  9. #9
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    Thanks for that RC,

    but the fla you sent me was not quite what i had originally intended. (i am not ungreatful!!!!)

    The fla i sent you had the corporate and services movie clips working as intended
    1.if one or other is first pressed, that mc plays
    2.if one or other is pressed and the other has already played, then the former plays and the latter actually rewinds.

    The fla you sent me sends any clip that has already played back to frame 1 instantaneously on press of any of the other buttons.

    Is there any way of incorporating the actions i set in the "rewind" frame on each of the controlling movieclips, into the rewind funciton that you wrote?

    sorry to keep being a pain

    incidently i have learnt alot from your function setting - thanks

  10. #10
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    Sorry, will send you a new fla again. but there is a small bug, I will try to fix it or I will post it up here for people to fix it (if you don't mind)

  11. #11
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    Fixed, just add one line to it. So now your code look like this after I fixed up everything.

    Code:
    if (_root.finalhex[_root.now]._currentFrame == 38) {
    	_root.clicked = _root.now;	
    	gotoAndStop(1);
    } else if (_root.finalhex[_root.now]._currentFrame != 38) {
    	_root.finalhex[_root.clicked].prevFrame();
    	_root.finalhex[_root.now].nextFrame();
    }
    Take care.

  12. #12
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    One more thing, what and how do you do to create those hexagons, and tween them they way they look in the movie? Are you using some kind of software? I wish I could do those thing.

  13. #13
    Senior Member
    Join Date
    Mar 2001
    Posts
    527
    Thanks for your help - will now try and input that new line of code


    Those hexagons were created and animated in Swift3D and then exported and brought into flash. Will be doing more of the same as the project continues. The site is the corporate flash site for our company Stratisoft Ltd. Should look pretty cool when finished.

  14. #14
    Senior Member
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    437
    Got to learn Swift3D

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