|
-
Loader permissions
Hi all,
I have a flash file that, for the most part, just loads other swfs with their own interaction code, etc. In the loaded swf (not the main one, the ones being loaded), I want to access some functions in the loading swf. However, in the Loader documentation, it says that the root object in the display list of the loaded swf is the swf itself, not the loading one (I have confirmed this with lots and lots of traces statements and loops... )
Does anyone have an idea of how this can be done? In psuedo code this is basically what I want:
function some_function() {
trace('here');
}
addChild(load_some_other_swf('other.swf'));
in other.swf:
my_loading_swf.some_function();
All swfs are in the same domain.
Thanks!
-Thomas
-
you need to do 2 things:
1. wait for it to load
2. use the content property of the loaded swiff
e.g.
you have a file called "loadee.swf". contents of loadee.swf has a function called "someFunc"
PHP Code:
function someFun(){
trace("yep.");
};
you want to load that and call someFunc from the loading document called "loader.swf". contents of loader.swf:
PHP Code:
var loader = new Loader();
var request = new URLRequest("loadee.swf");
loader.load(request);
var oncomplete = function(event){
event.target.content.someFunc();
};
loader.contentLoaderInfo.addEventListener("complete",oncomplete);
this.addChild(loader);
-
I was actually thinking about it going the other way (loadee calling a function in loader), but that did give me an idea...
For anyone in a similar situation, what I did, is when loadee loads, I call a function in loadee, passing in the stage of loader. I can then use that stage instance to do whatever I need. Works great.
Thanks for the inspiration!
-Thomas
-
The OOP way around that would be to dispatch an event from the loadee and listen to it in the loader...but if you have it working - no need to fix it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|