ActionScript 3.0 :: Pass Variable Through Classes?
Dec 9, 2009How do you pass variables through classes?
View 7 RepliesHow do you pass variables through classes?
View 7 RepliesI've been having a problem with passing variables between classes.
I have one class called GlobeView.as
Within that is a function designed to add markers to a globe
GlobeView.as -
public function addAdventureMarker( latitude:Number, longitude:Number, name:String=null ):void
{
[Code]....
I need to pass a boolean variable initially set to false to one of my classes called "EasyGame".It is than changed to true when one of the function in this class is runned.
View 1 RepliesI have two classes. See below.
What I want to do is pretty simple but I must not know how to do it. I want the URLFactory to create the Array and store it in the variable "dataArray" and use the Array in the Main class by calling the GetList() of the URLFactory class. What I have returns nothing...
Basically I need to set a variable equal to URLLoader.data (var something:String = URLLoader.data) so I can use this variable in other classes.
[Code].....
Trying to pass a variable as well and cant seem to escape to pass it. How can I pass using window.open as such: Trying to pass (pid) all i get back is (pid) and not actual pid.How to on a jscommand?
Code:
something.onRelease = function () {
var jscommand:String = "window.open('http://www.someform.php?proj= + (pid)','win','height=200,width=300,toolbar=no,scrollbars=yes');"; getURL("javascript:" + jscommand + " void(0);"); }
I can do a standard getUrl("http://www.someform.php?proj=" + (pid), "_blank"); works fine but no control over window properties.
I want to send the contents of a variable to a class where it can be used in its functions. Since I have no experience with object orientated programming what so ever I tried to break it down into real simple code so I can understand better what's going on and how I can implement it in my main code.I made a test file and a test class, basicly I just want to give a variable contents in my main code, then send the variable to the class so the class can trace it. But no matter how I try it i always get "Testoop.as, Line 6 1120: Access of undefined property test.Here is the code:
so this is the FLA:
import Testoop;
var test:String;
[code]....
I've traditionally all my as3 code in one included .as file, not as packages / class files, but I'm trying to make that transition. I'm a little confused about how to pass information back and forth among class files though. For example, what I'm trying to make is a sort of node diagram where clicking on a certain node will sprout out its child nodes, and clicking on a child node will sprout out its children, etc. I have a main class, Main.as, which I was going to make parse an XML document and store an array of all the relevant data for each node (things like a title, link, etc). Then I have a class file called Node.as which actually builds the node, adds it to the stage, and sets up its listeners and the motion tweens.
My question is - if all the information for the nodes is stored in Main.as, but the click handling is done in Node.as, how does Node.as know what attributes to assign to each added node (i.e., how does it access the array from Main.as to assign properties to the clips created)?[code]...
How to pass a variable from one AS class to another please?
View 4 Repliesive written a class to control my content panels on my site. They work well! Currently they controll all the positioning perfectly on there own. What I am having trouble with, is how do i pass variables into my classes. For instance, my main content panel, has variables in the class: public var contentState:Number; Now, what I would like to do, is have movieClips on my stage, or 'buttons' that will be able to change 'contentState' within my class.How do i go about passing these variables?[code]
View 1 RepliesI'm trying to pass the contents of variable playnoyes to the long line of code below to decide whether or not to autoplay the flash movie, but doing it as I have below, the resultant line of code has the variable in quotes and therefore the code doesn't execute it as expected. My question is, how can I pass the variable so that the resulting line of code doesn't have the quotes around the variable value.
var playnoyes='true';
var testtext = "<script type='text/javascript'>AC_FL_RunContent ('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.[code]....
I am trying to do is declare a variable in PHP and pass that variable to my flash file. Right now i am simply trying to do 1 easy variable, more will happen in the future but i need to figure this out first.I have used other forums and they say try this and that, but nothing i do seems to work. here is my code.
PHP Code:[code].....
I have two custom as3 classes, TriviaGame and TriviaQuestion, and I am attempting to retrieve a bitmap image stored in TriviaQuestion and have found it impossible thus far.
It seems the root of my problem is that bitmap is somehow null in my GetImage() function, even though it is class data that has been set earlier in ImageLoaded(). The only time I am able to access the bitmap's info (in order to add it to the display) is inside ImageLoaded().
In TriviaQuestion.as, loading the image:
private function XMLLoadedHandler (e:Event):void
{
xml = new XML(e.target.data);
[Code].....
I declare this class which has a value x (In it's own document)[code]...
View 3 RepliesThere are many tutes on the web on how to make interface elements, such as drop down menus, or accordion menus. The example Menu Class includes all the event listeners and functions. It invariably ends with the CLICK event function tracing some comment so you know it works. But no information on how to implement the Menu Class. So say you have a Main Document Class that instantiates a Menu Class. How can you pass the CLICK event back to the Main Document Class to do something with it? As far as I can see, the Menu Class can build the menu but all the listeners and functions for it have to reside in the Main Document Class. Or do you have to build a custom Class that extends the Event Class?
View 3 RepliesI am trying to pass a variable with brackets in the variable name. Example
productoption[]="value";
Whenever I publish the file flash gives me an unexpected "]" error code. Is it possible to have a variable name with brackets? I tried to use the escape codes %5B%5D to pass the brackets but that didn't work also.
i write my own code for php and actionscript...and i had a problem with it.. How to pass php variable to action script variable?
[Code]....
can i pass variable from one swf to another swf. each swf is in separate html page.
View 3 RepliesI was just wondering if this is possible and the best way to achieve the following.I have 3 classes. One base class and 2 subclasses. eg MyShape, Square, Circle. The Circle and Square classes both override the MyShape's assignProperties method which takes a string as its argument.What I do in this method is loop through a serialized string and assign variables.So the string looks something like p:10|x:200|f:300Because some of the properties are generic to the MyShape class I have the Circle and Square assignProperties call super.assignProperties()Now this all works great but I realised I'm going to get some repitition calling it at each level.
So I was thinking is it possible to get the supers.assignProperties to strip a property from the string if it is found before the assignProperties in the Circle and Square class is called.Here is sort of what I have with a little pseudo codeSquare Class assignProperties Method
PHP Code:
assignProperties(_properties:String) {
var properties:Array = _properties.split('|');
[code].....
I have two classes, IntroScreen.as and MainMenuScreen.as.I have an input text box on the IntroScreen that captures text and successfully traces it in the same class.
Actionscript Code:
public var nameEntry:String;public function startButton(event:MouseEvent):void { trace("Start button clicked.") nameEntry = enterName.text;
[code].....
I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code. What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.
Document ClassEgoGame.as
package
{
[code].....
I have a problem with returning variable between classes. As far as I know there are some ways to do it but in this particular case I tried to use Getter.
So I have an XML file (content.xml), a class to read XML (LoadXMLExt.as), a class to display images, and the main class which first call the LoadXMLExt to get the information from and then call the displayimage class including passing the information from LoadXMLExt.
[Code]...
I am able to pass a variable from an html link that loads a separate html file and instructs the embedded file to go to a specific frame. But - I now need a link within an swf file on one page to open a new page and tell that swf to start on a specific frame and it is not working. Here is the code I use for the first example - works like a champ:
[Code]....
I want to put a variable at the end of a URL and have Flash "find" that variable. The url would be: [URL] "Campbell" is the variable I want to pass to Flash. I then have this script in the root timeline:
loadVariables (""+agent".txt", this);
I want "agent" to be replaced with Campbell. That way I can have it read a bunch of variables from the txt file. I tried this as well:
loadVariables (""+_root.agent".txt", this);
What am I missing in this?
I have declared one variable in one.fla file on a button press i am opening another swf file. [code]...
View 1 RepliesI use AS3 to pass variable to PHP. The script is as follows
<<Actionscript>>
var urlFailLoader:URLLoader;
var urlFailVariables:URLVariables = new URLVariables();
var urlFail:String;
[Code]....
However, nothing is displayed as I type "http://localhost/moodle/flashtophp.php" in browser. Why is that?
Now I understand this has been asked to go from Parent to Child before, which is all well and good, but what I want to know is, how do I go about passing from a Child SWF back to the Parent?[code]...
View 2 RepliesI have a main swf in as3 and I load another swf in as3 in it. Now I want the main swf to pass variable to loaded swf.
View 2 RepliesI want to pass a variable from one swf to another that will be embedded in an html page that the first swf will open. Basically, I want to pass a variable with the URL of the image that the second swf should load.
I respect people that have this knowledge, and I am not asking you specifically for the code, but for some directions on how to make this happen.
i write my own code for php and actionscript...and i had a problem with it..How to pass php variable to action script variable ?
e.g my php code (test.php) is
Code:
<?php
print"&phpVar=1";
?>
My action script code is
Code:
loadVariablesNum("test.php", 0, "POST");
if(phpVar == '1')
{
[code]....
The output should be "Condition A" Since phpVar = 1 ......The output of this script is always "Condition B" Means this script not detect "phpVar = 1" how to show this output "Condition A" by using php variable ?
I have two swf(a.swf anb b.swf) in as3 . Now I want pass variable From a.swf to b.Swf. i used the Loader Class.[code]...
View 6 Replies