ActionScript 2.0 :: Pass Flash Array To Javascript Function Without Using Json?
Oct 28, 2009How do I pass flash array to javascript function without using json?
View 3 RepliesHow do I pass flash array to javascript function without using json?
View 3 RepliesIs it possible to pass an ArrayCollection object from flex ExternalInterface.call() as a parameter to javascript function?
[Code]...
I need to call a function in JS that's expecting a JSON object. Can I do this from External Interface? The company's example (after the include file url) in HTML looks like this:
//there's an js include URL earlier//
Shopwithme.Initialize({
"id":"prod1234",
[code]...
But, I need to dictate these vars through Flash. How do I call this function using External Interface?This is my EI code, but I'm obviously off base, since it's not working:
ExternalInterface.call("Shopwithme.Initialize",[{ "id":"prod1234",
"type":"2","URL":"http://www.somelink.com"}]);
What do I need to do to call this javascript?
I am attempting to get Flash - Javascript communication working using ExternalInterface.addCallback, using code found at http:[url].... I am trying to pass parameters into Flash using a javascript function, but it only works if I insert a 'window.alert' line into the code. Once I click OK, the parameter str is passed into Flash ok. The function is:
function sendToFlash(str) { if (str=="tools"){ window.alert(str); getFlashMovie("richFunctionality_corp").sendTextToFlash(str);[code]....
If I remove the window.alert, str isn't passed into Flash. Is this a browser speed thing? A value menu is passed out of Flash using getURL("index.php?pageID=239&menu=tools"), i.e. the page reloads and a php script sends the appropriate str value to the sendToFlash javascript function based upon the value of menu.
I think this is fairly straight forward but my skills lie in JavaScript and Ruby rather than flash so I want to run this past a few other minds :) I have a flash file that will take pictures of the user via their web cam. I want to take that newly created image, base64 encode it then pass it to a JavaScript function. That JavaScript function will essentially take this data then embed it into a hidden form element on the page.
[Code]...
How To Run A Shadowbox Gallery From A Flash getUrl function Call..
This Is What I Have In My Flash:
btn1.onRelease = function() {
getURL("javascript:MyGallery([page1,app1]);", "_self");
}
I want to be able to declare my arguments in flash like so
var page1 = {
title: 'Google',
player: 'iframe',
[Code].....
I have a pure ActionScript 3 problem, but the simplified test case I've prepared is in Flex 4 for better visibility (the source code is below): Since Flash Player 11 / AIR 3 support JSON natively, I've decided to move a multiplayer game, which used XML for communicating with server, to JSON. But I have a frustrating problem, that given two Objects like
[Code]...
What is the best way to pass JSON to and from a Flash movie?Currently to communicate between javascript and Flash :I'm using 'flashvars' to pass data to the flash movie when it initially loads I'm using 'ExternalInterface' at runtime to transfer single values, such as booleans at runtime I want to move to the next level and do this with JSON now.
Initially I just want the ability to send JSON to the flash movie on instantiation, but later i will need to send data back and forth.I just want to do it right first time and avoid any compatibility or 'gotcha' issues if there are any. i dont even know if i can pass a whole object to Flash, or if i need to serialize it as a raw JSON string.
Can any one provide me with an example of how to encode data and pass it to a php file using JSON and flash?
View 1 RepliesI have read a lot about parsing JSON with Actionscript. Originally it was said to use this library. [URL] but it seems Flash Player 11 has native support for it now. My problem is that I cannot find examples or help that takes you from beginning to end of the process. Everything I have read seems to start in the middle. I have no real experience with JSON so this is a problem. I don't even know how to point ActionScript to the JSON file it needs to read.
I have a project with a tight deadline that requires me to read twitter through JSON. I need to get the three most recent tweets, along with the user who posted it, their twitter name and the time those tweets were posted.
The back end to this is already set up I believe by the development team here, therefor my JSON files or XML just needs to be pointed to and then I need to display the values in the interface text boxes I have already designed and created.
note: using django/python/javascript/flash So its been two days since I'm stuck at the error. I did the things you told me to and found a couple of ways around it but nothing worked. These are the results.Javascript does not receive the normal string it has to be a json object so. in views.py
somestring = json.dumps("HELLO WORLD")
which renders this in HTML
"HELLO WORLD"
and in javascript it is rendered like this
a240527176321_quote_hello
Now, since it is a json object I need to convert it back in flash. But when it gets in flash where I receive it like this
function something(hellovar){
.....
......
}
it does not even come inside the function.
I want to be able to call a JavaScript function from a Flex app using ExternalInterface and pass a reference to a different JavaScript function as an argument.
[Code]....
I'm trying to call a function in frame 1 of my SWF and also pass it a parameter.
I need to do this from elsewhere on the embedding HTML page using JavaScript.
For example call the function flashFunction(foo);
Does this require a listener in Flash that listens for the call, excepts "foo" and then calls the flashFunction and passes "foo" to it?
Can this be called directly without a listener?
I've ran into a weird problem while trying to send a JSON command to my company's flash player. Basically, i am unable to pass a playlist to this player - nothing happens - using the following command:
player.sendEvent("LOAD_PLAYLIST", json_str);
but the weirdest part is that if I print the entire command using Firebug's console.log, copy it and paste it into the code (thus hardcoding the playlist), everything works like a charm.
For instance, the following code:
player.sendEvent("LOAD_PLAYLIST", "{"streams": [{"src": "rtmp://xxx.xxx.xx:80/redirectvodxxx/nas2.share/h264/512x384/progname1/prog_1_20110804.mp4"},{"src": "rtmp://xxx.xxx.xx:80/redirectvodxxx/nas2.share/h264/512x384/progname2/prog_2_20110804.mp4"},{"src": "rtmp://xxx.xxx.xx:80/redirectvodxxx/nas2.share/h264/512x384/progname3/prog_3_20110804.mp4"}]}");
was obtained using
console.log('[loadNewListofContents] playing the following content list: player.sendEvent("LOAD_PLAYLIST", ' + json_str.toString() + ');');
and if i hardcode it, it works!I've tried all the toString() tricks I can think of (ex: json_str.toString(), '"' + json_str.toString() + '"', etc...) but so far no such luck.
Is it possible to pass the contents of an array to JavaScript code which then creates a text file on the local machine?
View 10 RepliesI have a function call as shown here: ActionScript Code:c.draw(colorRead.population); In this function, I would like it to be able to print out population as part of the string for my toolTip. Note, what is in the parameter here may not be the case in every of the instance I need to create.
[Code]...
In AS2 I have several arrays constructed like this :
var myArray0:Array=new Array(value,value,value...)
var myArray1:Array=new Array(value,value,value...)
var myArray2:Array=new Array(value,value,value...)
var myArray4:Array=new Array(value,value,value...)
...
What I'm trying to do is use iteration to reference each array name to pass it into a function.
Like :
function doSomethingWithArray(arrayToPass){
...
}
//Later somewhere in For loop... :
_root["myButton"+i].onRelease=function(){
doSomethingWithArray(WHAT-THE-HELL-I-TYPE-HERE[i])
}
I'm facing a problem with passing variables from array to function. [code]
View 2 RepliesI'm trying to access a nested json array
var jsonResponse:Object = JSON.decode(response);
var foo:Object = JSON.decode(jsonResponse.nested);
var bar:Array = foo as Array;
When i inspect foo - its an object with about 50 children objects.I can read the properties of the children objects. However, when i cast foo as an Array it comes back null.I'd prefer to not iterate over each object and push it into an array.
I'm working with arrays in AS3 and some of the utility functions described in the livedocs such as filter() or some() would be very useful to me, if only I could pass parameters to them...
Actually, I cannot find a single example of the use of these functions with custom parameters passed to their callbacks. Everywhere, it is always used with constants ! E.g. on this page: [URL]
var arr:Array = new Array();var totalElements:uint = 100;for(var i:uint = 0; i<totalElements; i++) { arr[i] = Math.round(Math.random()*100);}function isLargerThan90(element:*, index:int, arr:Array):Boolean { return element > 90;}var highestNumbers:Array = arr.filter(isLargerThan90);trace(highestNumbers);
What I need is a kind of "isLargerThan" function with "90" as an argument's value, not as a constant. Something like
function isLargerThan(element:*, index:int, arr:Array, param:Object):Boolean { return element > (param as Number);}I find it very odd that I cannot find no mention of the way to do this on the whole WWW, because that makes these utility functions absolutely helpless in many many cases and programming with arrays a real pain...
I'm making multiple similar calls with similar results to one remote object. Because these calls are so similar and very changeable, I've been keeping the name of the remote method in a config file, and when I need to make the call I use getOperation() on the remote object, and call send() on the operation object. However, the requirements have changed so that not all of the calls will have the same number of parameters. Because send uses ..., will I be able to continue using the same formation and pass an array, or will send() treat that as passing one argument of type array?
View 2 Repliesi want to pass multidimensional array as parameters to a function.
i tried this.
sort(number);
function sort(num: Array):void;
I have an array with some values and i want to pass this values to a function arguments.
example
var theArray:Array = new Array("test1","teste2","teste3");
function hello(t:Number,a:Array){
// do something
test(a)
[Code]....
In AS2 I have several arrays constructed like this :
var myArray0:Array=new Array(value,value,value...)
var myArray1:Array=new Array(value,value,value...)
var myArray2:Array=new Array(value,value,value...)
var myArray4:Array=new Array(value,value,value...)
...
What I'm trying to do is use iteration to reference each array name to pass it into a function.
[Code]...
I have this swf (flash) file that provides the json that needs to be sent to the server.[code]...
Of course I can pass the json as a string to the view function. Doesn't seem good to me. Any other way of passing the json object to the django view?
I have a very odd problem with Flash 10 and ExternalInterface. I am currently using a homemade bridge to use RTMFP with Javascript and whenever I try to pass data that contains JSON, I get a wierd Javascript error that comes from Flash[code]...
View 2 RepliesI have flash application, which creates array and calls javascript function.[code]My question is how to pass params from actionscript to javascript as array and not as string value.
View 2 RepliesI'm working on a Flash AS2 application that needs to post JSON data to a web service.In previous projects, I've used LoadVars.send() or LoadVars.sendAndLoad() successfully to manage this:
var send_lv:LoadVars = new LoadVars();
send_lv.data = JSON.stringify({some json object});
var response_lv:LoadVars = new LoadVars();
response_lv.onData = function(rawdata) {
[code]....
In somepage.php, I can grab that JSON data using $_POST['data'].However, on this project, the developer of the web service requires the JSON content to be the BODY of the request (i.e., not a name/value pair). Is this possible with LoadVars?
I'm making numerous ExternalInterface calls to JavaScript methods and have a helper function for doing so:
[Code]...
However this means the JavaScript method will only be passed one argument - the array of arguments - meaning I have to change the JavaScript to accomodate this, e.g. instead of:
[Code]...
I am trying to get javascript to call a function in ActionScript and store the returned array. I have looked everywhere for help and i cant seem to get this to work. My actionscript is below:
import flash.display.Sprite;
import flash.text.Font;
import flash.text.FontType;[code].....
There is a getDeviceFonts() method that works, and the .call function works too, calling the function within the javascript. However, when i try and call the getFonts method in javascript it dosent work. Relavent Javascript is as below:
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];