A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Adressing _levels using variables? I'd love help!!

  1. #1
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    Hi you flash 5 actionscript experts around the world!

    How can I adress a _level with a variable?

    Expl: I like to define a variable n to adress a movie on _level n. but I don't know the syntax. (I only know the syntax for movieClips that is for example _level0["clip"+n]._x = ... and ["_level"+n].clip2 = ... doesn't work)

    I'll bake a cake for anyone with a helpful answer and send it even to brasilia if that answer would do the trick. HELP!

    .tobi.

  2. #2
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    read on flashgurus site that if you use _flash. it will address variables at any level. I've not tried it, but then again I'd probably trust him!

  3. #3
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    Hi swampy!

    thanks for the fast answer. but _flash doesn't work -> perhaps it adresses variables on all levels but not objects! do you have another idea? anyone else?

    by the way, what's the flashgurus url?

    .tobi.

  4. #4
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775

  5. #5
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    Thank you again swampy!

    SO, IS THERE ANYONE OUT THERE WITH AN ANSWER, THAT'LL FIX MY PROBLEM?

    Help!

  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    surely you can use the same syntax that refers to objects on the other levels.

    so _level1 refers to the timeline of level 1. if you load another swf into that level, you can address variables in its root by _level1.variablename. if you have a movie clip called 'cake' in that movie and a variable 'chocolate' defined in that MC, you could put:

    _level1.cake.chocolate = "lots";

    [some subliminal messaging there ]

    that should do it...

    have fun - n.

  7. #7
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    ups. I think we're talking about something different! I hoped to adress the level-number by a variable, not the objects in that level. So, how can I have a variable n that carries the levelnumber of the object to access?

  8. #8
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    ooops. I think you are right - sorry!

    try

    eval("_level" add levelNumber)

    that should do it


  9. #9
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    That's fine! ... as far as I only want to get variables and properties. ONE STEP IN THE RIGHT DIRECTION! but what about changing properties using variable levels? like _leveln.stage._x = 345;

    So, if you find an answer for that, the mentioned cake will be yours!

    Thank you so far!

  10. #10
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180
    Hi...
    Adding to enemem previous post:

    on (release) {
    eval("_level"+n).myMc._x=345;
    }

    The above code targets the MC 'stageMc' and changes it's position to x=345.
    I set the variable 'n' to 2 elsewhere in the movie. The 'stageMc' resides on level2.

    Good luck.

  11. #11
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    YIPEE! That really saved my day after nine hours of trouble. So your the winner of the handmade cake, if you like to have it. It would be my pleasure! So, if you like, just mail the post-adress to tobistobi@hotmail.com. :-)

    Thank you,
    .tobi.

  12. #12
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    cake wars!

    I think I should have half the cake at least

  13. #13
    Senior Member
    Join Date
    Jun 2000
    Posts
    1,180

    Cake!

    Hi..
    Fair enough enemem, I'll except half as long as long as I get the half with the most icing on it.

    Cheers.


  14. #14
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    hmmm. not too keen on icing myself.
    so what if you just have the icing and I get the rest???

    sound fair to you?

  15. #15
    Junior Member
    Join Date
    Jun 2001
    Posts
    26
    hi you two!

    so, don't you argue! You really saved my live, both. And I promised a cake to the one, who helped me. ok. so there we are. what about two cakes? I mean two small cakes... your turn guys, it's just a offer -- ... that's gonna be a long weekend!

    .tobi.

  16. #16
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    hey tobi -

    you are too nice
    don't you have any more questions that you want answered????

    'tis okay - Marx can have the cake, I just fancied a bit of a debate...

    + where I live at the moment the post is very unreliable to say the least (about 10% comes through unopened - just the bills really ), so probably not the best idea to send it to me... [you can send me a picture of it if you really do bake it]

    it's a sweet offer though!

    Marx: let me know how it tasted!

    see you - n.






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