nested child calling root parent function help me!
sup playaz! So i've been reading and searching for 2 days on this and so I've finally decided to ask for help. I'm switching from as2 to as3 and everything was going swimmingly with my new site until i tried to use a _root call to a function on the main timeline by a loaded movieClip that is loaded nested into 2 other movieclips. the movieClip needs to tell the _root when it's done playing so the root knows to load the next one in line through a php call. Everything works except for the _root call. In as3 there's no such thing as root anymore so I figured no big deal, i'll just find out what the new thing is and holy crap wtf! I can't figure this out!! I've read from doing stuff like custom eventLisnters (which i am trying now) and casting the root as a movieClip and then I read this whole crazy tutorial on building an event structure and the proper MVC way of coding and blah blah blah ALL I WANT TO DO is tell the _root that the loaded MC has reached the end of its timeline. Basically if it were as2 i could just go _root.loadNext(); and it would work. Does anybody have any clue how to make a loaded MC talk to the _root timeline and call a funciton from there?
I'll keep trying and if i figure it out I'll post what i come up with here. Thanks
I made some test flas so we can all figure this out. I have a parent fla that loads the nested movieClip that tries to call back a function on the parent when it's done playing. Make it work and get a star!
Not true. Root is still there, just called "root" instead of "_root", and it's handled a little more type-strictly. But swfs in as3 always act like the old lockroot was set to true, so the loaded swf's root will be itself, and not the main timeline. You could use a parent.parent... chain, but that's ugly as sin.
Instead, use the event model to bubble an event from the loaded swf up the displaylist until it hits something that cares about the event.
In last frame of loaded swf:
Code:
dispatchEvent(new Event("allDone", true));
In main timeline:
Code:
addEventListener("allDone", loadNext);
function loadNext(event:Event = null):void{
//... whatever you do in loadNext.
}
"allDone" is the event type here, and it's arbitrary. All you need to make sure of is that both the loading and loaded are using the same value.
I put it above the loadit and still aint work. I donno if mc_inner1 is "on the display" cause I don't know what that means :-[ Does it mean that theirs a display array that lists all the stuff in it? Below is a link to the 2 files where i attempted your event dispatch
Unfortunately, I only have CS3 (and I hate to use that), so I cannot open your fla files. However, I did create a simple flashdevelop project which shows the principle.
In the attached zip, you will find Alice.as and Bob.as. Alice loads Bob and listens for an event. Bob dispatches that event. Both of them report their own and their root's ids.
Here's the output I get:
Code:
alice says id=alice
alice says root.id=alice
bob says id=bob
bob says root.id=bob
alice got an alldone from bob
hahaha looking at your files and sheesh! what is all this stuff. What is roottest.as3proj ? did you do this in flex or some such? I'll keep looking at it....
oh wow! i see how you put my loadit and stuff in there! gonna work at it. My stuff isn't in a package though. perhaps that's what is screwing it up :-\ thanks i'll work on this more...
as3proj is how flashdevelop saves projects. That's not important. Just look at Alice.as and Bob.as.
roottest.swf in the bin folder is the main loader swf. Bob.swf is from Bob.
Alice loads Bob with a Loader, and you get the output I showed above. You should be able to look at the code in the two .as files and apply it to your own project. I will attempt to open your updated cs3 version and see what I can do, but I'm currently busy with paid work so it might be a while.
hahahaha thanks sorry to slow down your paid work lol. I am doin what you said! am close maybe. no rush. thanks again. I'm beginning to have breakthroughs that i can use for so much stuff so this is mad exciting if i get it workin i'll post it back here yaaay
oh man! i got it working with the php now!!! you rock so hard. so now it loads the cartoon from yesterday -- or will haha once i make them starting tonight!! yes!! take a look at your glorious event thing in action!
Ignore the shart art right now it's still just a sketch! hahahaha click the button with this guy on it :-P for a surprise! I should have all the dudes animated and stuff by like tomorrow night or something. You rock for helping me!
hahahaha hey! i was just watching this show called "Through the Wormhole" with Morgan Freeman and there was this scientist trying to send messages back in time with lasers and hahahaha the one sending was Alice and the one recieving was Bob!! WTF is that why you named your .as files Bob and Alice???? haha it can't be a mere coincidence! did you send me this flash help from the future???
In cryptography and other fields, Alice and Bob are placeholder names. Usually the scenario involves passing messages. In cryptography, there is often a third person, Carol, who is trying to intercept a message from Alice to Bob.