ActionScript 2.0 :: Variables In An Object?
Apr 24, 2006how do you access a variable in an object? i have created a subclass of movieclip in but cant access variables in instances of that subclass by using instancename.variable
View 6 Replieshow do you access a variable in an object? i have created a subclass of movieclip in but cant access variables in instances of that subclass by using instancename.variable
View 6 RepliesI need to know if there's a way (a tool) to get a flash object (swf) variables which are used in "flashvar" tag.
View 2 RepliesThere is the code that makes up the major part of the game, and then there is an object for the game board which I kept separate because it required a lot of code of its own to handle pieces on the board, change perspective, and so forth. From the main game code I have no problem accessing information in the game board. I can get the information about an object of apiece on the board, for example, by addressing it astrace(gameBoard.aPieceObjects[x][y].visible) BUT if I want to get information about the main game from the gameBoard object I can't seem to do it. For example, to remove a fog of war I need to know how far a player can see which is information that is kept in the main code in an array of possible players. addressing it as trace(parent.player[i].adVision) gives me an error that there is no such property. The same is true if I use "root" or "this.parent" instead of just "parent".
I know that I could set it in the main game code, but this would mean making duplicate copies of lots of variables which I would prefer not to do. Especially since my program is already not very efficient due to sloppy planning (this is my first real programming project in quite a few years).
I'm wondering if it's possible to remotely create variables/properties on another object. Specifically, the stage.
I'd like to do something like this
public var stage.myArray:Array = new Array(1,2,3,4,5);
Perhaps that's not the right syntax. But assuming the array doesn't already exist there, can i create it (from an object that is on the stage)
How do you assign an object different variables.I tried setting it up like this but I get an error.[code]How do you do this correctly I get error Label must be simple identifier when I do it like this.
View 2 RepliesI want to assign an existing Object all the vars of a prototype Object, without a direct reference. One way to do this is:
[Code]...
This way both Object's values for .nom and .age can be independently changed, but it's tedious. Is there an automated way to assign all of protoObject's vars to enObj?
I have a simple problem which is not easy at the moment. this is a text field class which add a text field to a movieclip (passed from root class) and also save(buffer) some data (like xml file name) in it`s public variables:
package src {
import flash.display.Shape;
import flash.display.MovieClip;[code]............
.. now I use a for loop to add instance of that class to a movie clip on stage:
for (var i:int = 0; i<Bunker[0]["trans0size"]; i++) {
menuData[i] = new menuitem00(i, menu_mc, Bunker[0]["transfile0" + i]);// pass i , a movieclip named menu_mc and an xml file name
menuData[i].name00 = Bunker[0]["transtitle0" + i]; // pass text
menuData[i].activateFlag = true; // set actveFlag to true
menuData[i].init(); // run init() inside the instance. it adds textfield to the menu_mc and also set name00 as Text for the textField
}[code].........
I want to get "xml00" var from that instance on the stage by mouse click but, trace (evt.target.xml00); is not working .. also trace (evt.target.name00); is not working. I can get everything like .alpha or .text from txt00 but not other variables in my object.
I've created and XML object that's working fine and I want the user to be able to add to the XML dynamically, using an input text field and appendChild() So, what is the syntax to use so that I can put in the text they enter as an attribute of a node of my current XML object? Here's what I've got for adding to the XML (stripped down obviously):
ActionScript Code:
var xmlData:XML = new XML();
var clientToAdd:String = userInput.text;
xmlData.appendChild(<project name=clientToAdd></project>);
How can I take the variable clientToAdd and make it the attribute "name" of the "project" node?
I don't know if I named thread technically correct.
I'm new to flash, and my current challenge is to access object.[code]...
I need to store a users username that has successfully logged onto our system.
The user will be accessing a directory behind the corporate firewall.
I've talked to IT about it... they have said.
Quote:
I can put an integrated security virtual directory in place.
In turn, you would need to figure out how to get the �current logged on user� details from the environment variables that are in the request object (that comes from the user�s browser to the webserver).
Is there a way of tracing variables in an object without expressly listing each of them?
e.g.
Code:
so.data.thename="derek";
so.data.thenumber=1234;
so.data.sex="male";
[Code].....
If I have a variable that is declared within a method of a class, should that variable EVER need to be marked for garbage collection (set to null).
For example:
Code:
public class MyClass extends MovieClip{
public function MyClass():void{
//constructor
myMethodThatLoadsAPage();
}private function myMethodThatLoadsAPage():void
[Code] .....
I am making a 24/7 kiosk app and am noticing that the "pages" I load from the library using the above technique continually increases the memory usage (using Monster Debugger 3 and testing the SWF from within Flash Pro CS5 on a Mac.) As I understand it "myVar" are the only references to each "SomeObject" object that gets instantiated. Shouldn't the fact that myVar is local mean that SomeObject should be available for garbage collection after each new page is loaded?
I have an application that reads a PHP script and populates the Flash applets using the following on frame 1:
[Code]...
A combobox (created with the returned data) is created on frame 61. When a selection is chosen in the combobox I need to add the value returned from the combobox to the variable catvar, add this variable to the LoadVars object and run the script again. It seems to set c.catvar initially but when I use the 'sendAndLoad command the second time c.catvar isn't included. Is it possible to add variables to a LoadVars object created
on frame 1 from frame 61?
After unexplainable problems with external class files, I'm trying another way of doing what I need to do: an Object variable declared in the fla file. Well, this has its own set of problems. The big picture is: I need to get user data and populate fields in their profile when they sign on. Then save changes to their profile during the session, add new users and make changes to their profiles. Pretty normal stuff.
Here's the problem I'm having with the object.
Frame 1 Script:
/* Define the object to use as an associative array.*/
var Person:Object = new Object();// Define a series of properties.Person.HomName = "Joe";Person.HomEmail = "joe@gmail.com";
Then go to a new keyframe, where I have my fields that need to be populated
Script:
EnterName.text = Person.HomName;EnterEmail.text = Person.HomEmail;stop();
When I compile, I get this error twice (once for each field) "The property being referenced does not have the static attribute."
What does the mean and how do I fix it?
Here is a link to the source file if you care to look.
[URL]
The only way I've been able to get variable data from one script to another is through a _global.variable. Is this the only way? No arrays or objects vars?
Thanks in advance for all who assist. Some day soon I hope to be able to return the favor!
I have a simple object defined by an object literal, and have a couple functions assigned to this object. Inside the functions, I try to access global variables, and it only gets undefined. The Flex debugger tells me the variables are just right up the scope tree.Yes, I know I can access Thing by using 'this', that doesn't solve my scope issue though.Project Flex Compiler Settings: Flex SDK 3.4, Require Flash Player 10.x.Example:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="Thing.bling();">
<mx:Script>
<![CDATA[
[code].....
Right now, I have many MovieClips's in my array. I want to update all the alpha values of the MovieClips in my array. Right now, I am using a for loop but this is not the fastest way to do it.
View 3 RepliesHow do you use variables to access Object attributes? Suppose I have an Object declared as follows,
var obj:Object = new Object;
obj.Name = "MyName";
obj.Age = "10";
[code].....
I have these movies already existing in my actionscript code: inner_mc AND gallery_mc.So - I attach my library movie clip: called "link_box", and name it link_box0 and so on through the loop.
-->
for (i=0; i<numimages; i++) {
inner_mc.gallery_mc.attachMovie("link_box", "link_box"+i, i);
Now I want to create a new movieclip called thumbnail0 and so on, to the newly attached movieclip.
This is my attempt: this.movieHolder = inner_mc.gallery_mc.link_box+i.createEmptyMovieClip("thumbnail"+1, i+1);
When i try:trace(this.movieHolder ) it says undefined for all times it loops through.
Whats the syntax to combine strings and variables so that the result is seen as an object name ?
I was wondering if there is a simple way to access variables from a class object, where the variables are not actually a part of that class. So if you had an array defined on the first frame of the stage, and added some elements to it, you could use the methods of the custom class to manipulate the array's data.
Stage Frame 1
Code:
var myArray:Array = new Array( "apple", "banana", "pear" );
var myClass:someFunctions = new someFunctions();
myClass.addValue( "orange" );
myClass.sortValues();
[Code] .....
It might not seem logical as to why you would ever want to do that, but it's a very simple example, and it's the means I'm after, not the result. I'm creating a list of functions available to execute by a user via an input field. To keep things simple I made them the methods of a class. The issue, however, is that these methods need to manipulate objects which are on the stage, added and removed by a separate controller class. Passing the objects by reference to the class as a parameter would not be viable with what I'm trying to do either.
If I set an Object = null, does that remove all references to the Object's variables assuming there are no external references to said variables? Or do I have to manually set all said variables = null?
View 4 RepliesI am making a game in which you have to click on objects in different frames. The objects are buttons with this actionscript:
[Code]...
i am wanting to know how much I can be sure that users of my website will not be able to pass bogus variables to my Flash movie. Basically I will have some features available to certain users and I realise that for the average user they will not know anything about how to send spoof vars but is it possible for someone to change the variables sent using SWFObject when a page loads and thus be able to use the functionality that I am trying to disable for them.I have a PHP (my_flash_movie.php) page that calls a function from an included globals.php file to determine if the user can see the restricted functionality is_ user_a_subscriber($_SESSION['user_id']); which returns 1 or 0. This 1 or 0 is then passed to Flash which enables or disables certain features. I dont want someone to be able to send a 1 instead of a 0 basically. This isnt a site where security is critical and the functionality that is disabled is not really critical either so wouldnt be too bad if this happened but im just curious about this and wondering if I should think of another way to pass these vars that might be more hidden.
View 3 Repliesi want to put all variables of an object into ByteArray in declaration order. the object can be a extends one. here is my code:
private static function getVariables( packet:*): Array
{
var vars:Array = new Array();
[Code]....
what does the "pos" for ?
i try to print the xml, but i can not find the meaning of "pos"....
I need to get variables that are passed from my html object and/or embed tags, so I can use them in my flash project.
for example: src="/incl/flash/Line_Graph.swf?a=value1&id=1"
how can I get a and id inside my flash file?
I have the livedocs wide open and I still can't figure out how to send off multiple variables in an object (from a class) to the FLA file...[URL] The setup: I have a class that extends EventDispatcher. I created an Object called _pass, public var _pass:Object;. In my last function (everything is cool up until now), I have four variables that need to be passed to the main fla. Let's say they're param1, param2, param3, param4.
It was explained to me that I could use the public var _pass:Object; by first creating an instance of the object like so, _pass = { param1, param2, param3, param4 }; (each param is available in the function). Having setup an object instance, I could then dispatch the object to read from within my fla: dispatchEvent(new Event(Event.COMPLETE));.
But I get these errors:
1084: Syntax error: expecting colon before comma.
1083: Syntax error: rightbrace is unexpected.
As the livedocs show, you can use an associative array (with braces and a colon), but I don't need that. I just need to pass my variables that are pre-made to the FLA.
I am trying to create an AS3 Fla to score a quiz's results. The quiz is a separate swf that stores its results to a shared object ("G1"), and both the quiz swf and this new scoring swf would reside on the same website.
I've tried scripting the AS3 in the new scoring Fla but I keep getting error messages.
So far, here's what I have that doesn't work.
[Code]....
The goal is to open the scoring swf, populate some variables with the values from the SO, then (not yet tried in the script) apply some if/else conditions to show specific results based on scores.
I'd like to easily convert a string of say "dog=Sam&cat=Garfield&mouse=Cheese" into an object of strings.
The object would contain the variable "dog" equal to "Sam", its variable "cat" will be "Garfield", and of course "mouse" the string "Cheese".
There are a number of ways to parse this, but what is the simplest way? I know when you use a URLLoader object, you can give it a dataFormat of URLLoaderDataFormat.VARIABLES and then it automatically converts the data into an object.
I am wrapping my brain around OOP in AS2. I am making two posts on two different subjects. My question here is: when should I use local instance variables, and when should I attach new properties to the instance object? (Feel free to correct my terminology.) Let's say I have a class for a scrolling background, which scrolls when I mouse over its edge. I want to put these values somewhere:
1) How wide is the border in which a mouseOver makes it scroll? This is basically a semi-constant I set it up once and keep it the same, unless the user changes it in an options menu to make the border wider or narrower. Call this scrollBorderWidth.
2) How fast is the background scrolling now? I want to track this so I can smoothly change the scroll speed over several frames. This is often changed. Call this scrollSpeed.
It seems I have two ways I can store and access these values and darned if I know which is better practice. METHOD A: Make them local variables in the class, so the scrolling background instance has them as local vars. I set them up thusly:
[Code]....
If I have a variable that is declared within a method of a class, should that variable EVER need to be marked for garbage collection (set to null).
for example:
Code:
public class MyClass extends MovieClip
{
public function MyClass():void
[code]....
I am making a 24/7 kiosk app and am noticing that the "pages" I load from the library using the above technique continually increases the memory usage (using Monster Debugger 3 and testing the SWF from within Flash Pro CS5 on a Mac.)
As I understand it "myVar" are the only references to each "SomeObject" object that gets instantiated. Shouldn't the fact that myVar is local mean that SomeObject should be available for garbage collection after each new page is loaded?
I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.
View 2 Replies