ActionScript 3.0 :: Passing Objects Into Flash From JS?
May 12, 2011Can you pass an Object into flash from a button click instead of a String?
View 2 RepliesCan you pass an Object into flash from a button click instead of a String?
View 2 RepliesSo i a building a categorized menu of different foods. I have a class for "categories" (buttons) which essentially will return a string "salads", "drinks", etc. I now have another class "menuItems" for items within categories and this handles sizes such as "small", "med", "large", etc. My problem now is that when i return "salads", i want to invoke an array which contains all the elements of salads, send it to menuItems which will populate the menu. So far i have both the category objects and the menu object setup. I just cant seem to be able to send the data that the category object is returning and pass it to the menu object. Both of which are added to the stage as shown below:
If there was a way that i could say add all these classes to one class so that they can talk to each other that would be great but i dont know how to do this.
I have a object, called friends, It contains the url to facebook profile picture, ie friends.friend1 = "http:// etc"; I have a swf file called, master.swf, which is passed the information to create the object through flashvars. I need to get the object OR the flashvars info to the externally loaded swf, called pageOne.swf. I have seen and tried several different methods, but now seem to give me what I need.
[Code]...
I'm passing a Javascript Array() to Flash via FlashVars but Flash complains. Can you guys point me what am I doing wrong here?
javascript code
// array with the user defined cities
var usercities = new Array(
[code]......
I am using PHP to save an AS3-generated XML document to my server. This works absolutely fine. Now, I'd like to be able top pass a filename along with my URLRequest under which the file would be saved.
When doing this in HTML it would be pretty easy and I would simply POST 2 seperate values, but how to do this in AS3?
is it possible to send native nested objects to flash via swfobject? i am trying this right now without luck:
PHP Code:
var flashvars = {event1:{eventid:"145",title:"event 1",toggle:["thistha","timestart"]},
event2:{eventid:"145",title:"event 1",toggle:["thistha","timestart"]},
event3:{eventid:"145",title:"event 1",toggle:["thistha","timestart"]}}
[Code].....
Is there a way I can pass complex objects like sprites or timers through LocalConnection? It seems like you can naively pass simple objects like String, Number, Array thru the LocalConnection. But I can't seem to send other data types.I read that you have to use the method "registerClassAlias()" within the receiving SWF file before that SWF file can accept complex objects. For example, when I attempt to send instances of Sprites or Timers, I get the following error:
"Error #2044: Unhandled AsyncErrorEvent:.text=Error #2095:flash.net.LocalConnection was unable to invoke callback sendState.error=TypeError: Error #1034: Type Coercion failed: cannot convert Object@b9210b1 to flash.utils.Timer."
How can I send complex data types or are some data types not send-able?
When invoking super() in my subclass, I can pass uints and strings as params to super, but passing a TextField instance that is on the stage of the library instance of the subclass fails. Why? Is there a workaround?
View 2 RepliesI'm trying to pass the stage display container too my Engine class but I'm getting the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.olly::Engine()
at com.olly::MainControl()
Here's the code:
I'm creating the the Engine in the main document class here:
Code:
public var MainGame:Engine;
public function MainControl() : void
{
MainGame = new Engine(stage);
[Code].....
I have created a Component class and it's working fine .I want to pass an ArrayCollection of Objects to the Component .I have read in many articles , that we should use [Bindable] to make an ArrayCollection of Objects .What are the ways can we achieve that ?
View 2 RepliesSo I try to send 1.the PDF 2. the message 3. the email-address to a PHP-Script. It works, but somehow my PDF always get garbled and is not a valid document.I transmit my things like:
Code:
var emailURLReq:URLRequest = new URLRequest('pdf/email.php');
var emailVars:URLVariables = new URLVariables();
[code].....
I wrote a code for handling google maps in a multi touch table. On the map itself, I have a sort of button that, if touched, makes a tool bar show up. On the bar I have a slider and a button, both of them activated by touch events. My problem here is that when I touch objects on the bar, the touch event pass through the bar and it is fired also on the map below, making my map move. Uff, this is very annoying.
View 1 Repliesim trying this every which way.creating global variables etc.I have a movie clip with a text area (lets call it txttest)there is text inside it which i want to send from this movieclip on the main frame to a text area (lets call that one txttestB) on the main frame. Whatever i try i get undefined in the text area on the main frame.I have tried this...
_global.selectedcompany = txttest.text;
_root.txttestB.text = _global.selectedcompany;
I'm having troubles activating the HitTest, passing the objects name as a parameter through a global function. Let's say there is the following function on the main timeline:
[Code]...
Internally Flash obviously keeps a list of the primitives drawn using Graphics so I wondered if you have many such primitives in a Sprite, can you re-position/remove/alter individual items rather than clear and re-draw everything? Or is this deeper into the bowels of Flash than you're allowed (or recommended) to go?
View 4 RepliesIs this the correct, most efficient way to recycle objects when creating an array of objects?
package com {
public class CreateList extends MovieClip {
//this is the object I will be recycling
private var newProperty:PropertyRow;
//this is the array I will use to reference the objects
[Code]...
1) Passing a control itself as parameter into a function 2) Passing an id ( managed manually) of the control as a parameter into a function . Say for an array of controls I have ctrl_Array = [ my_btn, my_mc, my_dtg ] and corresponding id_Array[0,1,2] PS: If my question is difficult to understand, i just wanna know, if it is a good programming practice to pass control references among the classes as function parameters ?
View 1 Replieswhen it comes to using php to pass xml items to flash. Could someone point me in the right direction?i have this xml setup that works fine when pulling in images:
images.xml
<xml>
<image>
[code].....
Creating a flash project where users can visit the site, and turn off/on objects in a house (ie. lights, tv, computer, etc.) The next user who will visit the house in the website, will see what lights or house appliances were left on. Flash variables are passed to PHP, and those variables are saved in an XML file. (For testing to see what is being saved to the XML file, on each click --vars.xml opens.) In the vars.xml file, I see that the house objects that were last turned on--are saved in the XML file- But in the SWF file, only one of the objects that are listed in the XML are turned ON. Only the last object that was clicked on would show ON--not all the objects in the XML file.)
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.*;
import flash.net.*;
public class House extends MovieClip {
[Code] .....
Can I pass values from fla to AS3. Example I have fla file where the xml faile loaded. Now I want to make button "Button 1" and "Button 2" now if I press the button it sent to AS3 values/variables.
private var xmlURL:String = "xml/Button1.xml";
After buttone 2 is pressed is
private var xmlURL:String = "xml/Button2.xml";
I'm trying to pass the file name of an image upload PHP script into Flash's UILoader component. So when a user uploads their image, the file name of the file is passed to flash so that the image displays within the Flash UILoader application. Here's the PHP variable I'm trying to pass: $filename= ''; And here's where Flash's UILoader gets it's source (ActionScript 3.0): uiLoader.source = "freshly uploaded file.jpg ($filename)?";
View 1 RepliesIs there a way that I can pass the value of app: or appstorage: to a javascript file which has been included via URLRequest? I have a web application with an HTML5 video player, and I've been asked to get it to work as an AIR app. So far so good, except that there is a bug in jPlayer that requires you to use absolute file paths for media if you're using flash fallback. I need to get the file path of the app: or appstorage: directory on a users machine, and pass that to javascript so that the player can find my videos.
View 1 Replieswhen it comes to using php to pass xml items to flash. i have this xml setup that works fine when pulling in images:
images.xml
<xml>
<image>
<thumb>thumb/1.jpg</thumb>
[Code]....
I have to pass some variables to the flash movie (movie.swf?var1=aaa&var2=bbb). never had a problem with using them before.I've read around a lot an tried different coding, but when I export the swf I got the error, that root is unknown...doesn't matter, if I use one of this
var flashvars:Object = root.loaderInfo.parameters;
var flashvars:Object = stage.loaderInfo.parameters; // stage is unknown here..
var flashvars:Object = MovieClip(root).loaderInfo.parameters;
var flashvars:Object = MovieClip(root.loaderInfo).parameters;
[code]....
So, I read the tutorial about passing variables by changing the url of the .swf with the following code:
Code:
if (movie==1 or movie=="") {
trace("default");
}
[Code]....
My question is, is there anything special if I want it to respond to the url of a .php page? So, if I have a page that ends in "?page_id=2" could I do the same thing or does it have to be an .swf?
Code:
if (page_id==1 or page_id=="") {
trace("default");
}
[Code]....
I'm using Zend AMF to send my remote objects to Flex. I've defined a Constant class and created getASClassName() method. Then I've created Action script class in flex.
Objects are send successfully, but they are deserialized to generic Objects in Flex instead of specific ones. EDIT: On network monitor in Flex I can see that AMF value is set to com.my.project.valueobjects.Constant. Although array from event.result contains Objects.
[Code]...
I have an array of temporary objects created in a for loop. The objects are of type class "Tile", a class I created. However, it appears that whenever I create a lot of tiles in the for loop, the program slows down indefinitely.
While the array is whiped at a later trigger point, I am thinking that perhaps these Tile objects are not being erased from memory. They are being created on the fly in a for loop, and the array is being reset to "array = []".
Are the objects still in memory or are they cleaned up when the array is set to []?
i have 1 PHP page in which i have a Flash animation. this flash swf file, display 2 fields and 1 button.
this php page is called "test.php".
i'm able to send data from Flash to a PHP page, but i would like to send the content of those 2 fields to the "test.php" and display them. however, i do not know how to do it.
i see that it works but i'm not able to display or refresh the PHp page to display the result.
as walkaround i was thinking to collect the webpage address where is executed the flash and to send it to another PHP page. and this 2nd PHP page, will reload the test.php with parameters...
how to get under flash, the address of the actual executed php page ?
I have a problem using a very simple URLVariables script with php.The thing is this sample do works on some servers and doesn't on other:Instead of having the correct values with trace, I get the php code itself.That means I get the following string in trace():[code]I know it comes from the php configuration on my server because I tested it on another server and it works, but I can't find what I must change in my php.ini file to get the good results in trace();
View 3 RepliesI want to pass flasvars to my app usng php. I can get the php var from the url string fine and write it but i cant pass it through flash vars for some reason.The code im having issues with is in red.
Code:
<?php
$avar = $_GET['a'];
[code]....