ActionScript 2.0 :: Accessing Array Within XML Objects?
Sep 19, 2006
Here's my code:
Code:
function loadProjects(loaded){
if(loaded){
projects = this.firstChild.childNodes;
[Code]....
the traces within the function return correct results, however when trace values of the arrays within the function and created by the xml are attempted results are returned 'undefined'.
Why can I not access arrays made in this way from outside of the function?
I have drawn colored rods which I have placed in the library and have put one of each on the stage with instance names likeblueRod_mc, etc.I place them around with time-line code like blueRod_mc.x = 300.0;I have now created an Actionscript class called Problem.I build a new object from Problem which I have called Riddle.But when I put blueRod_mc.x = 300.0 in a method (of Problem),I get the message that blueRod is not accessible.So I triedstage.blueRod_mc.x = 300.0;That did not work either.
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 a service which returns an Array of ObjectProxy objects. I would like to cast this to a custom object (a value object) and create an ArrayCollection. How can I do this?ited:I am using Django and PyAMF for the backend. I had to write a custom SQL query and I am wrapping the resulting records in ObjectProxy and sending the whole result as an ArrayCollection.Here is my client side code:
[ArrayElementType("SessionVO")] [Bindable] private var _list:ArrayCollection;
I'm so proud of myself. I figured this out all by myself and thought I would share. (If you can't tell, I'm new to AS) I needed a way to grab an item in a specific location and have it return an array of items. Here is how I did it:
Is 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
I'd like to be able to access some objects which are on the stage before compile time (e.g. in my .fla file). I can do this fine from the document class using the names I've assigned to them, but I need to be able to do this from other classes (instantiated at runtime) too.
What is the best way to go about this? Can I use the stage variable (this isn't looking likely from what I've read so far) somehow? Or do I need to pass in references to these objects from my document class when I create the instances of the class that needs to access them?
I'm working on a flash video player and I'm trying to figure out how to access something inside the constructor that I know is set but it keeps telling me its not.
[Code]....
now in the metadata function its giving me the error, "Access of undefined property video" Now, am I just completely not understanding how classes work or is this a common problem?
I want to access an object from a class in which it was not created in. I have a main class (A) in which I create and instantiate an object (of class B), from this class I can obviously do whatever I want with the object, no problem. The issue I'm having is another class (C) needs to access the object in question to change its x and y location values. Class C doesn't know what the instance of class B, created in class A, is; this doesn't surprise me, but I can't figure out how to allow class C to get access to what class A created.
If objects are created dynamically in AS3, using code like this:
for (var num:Number = 0; num<10; num++){ var txtFld:TextField = new TextField(); txtFld.text = 'This is the original text'; this.addChild(txtFld); }
then later, i want to changet the text of one of the TextFields, how can I do that? The only instance listed in the variables is a single instance of "txtFld" and it is the last one that is created. How can I access the others?
I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).
I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!
I have a datagrid which has id="myGrid" in my application, from it I call a component. Now from the component I can call parentDocument.myGrid.selectedIndex = 0; and it works fine.But I want to make the component reusable, and I would like to pass the ID to the component each time, so myGrid will change, how to properly send the ID to the component, and use it in the component?
have a button on the stage that you called "myButt". Now suppose you want to change its size. You write:myButt._xscale = 25;Now suppose you don't know it's name, but you get the name from another variable:buttname = "myButt";How do you change its size then? in some compiler languages you can expand the string buttname into its value at compile time, with special flagging, such as:
So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?
I'm a seasoned AS2 developer who's been dragged kicking and screaming into the world of ActionScript 3.0. I'm working on revising an old project coded in AS2 that needs to be re-coded in AS3 and It's been slow going. I have a question regarding addChild (attachMovie) function. My scenario is as follows: I'm pulling data from an XML file that dynamically builds a scroll list from items in the library. Each item in the list has an individual button function attached to it. I'm generating my list just fine, but I can't access the items as individual buttons. Instead, it seems that the entire list has the properties of the last child added.
I have a movie clip on my scene with a number of objects all prefixed with a keyword 'build' (e.g. 'build8934', 'build4920') - is there any method, array or object that I can access that would give me access to a list of objects for that movie clip?I'm intending to loop through an add events to an instance which matches the prefix 'build' and set additional properties based off that instance.x.
I have (may be a simple solution needed) a problem with a class I've wrote. I've wrote a class named Navigation [URL] and in there I make all the buttons for the navigation. Next to that I have a Ipage class [URL] and in there I have all the pages stored. When I click on a button, the Navigation Class is called and tries to access the public function ChangePage in the Ipage class. In the ChangePage function I trace if the function is called and the trace comes back. So it works... BUT if I want to access another object it's not working. I can't even set sprites on visible = false.
I am trying to learn how classes can interact with each other and I came across a problem I can't solve. On my stage I have a MovieClip called "myMovieClip".
iSo let's say I have three different arrays of objects, and I want to combine them into one sorted array. I want the order to be such that the items from each array are evenly distributed throughout the sorted array.
If there were 3 xItems, 3 yItems, and 3 zItems, the sorted array would have this order: x, y, z, x, y, z, x, y, z
HOWEVER, even if the arrays are differing lengths, I still need to make them alternate as much as possible. If there were 6 xItems, 4 yItems, and 2 zItems, the sorted array should have this order: x, y, x, y, x, z, x, y, x, y, x, z
I'm currently working on a game. I'm breaking down each piece of the game into individual classes and movieclips. The intro begins by going to the main menu which is a MC in my fla library. This is called through the document class. then all actions the main menu MC performs are commanded through the MainMenu class. When starting the actual game, MainMenu calls a function from the document class, after it is removed from the stage, that puts an empty movieclip called Level on the stage.
var lightBox:mc_lightbox = new mc_lightbox(); lightBox.x = 300; lightBox.y = 200; addChild(lightBox);
I get a lightbox up on the screen, within the lightbox is some more script, there are three menu options for that new window. So far when you click on it the loading part comes up just fine but whenever I have it go to another scene it leaves behind the lightbox above. I'm able to removeChild(loading) because its right there just a function above but I'm unable to removeChild(lightBox) because it's one up. How can I access that child? I tried many variations of parent, MovieClip, and root relationships but still couldn't get flash to find it.
I'm trying to access a MovieClip object in a SuperClass from a SubClass. The only way I can tell this is possible is through an event dispatch, but I'm dealing with a preloader and a loaded external SWF. So I can't make an instance of the "not yet loaded" classes because I'll get errors. Furthermore, the objects in both SWF need to be controlled in sync.
I have a structure display like this: (brackets shows the depths, within their parent)
my question concerns 'communication' between the highlighted objects - so you don't have to waste time understanding the whole tree! I've just added this to provide some context!
mc_init (0) ___| ___mc_page (0)
[Code]....
Now, its easy to add a mouse event to btn(1), but how do I get this button to set the visible property (say) of 'rectangleBG(0)'
how do I access the paths? of these objects added to the stage?
Code: if (! initialized) { for (var c = 1; c < 1000; c++)
[Code].....
The error given is "1120: Access of undefined property particle4." However, everything traces correctly, but the individual particles cannot be accessed outside of the loop. Eventually I want to add the next particle at the mouse position on every click, but obviously I can't do that without being able to access the individual particles. I also read about having to use getChildByName() to access names set in AS3, but I haven't been able to get that to work either.
i have two arrays of DesplayObjects and i want to add all the objects in the second array to the end of the first array, i knew that i just can just do a loop and puch em into the array, but i wondered if there was a simple function for doing this?