ActionScript 2.0 :: Dynamically Access Created Objects?
Sep 11, 2011Way to make a dynamically created object and remove it when it hits another dynamically created object, like a bullet?
View 9 RepliesWay to make a dynamically created object and remove it when it hits another dynamically created object, like a bullet?
View 9 RepliesAlright, so I'm creating objects dynamically,[code]...
View 4 RepliesIf 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 scroll pane with textboxes and buttons that are dynamically created in a function. The textboxes are a user list that can get very long.
I am having problems where once I get out of this frame I want everything to be removed. I have tried removing the scroll pane but all the dynamically created objects remain. Is there some command when you enter a new frame to clear all objects or something along that line?
I am learning AS3, and I am trying to understand how to target dynamically created objectsI have the code:
Code:
for (var i:Number = 0; i<5; i++) {
var boton:CreateButton(stage.stageWidth/5,30,0,1,colors[i],test,0xFFFFFF,"English");
[code].....
I need to be able to make a large amount of concentric circles, using only the action script. I need to be able to alter each of these concentric circles independently from each other. Currently My code is as follows:
ActionScript Code:
var circ1:MovieClip = new MovieClip();
addChild(circ1);
[code].....
iam in a situation to convert the dynamically created objects( just movieclips which contains boxes,texts etc) in flash using AS3 to .DWG format. i tried converting the flash objects in to SVG format , then tried to open it in Auto Cad , but the texts are not editable in auto Cad;
View 0 RepliesSo I have an object, generated on each click of the mouse. It's set up as a series of points with properties, with values for position randomly calculated, and set around where the user clicks the mouse. Lines are drawn from where the mouse is clicked out to each of these points, so it kind of looks like a star, but only lines, rather than a solid shape (like those old 50's atom clocks?). So once clicked there's an enter frame event listener on the object so that each of the points 'wobble' (using a randomly generated number) up and down around the original point.
For some reason, I can either set it so that on each new click of the mouse and newly generated object, the last one stops "wobbling" and only the new one does, or each new object moves to where the new object is, and maybe is still wobbling(?), but is underneath the new object. This way has the event.target as a new object in the wobble function, so I think it may be just a case of where the centre point is - i.e. saving the mouse x and y for each object individually, or perhaps I have too much of the setup function code repeated in my "wobble"function?
[Code]...
i have 2 layers, called typer layer and plain layer... on the plain layer i have drawn out a shape... like a circle for instance.... if plain layer is on top of typer layer everything works fine. if plain layer is below typer layer the typer does not type.... it doesnt even show up. at present the dynamically created text field into which the typing text will be put into has a depth equivalent to that of a guide inside the component (just a plain mc used for determining sizes etc nothing special) +1 i added 1 to its current depth because if i dont i only seem to get EITHER the circle OR the typer.... whereas if i add 1, i get EITHER the typer AND the circle OR just the circle..but this doesnt make sense does it? i mean if the typer layer is on top then it has a higher depth (ie. closer to zero as depths are currently in the negatives still ) so if i add 1 it shouldnt conflict with anything and i should get it typing and displaying the circle surely?and if it is below then the circle has a higher depth so in this respect if the typer wouldnt work when it is on the bottom i could understand this as the depths would be conflicting and as such the dynamically created text field couldnt be created in the first place because the depth level is already occupied....
View 12 RepliesHow do I access the methods of a dynamically created movieclip/object?
For simplicity sake I didn't post code on how I dynamically created the movieclip. Instead, assume its already created. It is an object. It is called field_2. Below it is referenced by using getChildByName('field_' + field.id);
Check_box_component.as
public var testVar:String = 'test';
public function testReturn()
{
return 'value returned';
[Code]...
When I trace temp.testReturn, why does it show "function Function() {}" instead of "value returned"?
This link below helped me get this to this point.
[URL]
I have created Movieclip in main actionscript file main.as :
var drawingSign:Movieclip = ne MovieClip();
drawingSign.x = 40;
drawingSign.y = 40;
How could I access it (add listeners etc.) from a class file?
im building a full as anything text-typing-component... easily modified and adapted etc...one problem however... i came across a depth issue in testing.... its a little peculiar so you will have to bear with me... i have 2 layers, called typer layer and plain layer... on the plain layer i have drawn out a shape... like a circle for instance.... if plain layer is on top of typer layer everything works fine. if plain layer is below typer layer the typer does not type.... it doesnt even show up....
[Code]....
I'd like to be able to dynamically access objects from with in a function. In javascript I might say something like window[objectName] and assign it to a temp var or call a method from it. How can I do this in AS3?
Use case:I have a currentReport var that holds the name of the currently active report. When a new report is called I want to unload the current report then load the new one and finally set the currentReport var to the new value.
I'm dynamically creating movieclips with dynamically created movieclips inside them and am having trouble with targeting them.Below is a simplified example of what I'm trying to achieve, in the real file there are a lot more movieclips and I'm creating and naming them with a for loop.
This one is just one Sprite created inside another sprite. I can target the top level sprite named "testname". However when i try target the nested MC it throws an error.The bottom couple of traces are just test MCs I've made to make sure i got the syntax right, on targeting nested movieclips.
PHP Code:
var holder:Sprite = new test1();holder.name = "testname";this.addChild(holder);var holder2:Sprite = new test2();holder2.name = "testname2";holder.addChild(holder2);trace(getChildByName("testname").x); //this one traces finetrace(getChildByName("testname").getChildByName("testname2").x);//this throws up an errortrace(testclip1.x);trace(testclip1.testclip2.x);
Essentially, I've got a MC container that's created dynamically based off an XML file (basically for every <title></title> I've got, it makes a new "card"). Now within the context of each <title></title> grouping I've got <imgs></imgs> in which I specify the path to images that are related.All of that works perfectly, save for the external jpg files actually appearing on the stage. The MC I add them to does, but the external image doesn't.My problem is- I can't add the external images until they're completely loaded (or so it appears). The thumbnail BG I use is blank. So I know for a fact that the thumbnail BG isn't occluding the loaded thumbnails.
View 2 RepliesSo, you have a sprite, you draw some graphics, you set cacheasbitmap=true... I can't seem to access the newly created bitmap data, to access the dispose() method.
[Code]...
If I press the button for the photogallery it creats new Objects, and dont erase it after i go back to main. So long its load all the objects in the memory and its exists all the time...
But I want that, delete all the objects from the memory after i go back to the main!
here is the source code:
Code:
/*
Created by Min Thu
http://www.flashmo.com
AS3 References and Credits
[Code]....
i created a "for" function who īll display an X number of buttons with addChild, and give a name for each using button.name = "name" + variable but later if I want to listen for the buttons using their name donīt work, already know that there is getChildByName so i tried but give me the same error who tells that there no object with that name.My question is, how i can listen for the objects created if i already have a name for each one of them? here is the code im doing.
for(var i:int = 1; i <6;i++){var miBoton:boton = new boton();var miTexto:TextField = new TextField();miBoton.x = i * miBoton.width + (i* 10);miBoton.y = 20;addChild(miBoton);miBoton.name = "boton" + i;miTexto.text = "hi";miBoton.addChild(miTexto);trace(miBoton.name);trace(miBoton.parent);}
I have an issue in flex which is causing a bit of a headache!
I am adding objects to an ArrayCollection but in doing so, another ArrayCollection is also picking up these changes even though there is no binding occurring.
I can see from the debug that the two ACs have the same address but for the life of me can't figure out why.
I have two Array Collections:
model.index.rows //The main array collection
model.index.holdRows //The array collection that imitates the above
This phantom data binding occurs only for the first iteration in the loop and for all others it will just write it the once.
The reason this is proving troublesome is that it creates duplicate entries in my datagrid.
public override function handleMessage(message:IMessage):void
{
super.handleMessage(message);
[Code]....
So I'm trying to create an object in my document class then reference it from a custom class file.I'm creating a photoContainer MC in the createPhotoContainer method and directly after it's creation it gets passed to the GalleryView class by calling it's constructor function.
ActionScript Code:
public class GalleryDocument extends MovieClip
{
[code].....
Why does this work...
textForContent = ["1.xml","2.xml","3.xml","4.xml","5.xml","6.xml","7 .xml"]
counter = textForContent.length-1;
while (counter>=0){
[code]....
And this does not work? All I've done is try to create 7 new XML objects using the counter...
textForContent = ["1.xml","2.xml","3.xml","4.xml","5.xml","6.xml","7 .xml"]
counter = textForContent.length-1;
while (counter>=0){
[code]....
The following creates movieclips from XML. Everything worksgreat.One problem however. I need each MC to have it's own mouse event listener anddon't know how to achieve this because I don't have specificinstance names to refer with. I want to update textfields etc, with specific data when a
View 3 RepliesI have a function that appends 7 movieclips to the timeline in a loop. The name of the clips is generated automatically:
[Code]...
I'm creating receives xml from the asp server its on.Because of this, there isn't an xml file that I can open and add to in the places I need carriage returns.To compensate for this, I've been using the split and join method.[code]Essentially I'm looking for certain nodes in the xml and adding a carriage return to the beginning of it.I had to add the extra quotes around the otherwise it doesn't work.The problem with this is, the carriage return works but it leaves the single quotes in the text.I tried adding another split join method that looks for the single quotes left and replaces them with nothing.The problem with this is, it deletes all the single quotes from the contractions.
View 4 Repliesnow a customer wants me to make a Flash intro in her (ASP MVC) site. The scenario is this: images are stored in the dbms. Every image belongs to a category. Depending on what category is selected, the corresponding images should be fetched and played in a flash player with "transition" effects (hope i used the correct words).How can a slideshow (swf) be created dynamically?
View 1 Replieshow should the path to the MC look like in case when his "parent" is dynamically created? i want to target my_FLVPlybk, which can be found in every duplicated "movie".
ActionScript Code:
for (i=2;i<21;i++) {
duplicateMovieClip ("movie1", "movie"+i, i);
newclip = _root.container.multimovie["movie"+i];
[code]....
If I create a mc within a "xml function" like this:
[code]...
Is it possible to have dynamically created variablenames in AS?What I was thinking was something like this:
for (i = 0; i < 5; i++) {
"myVariable_" + i = "Whatever";
}
[code]......
I am guessing the onLoad event handler doesn't work for dynamically created movie clips (with attachMovie) because it never gets loaded.. Is there any other way i can do something when it first gets created?
View 6 RepliesI've made xml gallery which has simple slideshow in starting and after clicking on that its takes to the xml loaded scrolling mc which is not scrolling properly like the tuts here in Kirupa. I've following code for that
function ScrollingCollectionTimeLine(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = page_collections._xmouse/725;
//trace(mousePercent);
[code].....