ActionScript 3.0 :: Grab Class Variables From Loaded SWF?
Sep 22, 2009
I have a project that works quite beautifully right now. I have come to my next task. Creating swfs that are loaded into another swf. This newly loaded swf needs to grab some variables from the main swf's document class or global variables class that I have created. I have set the class path as such that it can access the classes as needed. I did not set a document class.
I need to send a variable (zipcode) to a coldfusion script and also load the cf page that displays the results (same script) in the browser window (_self) is getURL the appropriate choice for this? (never done it this way before). if so, does using POST in a getURL just grab any variables on the _root? where does it get its variables?
I have an .SWF that is a "Share With A Friend" and the text fields are filled in and then the SWF sends the variables to sendToFriend.php and then the email is sent out.. The PHP is working fine and I have all the right codes to send that information from the SWF to to PHP, but the client wants another feature I can't figure out..
They want me to grab data from an XML and use those variables as well, because the XML will have the USER EMAIL and I need to grab the specific data from the XML and I can't find anything that does this..
I barely know where to start. Maybe a simple tutorial that doesn't just load the XML and display the content (I have found that), but rather something that loads the XML, then refers to a specific child and turns the text to a variable to get sent to PHP..
EXAMPLE XML
<client>Joe</client> <email>JOE@JOE.com</client>
How do I load the XML and directly refer to the <email> information so my PHP file can grab "JOE@JOE.com" ???
I got a request today conserning .txt files.What I want to accomplish is to grab information from a text file and save them in variables (or an array, depends).Whats the best way to do this, and whats the do's and don'ts?I'm planning to use the LoadVars class to pass the variables through and i've got a working test, but isn't there a more efficient way to do this?
how to grab the transparency (or alpha value) of individual pixels in an embedded or loaded video? We tried copying over a frame of video into a bitmapdata object with transparency enabled. However, even though we can "see through" the video at certain spots (indicating alpha = 0 there), the alpha value comes back as 0xFF for every single pixel in the BitmapData object.Obviously alpha data is being stored inside the embedded video, but how can I actually get that value?
I have a child class that is loaded into the parent class when the swf begins, like so: var myvar = 'hello'; public function Parent() { this.child = new Child(); }; How can I retrieve the variable 'myvar' from within child?
I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.
Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:
I am creating a Weapon class for a game and the weapons itself will be the sub classes. The sub classes will hard code some values (such as max ammo and the weapon name).
I trying to access this declared data in the base class constructor, at the moment it's not outputting the values. Is this possible?
My current workaround is creating a protected method in the base class to trace the information and calling that method in the sub class's constructor, this works fine but this doesn't seem like the most efficient technique?
Now I would like to use the variable out of class1 in class2 and change the value there.Afterwords use class2 in the main, but I get an error message. Why?
What is the correct syntax to initiate a function in a class similar to constructing an associative array? I have a function that's custom variables is ballooning out and I'd like to label them in the call for sanity sake.
Is it "better" to initialize AS3 class variables in the class constructor? Or can I just initialize them to their default value when I declare them at the top of my class? I ask because when there's a lot of class variables, it appears inefficient to declare them in one place and then initialize them in another when I could easily do both in the same place. It one option is better than the other,
I've got a document class (EgoGame.as) and another class (Ball.as) which has been duplicated to deal with several different video pieces. Inside the document class is a list of 'if' statements which decide which video should be played. At the moment I'm doing it the old fashioned way whereby if the condition is true....it tells the relevant Ball class to gotoAndPlay a certain frame within the linked movieclip...
I can't find a way to directly access a MC (or textfield, etc) on the timeline from a Class loaded into my Document Class. No problem from the Doc Class, but can't do it directly from the loaded Class. Is there a trick to essentiall extend the Doc Class AS from another external class?
I have two SWF files which I shall call container and slave. The slave file contains a movieclip that extends from a class I shall call base. base extends MovieClip and is compiled into an SWC. slave includes this SWC as a runtime library, while container includes it as merged (and does reference it so it should be compiled into the container SWF).
The container loads the slave like so:
bgURLRequest = new URLRequest(slaveUrl); var context:LoaderContext = new LoaderContext(false, new ApplicationDomain( null ), SecurityDomain.currentDomain); bgLoader.load(bgURLRequest, context);
When this loading happens, I get the error that class base was not found. I suspect this has something to do with the presence of the ApplicationDomain in there. I'm not sure what it does exactly, since I didn't write this loading code myself (but I do know that it's there for a reason so it can't be simply removed).
I'm trying to create a quick prototype of an application so i decided to use text file based variables. This was an hours work that has turned into a days worth of hassle.I just cannot get the else/if statements to work with my variables. Here is a simplified code that I am trying to use:
Code: myData = new LoadVars(); myData.onLoad = function(){ displaybut();
I am creating a flash program to open other flash programs (load swf files), and change their textfields to my own extended textfield class. This is to capture all text written to screen using a textfield object. Here is what I am doing:
1. If a textfield has been created, the event is captured
2. I want to replace the textfield with my own class extending textfield
*3. Any further access to the original textfield for value changes can be captured, and would update the replaced extended textfield object
The problem is if in their original code, at sometime, the text value of textfield is changed (mainly through textFieldObj.text = some_value) , I don't know how to capture this event.
This cannot be captured by event.CHANGE which requires the user input (ie: keyboard strokes) into the actual text field and changing the text through the code: textFieldObj.text = some_value does not trigger the event.
Here is a simplified example:
// FlashMovie.fla START ------------------------------------------- // any DisplayObjects (such as a created textfield) created will be captured // by ChildAdded() this.addEventListener(Event.ADDED, ChildAdded);
I'm having a SWF call functions from another SWF loaded in the first one with the Loader class. There are no problems as long as the target SWF does not contain any TLF TextFields created on stage by authoring time interface. As soon as I place a dynamic textfield on the stage of the loaded SWF, the main SWF (the loader) fails to call any of the functions within the SWF that is being loaded.Static text does not seem to present problems and neither do TextFields created via ActionScript.Also, is it possible to access variables of the parent SWF?
I am having a problem accessing variables in a loaded flash movie.
As my understanding goes (someone please correct me if I am wrong), if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.
As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.
I am developing a flash board game which entails moving a piece around a board as a result of throwing a dice (the person will either move the dice themselves or it will move according to the outcome of the throw). When they land on particular squares I am going to have a random question (this is going to be a loaded SWF) appear that will have a multiple choice questions.Can I save the result of 'multiple choice question' within the main movie / separate movie and then use this variable ?
in my script, when a button is clicked it loads a movie clip from the library onto the stage
but what that movie clip does is supposed to be dependant on what button is being pressed. however that movie clip being loaded onto the stage doesn't seem to recognize or load any of the variables from the stage.
its as if, since the movie clip does not exist when the fla is initially run, the movie clip doesnt recognize previously existing variables.. or doesnt recognize any variables outside of itself
i have a swf file that i am loading into a parent movie and i need to pass some variables to the loaded movie, unfortunately i do not have the original fla file of the movie being loaded in so i cannot use _root or _global ect..the swf that is being loaded in works fine and originally intended to have the variables passed though flashvars, is there any way i can pass these variables though the parent without having to change the fla of the loaded in swf
if I load a flash movie into a parent movie (i.e. 'loadMovie("myMovie", emptyClip);'), I should be able to access the loaded movie's variables using dot-syntax.As an example, say I have two movies: MainMovie.swf, and SubMovie.swf. SubMovie.swf contains a (global) variable called someText. After loading SubMovie into an empty movie clip called "emptyClip", MainMovie.swf should be able to access the aforementioned variable by saying "emptyClip.someText", right....? Well, when I try this I keep getting an undefined value for the variable.
Is it possible to pass variables to a swf that is being loaded from another swf without using GET or POST or loadVariables?Maybe a function? If so what is the code?
I am developing a flash board game which entails moving a piece around a board as a result of throwing a dice (the person will either move the dice themselves or it will move according to the outcome of the throw). When they land on particular squares I am going to have a random question (this is going to be a loaded SWF) appear that will have a multiple choice questions. My question to you guys is this. Can I save the result of 'multiple choice question' within the main movie / separate movie and then use this variable? I think essentially what I am asking is how do I load a variable from an external SWF.
If I load an SWF file, is it possible for the pre-loader to access and change a string variable inside the loaded swf? Is there any special way to do this or would it be a simple case of loadedMC.variable = "new value"
I'm trying to debug my movie, but the variables in the debugger are greyed out and I can't expand them. It also doesn't show the progress through the code. I think it's related to having loaded an external swf.