A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Use Button To Pass Var To Another Frame

  1. #1
    Member
    Join Date
    Jan 2002
    Location
    UK - near Sheffield
    Posts
    39

    Use Button To Pass Var To Another Frame

    Hi guys im back,

    ok so i got a button on frame 110, and i got some code in the actions of frame 120.

    I need it so that when you click the button on 110 if passes the var page = therightscene, to the action code in 120, ermm.... look

    button code

    ----------------------------------------
    on (release) {
    play();
    var page = corporate;
    }
    ----------------------------------------


    then on frame 120 i got

    if (page = corporate) {
    gotoAndPlay("corporate", 1);
    } else {
    }
    if (page = polos) {
    gotoAndPlay("polos", 1);
    } else {
    }

    and so on and so on....for the full 11 buttons and scenes lol

    so the code should be able to recognise which button was clicked and jump to the relevant scene using the page variable, ohh this is so much easier in php.

    thanx for lookin guys,

    me x
    If impossible is nothing >> I'll look forward to everything !

  2. #2
    Member
    Join Date
    Jan 2002
    Location
    UK - near Sheffield
    Posts
    39

    never mind

    i did it using set var and numbers instead of txt

    110 =

    on (release) {
    set(page, "3");
    play();
    }

    3 represents scene 3 called casual

    then on 120

    if (page = 3) {
    gotoAndPlay("casual", 1);
    } else {
    }
    if (page = 4) {
    gotoAndPlay("corporate", 1);
    } else {
    }


    and so on and so on.......

    thought id post the solution in case anyone else has the same problem

    by the way thanx for the help guys

    If impossible is nothing >> I'll look forward to everything !

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    code:

    on (release) {
    play();
    _global.page = "corp";
    }




    then on frame 120 you should have...
    code:

    if (page == "corp") { // if statement takes 2 "=="...
    //gotoAndPlay("corporate", 1);
    //Never target scene names...
    //Label the first frame of your "corporate" scene with "corp"...
    //and use the following...
    _level0.gotoAndPlay(_global.page);
    } else {
    // whatever, if not stop();...
    }
    if (page == "polos") {
    //gotoAndPlay("polos", 1);
    // and the same as above...
    } else {
    }...



    In fact you don't even need an if & else statements...
    Just a...
    stop();
    _level0.gotoAndPlay(_global.page);

    Should take you the labeled frame value that was set in _global.page, on each button...
    Last edited by oldnewbie; 10-31-2004 at 09:41 PM.

  4. #4
    Member
    Join Date
    Jan 2002
    Location
    UK - near Sheffield
    Posts
    39

    saved by the force

    lmao as soon as i posted the above it went arse up ans stopped working, i must have buggered it up copying and pasting code all over the place, so ill try what old newbie has put



    thanx again, no i mean again lol
    If impossible is nothing >> I'll look forward to everything !

  5. #5
    Member
    Join Date
    Jan 2002
    Location
    UK - near Sheffield
    Posts
    39

    ARGHH on last thing plz oldnewbie

    the swf. with the buttons etc in is actually getting loaded into the main movie by means of a targeted empty movie clip.

    what you wrote above worked like a treat in flash but, when i uploaded the new version of the screen.swf file, that loads dynamically into the home.swf file, into a target mc called import_movie, it didnt work unless i clicked the button twice ?

    _global must change surely but to what I am puzzled ?

    any help ?

    last time today..lol
    If impossible is nothing >> I'll look forward to everything !

  6. #6
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    I just like these questions...

    Starts off by "I want to build this house... Not a big house, just a simple 1 floor flat with a nice view..."

    Ok! Do this and that, I reply!

    Then always comes something like... "Yeah! That's exactly what I had in mind, except for one thing... I need this flat to be in downtown Bagdag, and I don't have connections with the Bush or Cheney families! Can you fix something up for me?"

    I'm not a genius even if you think I am!

    I need to see the goddam house in front of me, if you want me to tell you where the secret passage is!

    So again, zip up all relevant .flas in a MX only format, not MX2004, and attach them, before I give George a call!

  7. #7
    Member
    Join Date
    Jan 2002
    Location
    UK - near Sheffield
    Posts
    39

    Here !

    the FLA
    Attached Files Attached Files
    If impossible is nothing >> I'll look forward to everything !

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