A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: switch/case code not working

  1. #1
    Senior Member
    Join Date
    Jul 2005
    Location
    Birmingham, England
    Posts
    124

    switch/case code not working

    I have a presentation in flash that consists of a main menu and 4 sections

    it is all in one file. the main menu sits on frame 1 of the timeline, section1 sits on frame 2 etc.

    from the main menu you can choose to go to each section directly or choose to play all.

    this means that at the end of each section - depending on which option was chosen you either go to the next section, or back to the main menu.

    i am trying to solve this currently with the following code.

    code on the menu button......

    on (release) {
    _secton1.page = 1;
    tellTarget ("_root") {

    _root.gotoAndPlay(2);
    }
    }


    what i was hoping is that this would take you to section one and would then be sent back to the menu when reaching this code that is placed near the end of section1....

    switch (page) {
    case 1 :
    _root.gotoAndPlay(1);
    }


    the trouble is - its not working!!!! it just carries on past the frame where the code is, and so reaches the end of the section where I have the coding to take it on to the next section rather than back to the menu.

    I thought an easy way to solve the problem would be to double up all the sections ( so i would actually have 8 sections) and then the coding is simple as you can have one set of section with one code, and another with the other.

    ....However the presentation is quite big as it is (it has full audio commentry) so doubling it in size is not an option as my computer runs out of memory during publishing.


    Any idea's?
    ...Thanks in advance....

  2. #2
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    your checking for a number where this is possibaly a string
    try this
    code:

    switch (page) {
    case "1" :
    _root.gotoAndPlay(1);
    }



    hope it helps
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  3. #3
    Senior Member
    Join Date
    Jul 2005
    Location
    Birmingham, England
    Posts
    124
    thanks for the suggestion, but its still not working.

    has anyone got an alternative solution.....

    cheers.

  4. #4
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    ah forgot about the break
    code:

    switch (page) {

    case "1" :

    _root.gotoAndPlay(1);
    break;

    }

    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

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