ActionScript 3.0 :: Accessing Textfields In Movieclips Added By Addchild
Nov 4, 2010
I have a bunch of movieclips which were created by "addChild" method. These movieclips are added to "gamecontainer". There was a dynamic textfield in each movieclip. Now the problem is how can I change the text in the dynamic textfield inside each movieclip outside this function.
Here is the code:
private function arrangeClips():void {
for (var i:uint=0; i<7; i++) {
var tile_mc:whiteTail=new whiteTail();
I'm building a Facebook client in actionscript, and I'm running into a problem. I have this block of code:
var loader:URLLoader = URLLoader(event.target); var feedResponse:String = (event.target.data); var object:Object = JSON.decode(feedResponse); //getting the data
what happens is a timer is kicked off, the counter counts 10 secons and fires off a rotate picture function. The rotate picture function is supposed to display 7 pictures in sequence, starting with 1.jpg, then 2.jpg, etc...
All the images are loading, but I can't get it to unload the previous image before loading the next one.
I've tried removeChild, unload();, try/catch, etc... this is the basic part of the code that loads the images....
Code:
var picloader:Loader = new Loader(); addChild (picloader); if(_picDisplayed < numOfImages+1){
At the moment, everything is output to stage in one big clump. But I can't figure how to make each text field display on separate lines. Messing with the y value doesn't seem to do the trick nor do line breaks in the XML.
Code: var dtxt:TextField; for (var i:uint = 0; i < occID.length(); i++) { dtxt = new TextField();
[Code]....
The purpose of this code is to create a dynamic textfield or a movieclip with values from an XML file to be added to stage as options in a drop down menu. Putting them in a text field or movie clip would allow me apply mouse events, etc. I'm a novice coder and so I'm just trying to feel out the best way I can handle it at the moment!
I have a movieclip in the library called flare that consists (for now) of nothing but a drawing of a pentagon. Its associated class is called Flare. The movieclip instantiates just fine, but I don't see the pentagon. When the clip is instantiated, it traces its x and its width. They are both 0. But the width should be 100.Boiled down to the extreme basics, I was getting the same result. What am I forgetting here???Document class
Code: package com { import flash.display.MovieClip;
I have a 20 frame MovieClip in the library with a Class attached to it. There is nothing in the Class except the usual stuff pertaining to MovieClips with a Class (import display.movieClip and so on). The first frame in the movieClip timeline is a stop() command. I only want the clip to play sometimes. So in the main document timeline, I add the clip from the library as such: Code: var testClip:SampleClass = new SampleClass(); addChild(testClip);
But with this instance, I also want it to begin playing. However the following is not working: Code: MovieClip(testClip).play();// doesn't work? testClip.play();// also doesn't work?
But, if I delay things a bit it DOES work - like this: Code: Tweener.addTween(testClip, {y:0, time:.5, onComplete:function() {testClip.play()}}); // works fine, clip begins playing Why delaying the play command works, but telling it to play on instantiating doesn't?
The code below is called after a thumbnail is generated and available. It is supposed to add the thumbnail to a MC along with the file name. The first go around (after a file is uploaded and converted) works, but the second time around the 2nd MC is generated and placed on stage with the correct file name and thumb image, but the first thumbnail image isappears (the file name stays).I don't understand why.
Code: function initlistener(e:Event):void{ myURLFILE = "myURL";//reset URL
I used to have the checkbox MovieClips in the menuListingClass, but I instead wanted to add them using something like addChild(). However when I try to reference the checkboxs later in the same way as I did before, I get an Error #1010: A term is undefined and has no properties. What do I need to add to reference the checkboxes like I did before?
[URL] This article seems to say that all Flex 4 elements are now being added to a project using addElement() instead of addChild(). So my only question is why the switch?
I am adding rectangles dynamically and have first added them to movie clips so that they can receive mouse events.But I am having trouble accessing their position on stage.If I set the position of the movie clip that contains them, the x coordinate returned is always 0.Is there a way to get the position of the shape and/or movie clip container.
I've added a movie clip dynamically using the following code:
var apie=new cPie() apie.x=100 apie.y=100 stage.addChild(apie)
I now have a pie on my stage. Yum. Assuming this works like a movie clip placed on the stage by dragging and dropping, I added this in to change an instance in the pie.
How do you access a child that has been added to an object?For example if I have a movieClip on the stage and I add a child to it, how do I then access that child?
Code: var newClip:MovieClip = new MovieClip(); newClip.addEventListener(Event.ADDED, checkClip);
The following code adds 10 instances of circleMC to the stage. Inside circleMC is a dyn text field that increases in number from 1 - 10 so I have numbered circles on the stage.Each circle needs to open an infoBox which will contain variables unique to that box. I can't figure out how to address each infoBox. How would I say something like on circle1 set infoBox1.visible=true?
code: var jurNum:uint = 0; addBtn.addEventListener(MouseEvent.CLICK, onAdd); function onAdd(evt:MouseEvent):void {[code]........
Code: private var notesDefinition:Array = [Note1, Note2, Note3, Note4];
When faceMc moves (while dragging or as a mouse trail), points are created dinamically every 200px and one of the array�s mclips is added there in a random function. Now i need to remove that mc when it reaches its last frame (just the mc on stage, not remove from the array). I tryed the following but its not working.
Code: private function drawingAPI(event:Event):void{ var addNewNote:Boolean = false; //add first point
I'm having accessing an object i previously added to my stage. Or at least give me some direction, or tell me if there is an easier way entirely to achieve what I'm doing.
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: function saveAction(evt:MouseEvent):void{ var choice=evt.target.name; var inputText:String = saveName.text; }
I have this and I am trying to make a variable from the contents of the input box. Simple ya? The issue is that it is a child of another clip that is being added dynamically, so it doesn't think the input exists. How do I declare the input? How can I target it's contents? Also I have a remove function that is meant to remove this same parent clip.
Code: function closeSaveWindow(evt:MouseEvent):void{ removeChild(saver); } 'saver' is a variable created in another function, so I think there is a scope issue there. To try to fix that I declared 'saver' as a movie clip as a global var.
I'm adding various movieclips to the stage with the following code:var invis_obj = new invisible_li_mc();addChild(invis_obj);However, when I try to access the movieclip such asinvis_obj.buttonMode = true;I get nothing however, something like invis_obj.alpha=0; works fine..
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 movieclip on stage: I load inside it a form (via addChild). The form is made of textfields and movieclips and it is contained in a library object of MyForm class, extending MovieClip. So I have:
var myForm:MyForm = new MyForm(); myClip.addChild(myForm);
What happens: the MyForm class lets me interact with textfields (if I change a value of a textfield I can see it very clearly). But I can't manually reach the input textfields and the buttons (they don't respont to pressure, and I can't modify their content in the case of textfields). There seems to be something related to the fact that MyForm is contained inside myClip because if I load the form without the myClip container anything works again. I tried to use mouseChildren and mouseEnabled on myClip but it doesn't work.
I have created a content navigation system using xml. On the left there are a list of items and when you click on them their descriptions load on the right. I've gotten most everything working, however the list of items (which you click on) is messing up my formatting scheme creating a run-on page. Since the items are loaded using a for var i++ method, they each been created in separate textfields. I was thinking there must be a way to load them all into a movieclip and then create a scrollbar for the movieclip itself so that the user doesn't have to scroll the entire page to view the items.
I create various movieClips with TextFields in them using the following function.
function AddLabel(Label,L) // create a MovieClip with a Text Field. { obj = this.createEmptyMovieClip("mc" + L,L);[code].....
Lets say that I use the above function with the following statement:
JimMC = AddLabel("JimVision",1);
Then I try to assign a string to the above movieClip with some embedded html like so:
JimMC.txt.htmlText = "This is my test < a href='http://bogus.com'>link</ a>.";
When I try to run the above the results come out blank. When I list my variables I do see that my TextField is being assign the text and html code. What I also notice is that the textWidth and textHeight value become zero.why my results are blank? Why do the textWidth and textHeight values become zero?
Can't figure this out for the life of me. Its probably something simple, but I can't find any solutions online. Can anyone help a brother out here? All I'm trying to do is assign text to a dynamic text box that is inside a movieclip (loaded from the library using addChild()
I'm using the following code to add movieclip from library to stage...the moviclip holds a background and textfield. now adding it to the stage works fine and i can access the textfield 1 time but after the timer fires again the refrence to the text feild disspepears . I need to access the textFeild every time the timer fires so what am i doing wrong? HOw do i keep refrenct to the text field?
PHP Code: tim0 = new Timer(1000,30); private function PrepTime(e:TimerEvent) {