Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Launching and Communicating Between 3 or 4 swfs on Separate Displays

Community Beginner ,
Sep 08, 2016 Sep 08, 2016

I'm doing some experiments in potential courseware viewers. I'm trying to figure out if Flash is a viable option, either as standalone or embedded in a webpage.

In a nutshell, I want to be able to launch up to 3 additional swfs, each being displayed on its own monitor (for a total of up to 4 monitors each displaying a unique swf). Additionally, I need these swfs to be able to communicate back and forth.

Is this something that seems possible?

I remember looking at some code a while ago that dealt with AS3's LocalConnection, and it seems like this might be the way to go.

Any ideas/suggestions/warnings?

TOPICS
ActionScript
333
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 15, 2016 Sep 15, 2016

use:

In slave1:

var masterInboundConnection:LocalConnection = new LocalConnection(); 

masterInboundConnection
.allowDomain("*");
masterInboundConnection
.connect("masterToSlave1Connection");
masterInboundConnection.client=this;

function
UpdateTextFromCommunication(receivedArguments){
displayText
.text = receivedArguments;
}
Translate
Community Expert ,
Sep 08, 2016 Sep 08, 2016
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 15, 2016 Sep 15, 2016

Thanks for this. I've tried following the information at this location, but can't seem to get it working. Maybe I'm doing something wrong, or maybe my understanding of how LocalConnection is intended to be used is wrong.

Maybe you could help?

Here is some more info:

Essentially, I have 3 swfs. I have one 'master' swf, and two 'slave' swfs. When the master swf is launched (inside a webpage), it opens both other swfs in new windows. When a button is clicked in the master, I'm trying to just update some text in one of the slaves. More complicated stuff will happen later, I'm just trying to figure out LocalConnections first.

The code (on the timeline) in 'master.swf':

import flash.net.URLRequest; 
import flash.events.Event; 
//Used as a flag to open each slave window, one of the first frame, one on the second frame, as using
//navigateToURL twice in a row doesn't seem to work.

var frameCount = 0; 
//This is what I'm attempting to send over the LocalConnection.
var messageText = "it worked!"; 

var
slave1url:URLRequest = new URLRequest("slave1.html");
var slave2url:URLRequest = new URLRequest("slave2.html"); 

var slave1OutboundConnection:LocalConnection = new LocalConnection(); 
this.addEventListener(Event.ENTER_FRAME, Update); 

slave1Button
.addEventListener(MouseEvent.CLICK, SendMessageToSlave1);

slave1Button
.buttonMode = true; 

//Send a message to slave1 via the slave1OutboundConnection

function SendMessageToSlave1(e:Event){
     slave1OutboundConnection
.send("masterToSlave1Connection", "UpdateTextFromCommunication", messageText);
} 

function
Update(e:Event){ 
//Open the slave1 page on the first frame, and the slave2 page on the second frame.
      if(frameCount == 0){
           navigateToURL
(slave1url, "_blank");
           frameCount
++; }
      else if (frameCount == 1){
           navigateToURL
(slave2url, "_blank");
           frameCount
++;
      } 
}

In slave1:

var masterInboundConnection:LocalConnection = new LocalConnection();  

masterInboundConnection
.allowDomain("*"); 
masterInboundConnection
.connect("masterToSlave1Connection");

function
UpdateTextFromCommunication(receivedArguments){
      displayText
.text = receivedArguments;
}

I've also got a little bit of custom javascript in each html page to set page size and position, but I don't think that should matter:

<script> 
   //Get the width of the user's monitor
   var resolutionWidth = window.screen.availWidth; 

   //Get the height of the user's monitor (minus the height of the task bar)

   var resolutionHeight = window.screen.availHeight; 
   //First screen is 0, second is 1, third is 2, etc.
   var screenNumber = 2; 
   //If this screen is not displayed on the primary monitor, add 40 pixels for the lack of the taskbar on other monitors
   if(screenNumber > 0){
      resolutionHeight
+= 40;
   } 

   //Maximize the window

   this.resizeTo(resolutionWidth, resolutionHeight); 

   //Move the window to the appropriate display

   this.moveTo(resolutionWidth * screenNumber, 0);
</script>

When I click the button that's supposed to trigger the communication, nothing appears to happen.

I'm running the html pages containing these swfs in IE11 on a localhost xampp server on Windows 7. Swfs made in CS5.5.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 15, 2016 Sep 15, 2016

use:

In slave1:

var masterInboundConnection:LocalConnection = new LocalConnection(); 

masterInboundConnection
.allowDomain("*");
masterInboundConnection
.connect("masterToSlave1Connection");
masterInboundConnection.client=this;

function
UpdateTextFromCommunication(receivedArguments){
displayText
.text = receivedArguments;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 15, 2016 Sep 15, 2016

Awesome, thanks a ton!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 15, 2016 Sep 15, 2016
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines