I know this must be really simple, but I’m stuck in that and I need to finish 10 other thousand things for today…
I’m trying to access a function that’s on the document class, from a loaded swf.
I load an external banner, and when the banner has finished playing I want to call a function.
I’m trying:
myfunction();
this.stage.myfunction();
this.parent.myfunction();
with no luck…
Thanks
I think what you are trying to do can be accomplished another way with event listeners.
On the last frame in the banner:
[AS]dispatchEvent(new Event(“imDone”));[/AS]
In the container swf:
[AS]_banner.addEventListener(“imDone”, onBannerDonePlaying);
private function onBannerDonePlaying(e:Event):void {
// remove the banner and continue.
}[/AS]
I already solved it by using exactly the same approach you suggest.
Thanks anyway
i’m not having any luck with this method…
i am trying to call a function during a MouseClick event.
inside seperate button class:
public function takeSnapshot():void{
dispatchEvent(new Event("snapshotTaken"));
}
inside my Main class/swf:
object.addEventListener("snapshotTaken", execute);
private function execute(e:Event):void{
e.target.functionOfObject();
}
button.addEventListener(MouseEvent.CLICK, clicker);
private function clicker(e:MouseEvent):void{
e.target.takeSnapshot();
}
What if you try e.currentTarget?
Felixz
June 4, 2008, 12:01am
7
the difference is only in bubbling phase.
currentTarget is always am object which has the listener,
target is an object dispatching an event