Path to dynamically loaded clips

  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

hi alll

i have an mc in flash, i have another mc inside this, then another inside that. this 3rd movie clip then has this code

Code: [ Select ]
on (release) {
    _root.contents.loadMovie("3d.swf");
}
  1. on (release) {
  2.     _root.contents.loadMovie("3d.swf");
  3. }


i have an empty movie clip on the very first movie clip with the instance name contents, so basicly i want this MC/button to load the MC '3d.swf' onto the very top level of my flash file..

_root.contents is too deep....what do i need to use to do it..

thanks in advance.

**
i have also tried
Code: [ Select ]
on (release) {
    this.contents.loadMovie("3d.swf");
}
  1. on (release) {
  2.     this.contents.loadMovie("3d.swf");
  3. }

to no avail too....thanks :oops:
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Sooo,
Code: [ Select ]
_root____mainMC_____MC_____Button
       |
       |__contents
  1. _root____mainMC_____MC_____Button
  2.        |
  3.        |__contents

Code: [ Select ]
_root_____parent_____parent___this
       |
       |__contents
  1. _root_____parent_____parent___this
  2.        |
  3.        |__contents

Code: [ Select ]
this._parent._parent.contents

I get the order right ?

Macromedia should have a _generation(3) property :P (step back 3 _parents) They don't Im just saying they should :wink:

^that gives me an idea :idea:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

:D
Code: [ Select ]
MovieClip.prototype._granny = function(gen){
    var who = ["this"];
    for(i=0; i<gen; i++){
        who.push("_parent");
    }
    return eval(who.join("."));
}

createEmptyMovieClip("test",0);
test._alpha=90;
test.createEmptyMovieClip("test",0);
test.test.createEmptyMovieClip("test2",1);
test.test._alpha=80;
test.test.test2._alpha = 33;
test.test.createEmptyMovieClip("test",0);
test.test.test._alpha=70;
test.test.test.createEmptyMovieClip("test",0);
test.test.test.test._alpha=60;
trace(test.test.test.test._granny(2).test2._alpha);
  1. MovieClip.prototype._granny = function(gen){
  2.     var who = ["this"];
  3.     for(i=0; i<gen; i++){
  4.         who.push("_parent");
  5.     }
  6.     return eval(who.join("."));
  7. }
  8. createEmptyMovieClip("test",0);
  9. test._alpha=90;
  10. test.createEmptyMovieClip("test",0);
  11. test.test.createEmptyMovieClip("test2",1);
  12. test.test._alpha=80;
  13. test.test.test2._alpha = 33;
  14. test.test.createEmptyMovieClip("test",0);
  15. test.test.test._alpha=70;
  16. test.test.test.createEmptyMovieClip("test",0);
  17. test.test.test.test._alpha=60;
  18. trace(test.test.test.test._granny(2).test2._alpha);


Realistically this prototype would be called from inside a button/mC like this,
Code: [ Select ]
on(press){
   this._granny(2).test2._alpha = 50;
}
  1. on(press){
  2.    this._granny(2).test2._alpha = 50;
  3. }

_granny just gets all the _parents together for you :) (gotta love good ole granny :P )
_granny(0) would return this
_granny(1) returns this.parent
_granny(2) returns this._parent._parent
Ect...

Might come in handy if you have alot of MCs referencing deep liniage.
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

wow
thanks m8

i am replying in my dinner hour at the moment from work.
check my site and u will see one menu which has a drop down bit, with more buttons.

those are the ones that dont work lol, i will try it tonight..thanks agen
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

i tried what you said but didn't quiet work...

let me draw up a diagram

Image
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Ok :lol: I was seeing the path wrong, take contents off the end,
Code: [ Select ]
this._parent._parent.loadMovie()


Think of each movieclip as a directory in a filesystem, where _root is the same as doing /, _parent is the same as ../, & this is the current directory. So if your looking to access a mC (directory) that contains the current mC (directory) you will not be using the name of that mC (directory) unless you use _root first.
The thing about _root is if you use it then load that movie into another movie then you are changing the paths of everything inside of that movie.
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

ok, still having no luck :(

if you say using _root. is like using \

then just using

_root.contents.loadMovie("3d.swf");

should do the job...
but nothing is happening

i know the empty movie clip is on the very top timeline
but the button is 3/4 deep inside others.

there are some buttons which are 3 deep, and using
_root.contents.loadMovie("3d.swf");

they work

but there is one button which is even deeper, because it is a drop down menu i made, so for the additional AS it needs to be in anoth MC

could i send you the .fla....so you can see what i mean?

via email or MSN?

of yea, and i use mx 2004, i will save in mx if u need
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

cough cough...


very big thanks to jeobert the AS god for fixing my menu bar :)
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Nucleo's problem wasn't that the paths were wrong.

When you place movieClips with mouse event handelers inside of movieClips that have mouse event handelers the inner movieClips mouse event handelers are ignored.

Nucleo had button movieClips with rollOver & rollOut actions applied to them inside of a movieClip that had rollOver & rollOut actions as well.

Everything inside of that movieclip is considered part of that movieclip & when any part of that movieclip is rolled over/out it triggers the actions of the first movieclip in the path.
consider the paths,
Code: [ Select ]
_root.container
_root.container.button
  1. _root.container
  2. _root.container.button


If you have _root.container.onRollOver then _root.container.button.onRollOver will not work because button is inside of container.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.