ActionScript 3.0 :: Get Child Of Array?
Mar 30, 2011Let's say i define as follow[code]...
how am i going to change the attribute of the mychildSprite in the myArray?
Let's say i define as follow[code]...
how am i going to change the attribute of the mychildSprite in the myArray?
Im trying to create a line with 10px*10px squares and manages to get one square on the stage, but having some problems with the the rest since I can't get the .X .Y from the Array-childs
[Code]...
How do you get the value of a child node in an array titled "entries"? I used to do this in AS2, and now I'm trying in AS3. To top it off, I'm forced to use an XML format I'm unfamiliar with. So I'm not sure how to access these nodes in AS3. An example of the XML is;
[Code]....
I am trying to add a child to the stage through an array.
var one:First = new First();
var myArray:Array = new Array();
myArray[0] = "one";
[Code]....
I want to add a child by reffering the name in a array.
add a child to each movieclip in the array below?I want the code in bold to increment with the wObj movieclips.
e.g.
wObj1 contains a loader called wObjIcon1 loading an image from wIconURL1
wObj2 contains a loader called wObjIcon2 loading an image from wIconURL2
..and so on.
Code:
public function makeWObjects(numNewWObjects) {
for (var i:uint=1; i<=numNewWObjects; i++) {
wObjCounter++;
[code].....
I have written this little script, as i want to remove some of the text fields that are currently contained within the Display Objec, however it does not like to see the TextField as a varaible name. How would i convert the object from an array to become a textfield that can be removed, after being added through
addChild()
This is the script
var delayHeading:Number = 1500;var repeatHeading:int = 1;var setShow:Timer = new Timer(delayHeading, repeatHeading);setShow.start();setShow.addEventListener(TimerEvent.TIMER_COMPLETE, maybeLater);
[Code].....
Here's what I'm trying to accomplish: I have as3 script that successfully displays an array of MovieClips, the MCs have variable xy positions, and in some cases they overlap each other. I have a function within the array that I can't quite figure out. Here's what I'd like the function to do: When the cursor rolls over a particular MC displayed by the array,I'd like that MC to be brought to the front of the others. This is my script:
var myArray:Array = new Array(); for(var i:int=0; i<8; i++) { myArray[i]= new myImage();addChild(myArray[i]);myArray[i].x = 180*i;myArray[i].y = 330;myArray[i].addEventListener(MouseEvent.ROLL_OVER , overlap);
function overlap (event:MouseEvent):void
{trace('function triggered on image ' + i);
[Code]...
so here goes the description of what i'm (trying) to make : i want to make a slideshow with AS 3, it will load external image which the location will be written in xml after it has load all the image it will play by itself and change beetwen image with transition.. well i manage to : read the xml, load the picture one by one and convert it into a bitmap tipeafter convert it to a bitmap tipe data i save it into an arrayafter all the image has been laoded , converted into bitmap and saved into array to display the image itself i first add the the image which has been save into the array to the container that i specially made to hold this (well actually because transition manager can only have effect on MovieClip).
myMCContainer.addChild(myImageArray[imageIndex]); that's how i display it (of course i have added "myMCContainer to the stage").
well the real problem is when i tried to use remove child fo myMCContainer it give me error #2025, and when i tried to check number of child that myMCContainer has it returned 0 even after adding the image...
[Code]...
What (if any) is the correct way to access a property within an array of objects to sort upon. for example:
mySprite = new Sprite();
mySprite_child1 = new Sprite();
mySprite_child2 = new Sprite();
[Code]....
How would I get to mySprite.mySprite_child1.x (or any of mySprite_child1 properties) as the sort variable?
I am building a tile based game, in which the player can digg away at all the tiles.The problem im having is that my collision detection code for the tiles only will detect a collision with the first tile placed, or any tile required i explicitly code its number in.
In all other examples, tutorials and code, this should work, and yet it does not on mine.heres the specific code , the array the cildren are stored in is called dirt, as they are dirt tiles.
ActionScript Code:
for (var m:int=dirt.length-1; m>=0; m--) {
forval.text=String(m);
if (dirt[m].hitTestObject(_player)) {
[code]....
this brings me onto another problem i am having, which is that now that the collision code is inside a for statement, the above code doesnt work correctly. normally the lastx and lasty should be recorded , and if there is a collsion, the player is shifted back to the last position there wasnt a collision.for some reason now, even though it should be looping faster and detecting the lasx and lasty even faster, it isnt, and although a collision is detected (only with child 0).
I'm having trouble removing a child that I have spawned from an array. If I try to use the same for each loop that I use to address the children in the array in other functions, it removes all children that are in the array, but if I try to remove only that child, it complains the child is null. The clickListener function is working out if the crosshairs are on the cow when the mouse clicks, but I want to wait two seconds (to allow the death animation to play in the clicked cow) before removing the child.
Here's what I'm doing:
Code:
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.*;
import flash.ui.Mouse;
[Code] .....
It's the removeChild(cow) line that throws the "null" error.
the script below is for a smooth random movement around the stage with a single instance of a clip (Player) loaded from the library.how i can tell the package shown below that i want it to replicate the instance "player" on the stage multiple times and still keep the random movement for each instance of Player?so there are multiple clips all scooting around the stage at will?
PHP Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
[code]....
I have a picture on the stage that has multiple items that have hotspots/links over them that should open a child swf on top of the background and show details about the items. then have a button in the child swf itself that removes the child from over the background so the user can click on another item etc.I found this code in someone's post and I am trying to modify it so that works for multiple swf files...it currently works for a single swf.I wan to pass the name of the button in front of the .swf in the URLRequest to have the same name as the instance name of the referring button. But I can't figure it out. Here is the code I am using on the stage
View 2 RepliesI've dynamically created a whole bunch of movieclips.
I've given each clip a name based on a variable number:
mc.name = "mc"+i;
I've also use addChild to add a couple of dynamic text fields to each movieClip, named myText1 and myText2.[code]...
I'm currently working on a system that loads images (by url flash gets from PHP).Now I've got a loop with addChild that works. I've put it into an array and I need a button with addeventlistener and then remove all the images in that array.[code]
View 2 RepliesOk.. so here's the basics of the code:
ActionScript Code:
var stackNum:TextField = new TextField();
stackNum.everythingcondensedhere = everythingcondensedhere
stackNum.type = TextFieldType.DYNAMIC;
[Code]....
It creates a textfield (and an image, but not important) and a movieclip, adds the MC to the stage and adds the image(itemLoader) and the textfield(stackNum).
And then it adds it to an array at [x][y].
Then later it calls the .stackSize, adds 1 to it, and tries to update the textfield.
Everything works except for updating the textfield, I just can't figure out what I need to use to point to it and have it change.
regarding adding multiple childs to an array these childs are added using timer after a time interval.actually there two classes and child of both classes are added to stage one through timer as i described and other through keyboard event. now is it possible to do this if yes than how?? and is it possible to apply hittest object between these two array.
View 6 Repliesi want to load all the attributes by the name "pagename" within this xml file into an array : my_array
xml file:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
- <earnvaluemanagement>
- <module id="01" title="Overview" foldername="content/module_01">
[Code].....
Is there a right way to removeChild index of the array? My code is working but it throws me error once in a while; Here is my code;
var temp_array:Array = new Array;var cap_array:Array= new Array(sugar_mc,sugar_mc,cocoa_mc,milk_mc);[code]....
the error is ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.[code]...
i have problem with swfLoader in flex, when i close following code in click method i can easly add many swf to main application
<mx:VBox id="content" width="100%" height="100%" ></mx:VBox>
public function doIT():void
{[code]....
when i close adding those swfs in loop i have the same error, it looks like child apps couldn't access certain objects that were instantiated by another child app, so what can i do?
I have a movieClip with one frame on the timeline containing one child whose instance name is "myContent"I am using this function to swap "myContent" with any number of possible class instances.
Code:
function setContentAsClass(c:Class)
{
[code].....
I've used this site as a resource leading up to this, not particularly sure if I worded this correctly I have a class "Block" which is just a square (will be something else later on in the process) I want each block to have controls to add an additional block in either direction so I have another class BlockButtons which has my buttons for each direction.
And another class GlobalVar where I keep all my variables for funsies
[Code]...
var viewStack:ViewStack = new ViewStack();
viewStack.percentWidth = 100;
viewStack.percentHeight = 100;
[Code]....
Its only displaying canVas3 contents not canVas1 and canVas2
I have a component mxml file in which i have a view stack, on click of a button i navigate to the first child, now i need to navigate to the second child during onclick of a button present in the second child. All the childs are component files included within the view stack. How could this be done, Sample code is present below,
[code]...
Now in my offering.mxml file if i try to access navigationViewStack i am getting an error stating 'Access of undefined property navigationViewStack.
I've seen some discussion on how to load a child swf using swfLoader and accessing it's variables but I am wondering if it is possible to do this without adding any code to the child swf.Either accessing public vars or listening for funciton calls would work fine
View 2 Repliesi'm new to AS3 and i was wondering what is the best way to remove a child at a point. i tried Holder.removeChild(Holder.getObjectsUnderPoint(new Point(exampleX, exampleY))[0]); however that returned ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
View 2 RepliesI have an Movie Clip in Flash that have subobject of button type which has subobject of input text and movie clips. Right after creation core Moveclip all subobject are set to null, when I expect them to be valid objects.
[Code]...
MC_Core_design was created in Flash and exported to Actionscript. I've done this for button_1 class aswell. The code was written using Flex. When I comment out both lines that result in error I get correct view of the core Movie clip with all subobject. How can I set subobject properties right after object creation?
a quick low down would be its a gallery on the second frame and I breaks when coming back tot he first frame, all tweens die and such.
the errors are:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/removeChild()
at index_779_fla::MainTimeline/imageLoaded()
[code]....
I have an issue where removechild won't infact remove a child. I think its something to do with my dropTarget.parent issues. The concept of the code is that you drag a source onto a destination. When you drop the source onto the destination you will get a text field that says "Hello" or "Goodbye". The objective i want to achive is that once i drop a source onto the destination, removechild will remove any previouse textfields added. This is proving difficult.
[Code].....
I have created 2 sprites each containing a dynamic text field child. I then add this as a child of the stage. (I have done this in order to make the text clickable with a hand cursor on mouseover)It loads in fine, I just run into problems when trying to REMOVE it the sprite containing the text."ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller."Sections concerned in red:
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
[code]........