dcsimg
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: I really need some help with the if comand

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14

    I really need some help with the if comand

    hey ya.

    i am haveing a few probs wiv the IF comand. ok here we go, i have created a webpage useing a few difrent scene's (one for each section, design, hosting, portfolio and contact and the main page) what i want to do is from each of these secens i want to link to another so lets say u were on design and u wanted to go straight to hosting without going back to the main page. i have designed it so it all fades out so i should link probaly but i dont want to create 5 difrent endings to the scene just so it would link to the right page, thats where the if comand comes in. i want it to say something link

    if (designbutton = release)
    go to and play (design scene, 1)
    else
    go to and play (main scene, 80)

    well something linke that any way. hopefully you can understand my predicament and would be kind anough to give me a hand

    thanx alot

    Josh

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Just going from your code itn would be...

    if (designbutton == "release")
    gotoAndPlay("design scene", 1);
    }else{
    gotoAndPlay("main scene", 80);
    }

    This code indicates that you set a variable (designbutton) with the value "release" somewhere earlier.

    Using scenes this way usually complicates things as opposed to have the sections on different frames or movieclips. Or the best way in my opinion. To have each section as a separate swf file that only gets loaded when needed. That saves the user some valuable download time and seems to be the standard way to design an all Flash site.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    hmm that didnt work.

    i was going to prelaod each of the diffrent scene's. if i did split them up into difrent swf's i would still have this problem tho. i would just be linking them to a difernt htm rather than a diffrent scene.

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You might have the same kind of problem with the playing of your transition, but that has got nothing to do with scenes or loading different external movies, and that problem can be easily be solved with proper code.

    As for loading external movies rather than using scenes, you would load these movies an a main interface movie, not calling different html pages.

    See these...

    http://www.kirupa.com/developer/mx/loading.htm

    http://www.kirupa.com/developer/mx/full_site.htm

  5. #5
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    after i have sorted out the transitions i will look at how im going to load it. thanx for the advise. but i still cant get my script to work. i think it is something to do witht the release bit of the if comand.

    i have tryed useing true and that kinda did it untill i started adding the other buttons.

    heres my script. bareing in mind that it dosent work and it is a 1st for me.

    if (designbut = release) {
    gotoAndPlay(1);
    } else if (hostingbut = release) {
    gotoAndPlay("hosting", 1);
    } else if (portbut = release) {
    gotoAndPlay("portfolio", 1);
    } else if (backbut = realse) {
    gotoAndPlay("main", 245);
    }


    i have tryed useing == and eq aswell as changeing the relase to true and evey thing else but there is something wrong with it

    j

  6. #6
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    btw i mean a 1st time at scripting not at it not working thats happend to me plenty lol

  7. #7
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    come on someone out there must hav done something like this b4. think of all of those full flsh sites they all have smooth transitions how did they do them

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Well first off, an if statement does need 2 "==" for it to work! One "=" is used to set a variable.

    Second, what's this "release" thing? A variable? Or are you thinking the "release" action on your button.

    Off to work, so someone else will have to pick up on this...

  9. #9
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    the release thing is ment to be the an action on the button eq when the button is released or hit or down etc

  10. #10
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Well that won't work as scripted.

    You have to differently set a common variable when each button is pressed, and then check the value of the variable...

    on(release){
    _level0.my_var = "about"; // for example...
    // some other actions...
    }

    Then...

    if (_level.my_var == "about"){
    // Do something...
    }
    if (_level.my_var == "news"){
    // Do something else...
    }
    Etc...

  11. #11
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    i dont get this bit

    _level0.my_var = "about";

    would i just keep it the say as above or would i change it? if so what would i change it to.

    would it be something like _level0.my_var = "designbut"; or something like that?

  12. #12
    Flash maniac katiyuki's Avatar
    Join Date
    Sep 2000
    Location
    San Francisco
    Posts
    382

    hi

    hello!

    i think oldnewbie means something like this:

    first, on your main timeline you set a variable (doesnt matter what the name is, and set it preferably on the very first frame on the timeline) like this:

    my_var="null"; //doesnt have to be equal "null" , just something that means
    nothing

    second, in the actionscript for your button put something like this in it:

    //on the design button
    on (release) {
    _root.my_var="design";
    }

    //on the news button
    on (release) {
    _root.my_var="news";
    }

    //on the about button
    on (release) {
    _root.my_var="about";
    }

    and then lastly, on the frame where you want to know which scene must be played next, you have to see what "my_var" is set to. what "my_var" is set to will instruct which scene should be played next. on the frame where you want to know this, put this actionscript in:

    if (_root.my_var=="design") {
    gotoAndPlay("design",1);
    } else if (_root.my_var=="news") {
    gotoAndPlay("news",1");
    } else if (_root.my_var=="about") {
    gotoAndPlay("about",1);
    }

    hope this helps.

    kat
    back to flashing...woohoo!

  13. #13
    Junior Member
    Join Date
    Apr 2003
    Location
    Isle of wight
    Posts
    14
    THANK YOU

    It work, u r a star. infact all of you r stars

    thanx alot

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