A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: gotoAndPlay scene variable

  1. #1
    Gods cower, women quiver. Buckwheat469's Avatar
    Join Date
    Dec 2003
    Location
    Uranus
    Posts
    247

    gotoAndPlay scene variable

    Hello,
    I'm working on making some buttons read a variable that I have set, that's not really the important part so I'll make it simple.

    scene = 1;

    Scenename = "Scene " + scene; //something like this

    gotoAndPlay(Scenename,1);


    I get the error that I need to define a string for the Scene on the gotoAndPlay statement. How do I get around that so I can use the variables that I set?
    yup.

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    First, you shouldn't be targeting scene names, but labeled frames instead...
    Just label the targeted frame in whatever scene or whatever timeline, with an unique label such as my_target1 (no number only labels, or at least not starting off with a number, no caps, no spaces, no other special characters other than the underscore...), add _root or _level0 to your path to target the main timeline, and target the labeled frame on your scripts...
    code:

    on(release){
    _level0.gotoAndPlay("my_target1");
    }



    If you want to use a variable...

    _global.frame_to_go = "my_target1";

    Then...

    code:

    on(release){
    _level0.gotoAndPlay(_global.frame_to_go);
    }


  3. #3
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    I'm trying to do that, but it's not working. I label the frame, but what's this _level0 business about??

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    _level0 is basically the same as _root when a button is within a movie clip, but would expressly need to be used if the button was in an external movie loaded on another level.

    If it's not working for you, then you've got something else wrong!

  5. #5
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    Well, all I'm trying to do is make an animated button take me to another scene!

  6. #6
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Attach your .fla, zipped up and in MX only format, not MX2004!

  7. #7
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    How do I zip it?

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Are you on Mac? If not, no need to zip it if it's under 300kbs.
    Otherwise Winzip!

  9. #9
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    I'm on a spanky Mac, yes.

    So, Winzip, yes?

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

  11. #11
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    Sorry for the delay...
    Attached Files Attached Files

  12. #12
    Junior Member
    Join Date
    Sep 2001
    Posts
    15
    You need to clean up your code. No fringe spaces here and there!

    Remove the code you have added for a Symbol Definition. I do not know what that is. Then put this code on the button in frame 25:
    code:
    on (release) {
    gotoAndStop("Contents","my_target1");
    }


  13. #13
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Can't open your .fla... Must be a MX2004 format, that can't be open on MX only unless you save a copy in a MX only format...

    As for Janove, he seems to be suggesting to use exactly what I said you shouldn't be using, which is a scene name...

  14. #14
    Junior Member
    Join Date
    Sep 2001
    Posts
    15
    It seems it works without inserting the scene name too as oldnewbie says. I didn´t know/understand that. So just use this code:
    code:
    on (release) {
    _level0.gotoAndStop(_global.frame_to_go);
    }


    Define the variable as stated ealier in the thread in the start of your movie. I have attached a working file in MX format.
    (Sorry about giving wrong advice oldnewbie.)
    Attached Files Attached Files

  15. #15
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    Okay cheers! I don't *quite* understand all this variable stuff, but that's something I'll have to look into, eh?!

    I've only got one more problem (), and that's when I click the button, it locks onto the first frame of the scene, and nothing plays. I've tried moving the 'my_target1' around, but it doesn't show any movement - it's just locked on.

    I'm thinking that there's something simple I should be doing.

    Any answers?

    (btw, cheers again guys! )

    P.S, this isn't relative to the topic, but my pixel fonts, on some selected sentences are blurry, even though they're all size 8. It's happening on all 3/4 of them, any idea? (For reference, they're Pixel08, SquareDance and fixed01...).
    Last edited by Tomm3h; 10-11-2004 at 02:23 PM.

  16. #16
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Change the gotoAndStop() to a gotoAndPlay() maybe

    Several other restrictions on the use of pixel fonts...

    Textfield must not have been scaled, must be 100% across in the Transform panel...
    Text must be left justified only...
    If the textfield is nested in movie clips, they must also be on exact pixel value coordinates, and must not have been scaled either.

  17. #17
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    Cheers );

    K, the font was blurred because it was justified. But... I want it to be justified, anyway I can get past this with it being justified?

  18. #18
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Dynamic text cannot be full justified, if that's what you really mean. Even more so when using a pixel font.

    You can use spaces to justify each line of text yourself in the text file...
    Or you might try the somewhat method in this thread, but don't think that would work with a pixel font...

    http://www.flashkit.com/board/showth...hreadid=566694

  19. #19
    Fo'Stick
    Join Date
    May 2004
    Posts
    65
    It's not dynamic, just static. And I'm trying to make the text not blurry, which it goes when justified. There must be an easier way the just spacing it out, surely.

  20. #20
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Nope! To my knowledge and from the man himself (http://www.fontsforflash.com/), a pixel font can only be left justified.

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