A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: action script _parent _root etc

  1. #1
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44

    action script _parent _root etc

    Can you help me please, im confused i am trying to write code inside the timeline of an object that refurs to the object it is in, (it wont know what its instance name is) i thought i could _parent but this seems to then effect everything not just the one part i want to move or use any ideas??

  2. #2
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    Your best bet is to use the _level action. Then you don't need to worry about instance names.

    The default level of your main movie is _level10. Additional movies are placed on higher levels i.e. _level11, _level12 etc.

    So, if this movie(MC) you want to control is on _level22, then you can control it like this (this is just an example):

    1) Through a button action -

    on (release){
    _leve22.gotoAndStop(5);
    } //this will go to and stop on frame 5 of the MC on level 22

    2) Through a timeline action -

    _leve22.gotoAndStop(5)

    Understand?
    "A day without laughter is a day wasted." - Charlie Chaplin

  3. #3
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    Thanks, but i dont think that will help. I am making a interactive thing where blocks will fall downwards if they are not suported by a block below it. All the blocks are the same mc, they can work out if there is a movie clip below it using a loop and hittest, the code for this is inside the movieclip, (so it will be the same code for every block) i need some way of the code refuring to the mc it is in, i cant use levels as all the blocks will be in the same level or this level will be unknown, as will the instance name.

    this is the file http://www.cellarmation.f2s.com/blocks.fla

  4. #4
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    I had a look at your file. I am a little bit confused.

    All I see is what appears to be 3D shapes piling up on top of each other on the root timeline and then the animation reverses. The animation does not clearly show objects dropping down on top of each other.

    There is nothing in your library which means that no Movie Clips or Instances exist.

    What this means is that I cannot do anything with what you have in your file.

    I assume that what you want to do is have boxes drop down in a 3 dimensional way. If a box collides with another it must stop on top of it. If not, it must fall all the way to the floor. Right?
    "A day without laughter is a day wasted." - Charlie Chaplin

  5. #5
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44

    Sorry

    im sorry that was the wrong file! this is the right one! http://www.cellarmation.f2s.com/blocks.fla sorry i uploaded the wrong one last time such a newb!!!

  6. #6
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    Can you see the problem i have now? I think its just down to how i can refur to a object from inside it.
    "Im Looking For Some Monkeys, 12 Of Them"

  7. #7
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    OK. I think I see what you are trying to do. Blocks will fall from the top of the screen. If a block lands on another one it must stop. Right?

    Let me have a look at it.
    "A day without laughter is a day wasted." - Charlie Chaplin

  8. #8
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    Yeah, and the large block at the bottom doesnt fall, so blocks should pile up, when i make more. but the action to move them down in the block mc effects everything as you can see if you run it, apart from that my code works (i think)
    "Im Looking For Some Monkeys, 12 Of Them"

  9. #9
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    http://www.cellarmation.f2s.com/blocks.fla this is the right file now, the files had the same name but were in differant folders
    "Im Looking For Some Monkeys, 12 Of Them"

  10. #10
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    I'm having a look at it. By the way, what is the black line to the right of the blocks for?
    "A day without laughter is a day wasted." - Charlie Chaplin

  11. #11
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    i put that in 2 prove 2 myself that everything is moving and not moving as it is supposed to. This seemed like a good idea at 11 o'clock!
    Last edited by Omen-mojo; 05-26-2004 at 06:02 AM.
    "Im Looking For Some Monkeys, 12 Of Them"

  12. #12
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    Any ideas of what code to use instead of _parent?
    "Im Looking For Some Monkeys, 12 Of Them"

  13. #13
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    Sorry. I haven't had a chance to sit down and tackle your file. Will do it as soon as I can.
    "A day without laughter is a day wasted." - Charlie Chaplin

  14. #14
    Lazy Member
    Join Date
    May 2003
    Location
    England
    Posts
    44
    Don't worry just worked it out myself, i dont know if this is the best way of doing it but i managed to get the mc to work out what the instance name of the object it was in my using a hittest and a for loop, thanks for all your help!
    "Im Looking For Some Monkeys, 12 Of Them"

  15. #15
    Senior Learner garion1's Avatar
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    483
    Great. I definitely was going to suggest the hitTest action and was thinking along the lines of a For loop.

    Good stuff!
    "A day without laughter is a day wasted." - Charlie Chaplin

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