Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Be able to pass variables to Flash #68

Closed
wants to merge 5 commits into from

2 participants

@magcius

Implements flashvars. Should fix #53.

extension/firefox/components/FlashStreamConverter.js
@@ -114,14 +133,15 @@ ChromeActions.prototype = {
var data = new Uint8Array(chunk.length);
for (var i = 0; i < data.length; i++)
data[i] = chunk.charCodeAt(i) & 0xFF;
- win.postMessage({callback:"loadFile", url: url,
+ win.postMessage({callback:"loadFile", url: url, params: params,
@yurydelendik Owner

this statement is called multiple times -- there is no point to pass params each time. Redesign API or send it only first time.

@magcius
magcius added a note

what about: initial "loadFile" call with URL and params, and each piece of data from then on is sent in a "fileData" event, with the chunk of data, loaded, and total.

@yurydelendik Owner

Sounds good. Add session id or some other identifier to the loadFile and fileData events -- we may load more than one file in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
src/flash/display/Loader.js
@@ -311,7 +311,8 @@ var LoaderDefinition = (function () {
var def = {
initialize: function () {
- this._contentLoaderInfo = null;
+ this.contentLoaderInfo = new flash.display.LoaderInfo;
@yurydelendik Owner

Not sure why the getter is removed. Initialize it here in _contentLoaderInfo and keep the simple getter to "signify" read-only nature of the property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yurydelendik

Please squash the commits into one.

@magcius

Which commits?

@yurydelendik

Which commits?

All in magcius:params branch

@magcius

Huh -- why? All of them are logical changes that stand on their own...

@yurydelendik

They all look like small step-by-step changes to fix simple issue #53.

@yurydelendik

How would I test the solution? Can you create a simple html/swf demo, e.g. in the examples folder?

@magcius

I wrote a simple example that calls trace() on all the flash vars it gets, and confirmed it worked in the inspector.

extension/firefox/components/FlashStreamConverter.js
@@ -144,7 +163,7 @@ ChromeActions.prototype = {
}
win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "close"}, "*");
} else if (xhr.readyState === 1) {
- win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "open"}, "*");
+ win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "open", params: params}, "*");
@yurydelendik Owner

This method is used not only for movie download. Loading of the other file don't params. Please use other way to transmit params than "loadFile".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/firefox/content/web/viewer.html
@@ -199,12 +199,8 @@
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
- movieUrl = flashParams.url;
- var movieArgs = flashParams.arguments;
- var isOverlay = flashParams.isOverlay;
- console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
- FirefoxCom.requestSync('loadFile', {url: movieUrl, sessionId: 0});
- if (isOverlay) {
+ FirefoxCom.requestSync('loadFile', flashParams);
@yurydelendik Owner

The extension needs sessionId field and there is no need to send flashParams back. Use {url: flashParams.url, sessionId: 0} instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yurydelendik yurydelendik commented on the diff
examples/inspector/inspector.js
@@ -90,13 +90,31 @@ var builtinPath = avm2Root + "generated/builtin/builtin.abc";
var libraryPath = avm2Root + "generated/shell/shell.abc";
var playerGlobalPath = "../../src/flash/playerGlobal.min.abc";
+function parseQueryString(qs) {
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
+ var key = kv[0], value = kv[1];
@yurydelendik Owner

value = decodeURIComponent(kv[1]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yurydelendik yurydelendik commented on the diff
examples/inspector/inspector.js
@@ -90,13 +90,31 @@ var builtinPath = avm2Root + "generated/builtin/builtin.abc";
var libraryPath = avm2Root + "generated/shell/shell.abc";
var playerGlobalPath = "../../src/flash/playerGlobal.min.abc";
+function parseQueryString(qs) {
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
@yurydelendik Owner

if param value will have extra = the value will be truncated, e.g. key=val=ue. It's better to use indexOf here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@yurydelendik yurydelendik commented on the diff
extension/firefox/components/FlashStreamConverter.js
@@ -64,6 +64,24 @@ function combineUrl(baseUrl, url) {
}
}
+function parseQueryString(qs) {
@yurydelendik Owner

same comments as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/firefox/content/web/viewer.html
@@ -220,11 +220,11 @@
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
movieUrl = flashParams.url;
- var movieArgs = flashParams.arguments;
+ var movieParams = flashParams.params;
@yurydelendik Owner

make movieParams global (similar to movieUrl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/firefox/content/web/viewer.html
((6 lines not shown))
var isOverlay = flashParams.isOverlay;
pauseExecution = flashParams.isPausedAtStart;
- console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
- FirefoxCom.requestSync('loadFile', {url: movieUrl, sessionId: 0});
+ console.log("url=" + movieUrl + ";params=" + uneval(movieParams));
+ FirefoxCom.requestSync('loadFile', {url: movieUrl, params: flashParams, sessionId: flashParams});
@yurydelendik Owner

remove params from here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/firefox/content/web/viewer.html
@@ -278,7 +278,7 @@
switch (args.topic) {
case "open":
subscription = new Subscription();
- parseSwf(movieUrl, subscription);
+ parseSwf(movieUrl, args.params, subscription);
@yurydelendik Owner

use global movieParams created above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
magcius added some commits
@magcius magcius Loader: Don't lazily init the contentLoaderInfo field
We use it almost immediately after we create it, so this makes
no sense.
0bca897
@magcius magcius extension: Rename some loader variables
Make naming consistent between components.
5723ee4
@magcius magcius extension: Use the "flashvars" attribute to grab params from
Embed parameters are not passed to the movie.
b3348c6
@magcius magcius Add support for passing movie params
In the case of the inspector, we simply use the entire query string
of the page if there's an "rfile" and pass it directly to the SWF.

In the case of the viewer, we parse the <embed>/<object> parameters.
We eventually may need to parse the query string after the src URL.
5fd02ed
@magcius magcius LoaderInfo: Add support for _getArgs
This is what's used; "get parameters" just calls this internally
and makes a copy.
f28d0f0
@yurydelendik

f28d0f0 is broken, replaced by 8feae58

Added examples at examples/external/params.html (see 6006dba): not all ways to pass parameters work as in flash player

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2013
  1. @magcius

    Loader: Don't lazily init the contentLoaderInfo field

    magcius authored
    We use it almost immediately after we create it, so this makes
    no sense.
  2. @magcius

    extension: Rename some loader variables

    magcius authored
    Make naming consistent between components.
  3. @magcius

    extension: Use the "flashvars" attribute to grab params from

    magcius authored
    Embed parameters are not passed to the movie.
  4. @magcius

    Add support for passing movie params

    magcius authored
    In the case of the inspector, we simply use the entire query string
    of the page if there's an "rfile" and pass it directly to the SWF.
    
    In the case of the viewer, we parse the <embed>/<object> parameters.
    We eventually may need to parse the query string after the src URL.
  5. @magcius

    LoaderInfo: Add support for _getArgs

    magcius authored
    This is what's used; "get parameters" just calls this internally
    and makes a copy.
This page is out of date. Refresh to see the latest.
View
24 examples/inspector/inspector.js
@@ -92,13 +92,31 @@ var builtinPath = avm2Root + "generated/builtin/builtin.abc";
var libraryPath = avm2Root + "generated/shell/shell.abc";
var playerGlobalPath = "../../src/flash/playerGlobal.min.abc";
+function parseQueryString(qs) {
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
@yurydelendik Owner

if param value will have extra = the value will be truncated, e.g. key=val=ue. It's better to use indexOf here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var key = kv[0], value = kv[1];
@yurydelendik Owner

value = decodeURIComponent(kv[1]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ obj[key] = value;
+ }
+
+ return obj;
+}
+
/**
* You can also specify a remote file as a query string parameters, ?rfile=... to load it automatically
* when the page loads.
*/
if (remoteFile) {
$('#openFileToolbar')[0].setAttribute('hidden', true);
- executeFile(remoteFile);
+ executeFile(remoteFile, null, parseQueryString(window.location.search));
}
function showMessage(msg) {
@@ -106,7 +124,7 @@ function showMessage(msg) {
$('#message')[0].parentElement.removeAttribute('hidden');
}
-function executeFile(file, buffer) {
+function executeFile(file, buffer, movieParams) {
// All execution paths must now load AVM2.
if (!state.appCompiler) {
showMessage("Running in the Interpreter");
@@ -130,7 +148,7 @@ function executeFile(file, buffer) {
} else if (file.endsWith(".swf")) {
createAVM2(builtinPath, playerGlobalPath, sysMode, appMode, function (avm2) {
function runSWF(file, buffer) {
- SWF.embed(buffer, $("#stage")[0], { onComplete: terminate, onBeforeFrame: frame });
+ SWF.embed(buffer, $("#stage")[0], { onComplete: terminate, onBeforeFrame: frame, movieParams: movieParams || {} });
}
if (!buffer && asyncLoading) {
var subscription = {
View
26 extension/firefox/components/FlashStreamConverter.js
@@ -64,6 +64,24 @@ function combineUrl(baseUrl, url) {
}
}
+function parseQueryString(qs) {
@yurydelendik Owner

same comments as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
+ var key = kv[0], value = kv[1];
+ obj[key] = value;
+ }
+
+ return obj;
+}
+
// All the priviledged actions.
function ChromeActions(url, params, referer, window) {
this.url = url;
@@ -78,7 +96,7 @@ ChromeActions.prototype = {
getPluginParams: function getPluginParams() {
return JSON.stringify({
url: this.url,
- arguments: this.params,
+ params: this.params,
isOverlay: this.isOverlay,
isPausedAtStart: this.isPausedAtStart
});
@@ -248,10 +266,8 @@ FlashStreamConverterBase.prototype = {
tagName = element.nodeName;
}
if (tagName == 'EMBED') {
- for (var i = 0; i < element.attributes.length; ++i) {
- params[element.attributes[i].localName] = element.attributes[i].value;
- }
- url = params.src;
+ params = parseQueryString(element.getAttribute('flashvars'));
+ url = element.getAttribute('src');
} else {
for (var i = 0; i < element.childNodes.length; ++i) {
var paramElement = element.childNodes[i];
View
12 extension/firefox/content/web/viewer.html
@@ -231,10 +231,10 @@
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
movieUrl = flashParams.url;
- var movieArgs = flashParams.arguments;
+ movieParams = flashParams.params;
var isOverlay = flashParams.isOverlay;
pauseExecution = flashParams.isPausedAtStart;
- console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
+ console.log("url=" + movieUrl + ";params=" + uneval(movieParams));
FirefoxCom.requestSync('loadFile', {url: movieUrl, sessionId: 0});
if (isOverlay) {
var fallbackDiv = document.getElementById('fallback');
@@ -274,7 +274,7 @@
}
};
- var subscription = null, movieUrl;
+ var subscription = null, movieUrl, movieParams;
addEventListener("message", function handlerMessage(e) {
var args = e.data;
@@ -289,7 +289,7 @@
switch (args.topic) {
case "open":
subscription = new Subscription();
- parseSwf(movieUrl, subscription);
+ parseSwf(movieUrl, movieParams, subscription);
break;
case "progress":
subscription.send(args);
@@ -337,11 +337,11 @@
}
};
- function parseSwf(url, file) {
+ function parseSwf(url, params, file) {
console.log("Parsing " + url + "...");
function terminate() {}
createAVM2(builtinPath, playerGlobalPath, EXECUTION_MODE.INTERPRET, EXECUTION_MODE.COMPILE, function (avm2) {
- SWF.embed(file, document.getElementById("viewer"), { onComplete: terminate, onBeforeFrame: frame });
+ SWF.embed(file, document.getElementById("viewer"), { onComplete: terminate, movieParams: params, onBeforeFrame: frame });
});
}
2  lib/xstats
@@ -1 +1 @@
-Subproject commit a2d6191efc519d7e507268ca7199f007d92f9c80
+Subproject commit 477d2a0f254ae66f663b0fac0ffbf47dfab6a3e3
View
12 src/flash/display/Loader.js
@@ -349,7 +349,8 @@ var LoaderDefinition = (function () {
var def = {
initialize: function () {
- this._contentLoaderInfo = null;
+ this._contentLoaderInfo = new flash.display.LoaderInfo;
+ this._contentLoaderInfo._loader = this;
this._dictionary = { };
this._displayList = null;
this._symbols = { };
@@ -896,14 +897,7 @@ var LoaderDefinition = (function () {
},
get contentLoaderInfo() {
- // XXX: Why is this lazily initialized?
- var loaderInfo = this._contentLoaderInfo;
- if (!loaderInfo) {
- loaderInfo = new flash.display.LoaderInfo;
- loaderInfo._loader = this;
- this._contentLoaderInfo = loaderInfo;
- }
- return loaderInfo;
+ return this._contentLoaderInfo;
},
close: function () {
View
96 src/flash/display/LoaderInfo.js
@@ -17,6 +17,7 @@ var LoaderInfoDefinition = (function () {
this._url = null;
this._width = null;
},
+
__glue__: {
native: {
static: {
@@ -26,8 +27,7 @@ var LoaderInfoDefinition = (function () {
},
instance: {
_getArgs: function _getArgs() { // (void) -> Object
- somewhatImplemented("LoaderInfo._getArgs");
- return [];
+ return this._getArgs();
},
_getUncaughtErrorEvents: function _getUncaughtErrorEvents() { // (void) -> UncaughtErrorEvents
notImplemented("LoaderInfo._getUncaughtErrorEvents");
@@ -157,7 +157,97 @@ var LoaderInfoDefinition = (function () {
"bytesTotal",
"bytesLoaded"
])
+
+ get actionScriptVersion() {
+ return this._actionScriptVersion;
+ },
+ get applicationDomain() {
+ notImplemented();
+ },
+ get backgroundColor() {
+ return this._backgroundColor;
+ },
+ get bytes() {
+ return this._bytes;
+ },
+ get bytesLoaded() {
+ return this._bytesLoaded;
+ },
+ get bytesTotal() {
+ return this._bytesTotal;
+ },
+ get childAllowsParent() {
+ notImplemented();
+ },
+ get childSandboxBridge() {
+ notImplemented();
+ },
+ set childSandboxBridge(val) {
+ notImplemented();
+ },
+ get content() {
+ return this._content;
+ },
+ get contentType() {
+ return this._contentType;
+ },
+ get frameRate() {
+ return this._frameRate;
+ },
+ get height() {
+ return this._height;
+ },
+ get isURLInaccessible() {
+ notImplemented();
+ },
+ get loader() {
+ return this._loader;
+ },
+ get loaderURL() {
+ return this._loaderURL;
+ },
+ get parentAllowsChild() {
+ notImplemented();
+ },
+ get parentSandboxBridge() {
+ notImplemented();
+ },
+ set parentSandboxBridge(val) {
+ notImplemented();
+ },
+ get sameDomain() {
+ notImplemented();
+ },
+ get sharedEvents() {
+ notImplemented();
+ },
+ get swfVersion() {
+ if (!this._swfVersion)
+ throw Error();
+
+ return this._swfVersion;
+ },
+ get uncaughtErrorEvents() {
+ notImplemented();
+ },
+ get url() {
+ return this._url;
+ },
+ get width() {
+ return this._width;
+ },
+
+ getLoaderInfoByDefinition: function () {
+ notImplemented();
+ },
+
+ _getArgs: function() {
+ var params = this._parameters;
+ var mangled = {};
+ for (var k in params) {
+ mangled[Multiname.getPublicQualifiedName(k)] = params[k];
}
+ return mangled;
}
};
-}).call(this);
+}).call(this);
View
1  src/swf/embed.js
@@ -6,6 +6,7 @@ SWF.embed = function(file, container, options) {
var stage = new flash.display.Stage;
stage._loader = loader;
+ loaderInfo._parameters = options.movieParams;
// HACK support of HiDPI displays
var pixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1;
Something went wrong with that request. Please try again.