Skip to main content
Participant
March 20, 2013
Answered

AS3: use buttons in external swf

  • March 20, 2013
  • 2 replies
  • 2539 views

Hi,

  

I am making a website in Adobe Flash that imports it´s navigation buttons from an external swf-file.

The problem is how my Main FLA-file will know which of the navigation buttons the users has pressed, since the buttons and it's eventListeners are in the external swf-file.

With other word: can I make my external swf-file return a Number to my website FLA-file, to determine which button that have been pressed? If so, how?

This topic has been closed for replies.
Correct answer kglad

here are the various was your two swfs can communicate: 

http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

2 replies

Inspiring
March 20, 2013

I had a similar problem thanks to Ned Murphy, I learned you can dispatch events which can communicate between .swf

(Generally speaking)

Main Movie:

yourObject.addEventListener("myEvent",theEvent);

function theEvent(e:Event):void{

//code here;

}

External .swf:

//attach to whatever needs to fire the event.

dispatchEvent(new Event("myEvent"));

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 20, 2013

here are the various was your two swfs can communicate: 

http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

Olof1984Author
Participant
March 20, 2013

Thanks for the link.

I still dont quite understand, could you show be an example?

If I from my FLA-file called Main want to get the variable pageNr from the swf-file Buttons, what should I write?

kglad
Community Expert
Community Expert
March 20, 2013

are you loading the navigation swf?  if yes, show the loader code.

are the navigation button listener functions on the navigation swf's main timeline?  if no, what timeline are they on relative to the main timeline.