Copy link to clipboard
Copied
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?
here are the various was your two swfs can communicate:
http://kb2.adobe.com/community/publishing/918/cpsid_91887.html
Copy link to clipboard
Copied
here are the various was your two swfs can communicate:
http://kb2.adobe.com/community/publishing/918/cpsid_91887.html
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I made a simple Flash exemple:
Main.fla code:
import flash.display.MovieClip;
import flash.display.Loader;
var mcButtons:MovieClip;
var buttonsLdr:Loader = new Loader();
buttonsLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, buttonsLoaded);
buttonsLdr.load(new URLRequest("Buttons.swf"));
function buttonsLoaded(e:Event):void {
mcButtons = MovieClip(buttonsLdr.contentLoaderInfo.content);
buttonsLdr.contentLoaderInfo.removeEventListener(Event.COMPLETE, buttonsLoaded);
mcButtons.x = 20;
mcButtons.y = 2;
addChild(mcButtons);
}
Here are my code for Buttons.fla file:
var page:Number = 0;
b1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler1);
b2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2);
function fl_MouseClickHandler1(event:MouseEvent):void
{
page = 1;
}
function fl_MouseClickHandler2(event:MouseEvent):void
{
page = 2;
}
I have only 1 timeline in each FLA files.
EDIT:
I found a YouTube video that explaine LocalConnection function really well, so now I got it to work. (The youtube clipp can be found here: http://www.youtube.com/watch?v=bqxIPYJttjc).
Anyway, thanks all for trying to help me!
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
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"));
Find more inspiration, events, and resources on the new Adobe Community
Explore Now