How do I use the event.target.name String with an external dispatchEvent?
...I hope the title question makes sense... ![]()
On my stage I have an externally loaded SWF with a button. When clicked the button dispatches an event to the main stage.
On the main stage a listener then loads an SWF into a loader called gallery.
The gallery loader is also being shared by buttons on the main stage which use the event.target.name String to call in SWFs with corresponding names.
I am using Tweens to fade-out and -in content to the gallery when a button is pressed.
--
Loading the SWFs was working until I tried to create a universal button function for the dispatchEvent buttons...
The problem I have is that I don't know how to define the String to tell the newSWFRequest where to find the SWF when triggered by the external buttons.
(I may be doing this all wrong... but figured the best way to load an SWF on to the main stage from an external SWF was by using dispatchEvent??)
My code triggers the Event and the gallery loader fades out, but then it cannot find the new SWF:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
Please can someone help me understand the way to make the String point in the right direction? (I think the only errors are in bold below)
Code:
var myTweenIn2:Tween;
var myTweenOut2:Tween;
var nextLoadS2:String;
// Listen for external event dispatched from external btns
addEventListener("contactStage", btnClickExtrnl);
function btnClickExtrnl(e:Event):void {
nextLoadS2 = ?????
myTweenOut2=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,0.2,true);
myTweenOut2.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
}
// Btns Universal function
function tweenOutCompleteF2(e:TweenEvent){
myTweenOut2.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF2);
myTweenOut2=null;
var newSWFRequest:URLRequest = new URLRequest("swfs/" + nextLoadS2 + ".swf");
myTweenIn2 = new Tween(gallery, "alpha", None.easeOut, gallery.alpha, 1, 0.2, true);
gallery.load(newSWFRequest);
gallery.x = Xpos;
gallery.y = Ypos;
}
Thank you.