Problem with ExternalInterface with electron


#1

Hello guys,

I have problem with electron 1.6.8 and pepperflash 25 version both are 64 Bit
index.html




Hello World!

            webview {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            width:100%;
            height:100%;
          }
        </style>
      </head>
      <body>
        <!--<webview src="http://www.adobe.com/software/flash/about/" plugins></webview>-->
        <webview src="BrowserExternalInterface.html" plugins></webview>
      </body>

      <script>
        // You can also require other files to run in this process
        require('./renderer.js')
      </script>
    </html>

main.js
const electron = require(‘electron’)
const app = electron.app
const BrowserWindow = electron.BrowserWindow

const path = require('path')
const url = require('url')
let mainWindow
function createWindow () {
  mainWindow = new BrowserWindow({width: 800, height: 600, webPreferences: { plugins: true }})
  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }))

  mainWindow.on('closed', function () {
    mainWindow = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.commandLine.appendSwitch('ppapi-flash-path', 'pepflashplayer64_25_0_0_148.dll')
app.commandLine.appendSwitch('ppapi-flash-version', '25.0.0.148')

app.on('activate', function () {
  if (mainWindow === null) {
    createWindow()
  }
})

BrowserExternalInterface.html made by OpenFL I have changed to nw-flash-trust

	<head>
		
		<title>Browser External Interface</title>
		
		<script>
			

			function testMessage()
			{
				 document.getElementById('log').innerHTML += 'Some new content!';
			}
		
			try {
				
				var assert = require('assert');
				var path = require('path');
				
				var flashTrust = require('..');
				var trustManager = flashTrust.initSync('electron-quick-start');
				
				var appPath = path.dirname(process.execPath);
				var trustedPath = path.join(appPath, 'TestExternalInterface.swf');
				
				trustManager.empty();
				
				assert.equal(trustManager.isTrusted(trustedPath), false);
				assert.equal(trustManager.list().length, 0);
				
				trustManager.add(trustedPath);
				
				assert.equal(trustManager.list().length, 1);
				assert.equal(trustManager.isTrusted(trustedPath), true);
				assert.equal(trustManager.isTrusted(notTrustedPath), false);
				
				trustManager.remove(trustedPath);
				
				assert.equal(trustManager.isTrusted(trustedPath), false);
				assert.equal(trustManager.list().length, 0);
				
				console.log('All tests pass.');
				
			} catch (err) {
				console.log(err);
				console.log(err.stack);
			}
		
	</script>
		
	</head>
	
	<body>
		
		<object width="500" height="400">
		<param name="movie" value="TestExternalInterface.swf" />
		<param name="height" value="400" />
            <param name="width" value="500" />
            <param name="quality" value="high" />
            <param name="menu" value="false" />
            <param name="allowscriptaccess" value="always" />
	</object>
		<div id="log">initial content</div>
	</body>
	
</html>

TestExternalInterface.as into swf:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
import flash.system.Security;
import flash.text.TextField;

	import org.apache.flex.promises.vo.Handler;
	
	public class TestExternalInterface extends Sprite
	{
		private var _tf:TextField;
		private var _sprite:Sprite;
		
		public function TestExternalInterface()
		{
			Security.allowDomain("*");
			
			_tf = new TextField();
			_tf.x = _tf.y = 20;
			_tf.width = 400;
			addChild(_tf);
			
			_sprite = new Sprite();
			_sprite.graphics.beginFill(0xFF8800, 1);
			_sprite.graphics.drawRect(20, 50, 100, 40);
			_sprite.graphics.endFill();
			addChild(_sprite);
			_sprite.addEventListener(MouseEvent.CLICK, handleMouseClick);
			
			if(ExternalInterface.available)
			{
				_tf.text = "ExternalInterface is supported.";
			}else{
				_tf.text = "ExternalInterface is not supported.";
			}
		}
		
		private function handleMouseClick(me:MouseEvent):void
		{
			ExternalInterface.call("testMessage");
		}
	}
}

I already tried but it doesn’t work why does externalinterface not call or invoke?
But it shows externalinterface is supported. It is real. but won’t work to call. How do I fix… Where is unsandboxed of main.js I don’t know how do I force allow to externalinterface if I use flash-content is enabled? or I need add commandlione flash enabled = true?

How do I resolve? Thanks!


#2

No any answers? If you don’t know - How do I fix?

Is it possible working for ipcMain and ipcRenderer? I have any solutions. But it doesn’t work? If it has bug?