SEARCH YOUR SOLUTION HERE  

Controlling .text prop of a TextField as a child object of a MovieClip - not working

,

I know this one is going to sound ridiculously stupid, but while I am more than capable of controlling the text property of a TextField when it is on the stage by itself, my testing of a altering a TextField's text as a child of a MovieClip object is failing miserably. Can anyone tell me what kind of knuckleheaded mistake I'm making I tried to write out the code as clean as possible below...

//IMPORTS...



//VARIABLES...

//create movieclip object
var myMovieClip:MovieClip = new MovieClip();

//create object to be made a child object of myMovieClip
var myChildObject:TextField = new TextField();
myChildObject.text = "Child Object";
myChildObject.name = "Object1";//COMMANDS... TextField

//add myChildObject as a child of myMovieClip
myMovieClip.addChild(myChildObject);

//place myMovieClip on the stage
addChild(myMovieClip);//ADDEVENTLISTENERS...

//this will allow user to click on the stage activating a change in the x-coordinate of myChildObject
stage.addEventListener(MouseEvent.CLICK, changeChildObjectProperties);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, add2ndObject);//FUNCTIONS...

//ADDEVENTLISTENER FUNCTIONS...

function changeChildObjectProperties(event:MouseEvent):void
{
//CHANGING THE 'x' & 'width' PROPERTIES WORK JUST FINE...
myMovieClip.getChildByName("Object1").x += 50;
myMovieClip.getChildByName("Object1").width = 250;

//!!!THIS IS THE THING THAT DOESN'T WORK NO MATTER WHAT...

myMovieClip.getChildByName("Object1").text = "Object1's text has been changed...";

}

function add2ndObject(event:MouseEvent):void
{
var my2ndChildObject:TextField = new TextField();

my2ndChildObject.name = "Object2_" + myMovieClip.numChildren;
my2ndChildObject.text = my2ndChildObject.name;

myMovieClip.addChild(my2ndChildObject);

my2ndChildObject.y += 20;
}

//END ADDEVENTLISTENER FUNCTIONS

//NORMAL FUNCTIONS...



//END NORMAL FUNCTIONS

//END FUNCTIONS

Posted On: Thursday 25th of October 2012 11:13:36 PM Total Views:  343
View Complete with Replies




Related Messages:

controlling flv playback component skin x and y   (104 Views)
Hi , Is it possible to control the x and y of the video component skin I can see Code: my_vid.skin which will trace out the actual .swf file of the skin, but not sure how i can adjust the x and y. I mainly want to adjust the y position of the skin and I've done quite a bit of research but can't find this issue specifically. Anyone
controlling a list of movie clips   (94 Views)
hi im trying to get a button to move a list of movie clips up and down how would u go about this e.g i have a button at the top of the stage and a button at the bottom and when the top one is clicked it moves up one movie clip till last one is hit. and if the bottom one is hit it moves down one until it hits the last one any help im not very good at explaining my self sorry
controlling external mp3 sound clips with keyboard commands   (100 Views)
Hi all, I am new to kirupa and new to as3! I'm trying to control my mp3 sound clips with keyboard commands and have managed to get this to work with internal sound clips: //************************************************** ************* var note2:b = new b(); btn2.addEventListener(MouseEvent.MOUSE_DOWN,playNo te2); function playNote2(event:Event){ playSound(note2); } function playSound2(soundObject:Object) { var channel:SoundChannel = soundObject.play(); } //************************************************** ************* //btn2 btn2.addEventListener(MouseEvent.MOUSE_UP, bOut2); btn2.addEventListener(MouseEvent.MOUSE_DOWN, bDown2); function bDown2(event:MouseEvent):void { btn2.gotoAndStop(2); } function bOut2(event:MouseEvent):void { btn2.gotoAndStop(1); } btn2.buttonMode = true //keyboard****************************************** *********** stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown2); function myKeyDown2(e:KeyboardEvent):void{ if (e.keyCode == Keyboard.W){ playSound(note2); btn2.gotoAndStop(2); } } stage.addEventListener(KeyboardEvent.KEY_UP, myKeyUp2); function myKeyUp2(e:KeyboardEvent):void{ if (e.keyCode == Keyboard.W){ btn2.gotoAndStop(1); } } however I cannot seem to get this method to work using external sound clips. here is my code so far: var note1:Sound = new Sound(); note1.load(new URLRequest("un.mp3")); btn1.addEventListener(MouseEvent.CLICK,playSound); function playSound(e:MouseEvent):void{ note1.play(); } //hovers btn1.addEventListener(MouseEvent.MOUSE_UP, bOut1); btn1.addEventListener(MouseEvent.MOUSE_DOWN, bDown1); function bDown1(event:MouseEvent):void { btn1.gotoAndStop(2); } function bOut1(event:MouseEvent):void { btn1.gotoAndStop(1); } btn1.buttonMode = true //keyboard stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown); function myKeyDown(e:KeyboardEvent):void{ if (e.keyCode == Keyboard.Q){ playSound(note1); btn1.gotoAndStop(2); } } stage.addEventListener(KeyboardEvent.KEY_UP, myKeyUp); function myKeyUp(e:KeyboardEvent):void{ if (e.keyCode == Keyboard.Q){ btn1.gotoAndStop(1); } } I have searched all over the forums and the internet and cannot seem to find an answer for my issue, any help that one could offer would be greatly appriciated!
controlling loaded external swf   (90 Views)
it should be very very easy but i can't understand what i did wrong. i loaded an external SWF, and i want to control it's current frames.. how can i do it i'll be very
Flash keyboard event and controlling timeline   (106 Views)
I am very new to AS3. I have not wanted to migrate to it, but have been forced to do it for a current project which uses AS3 components. I am creating a slideshow (full screen) and will be creating each slide as a separate SWF file. I have been successful in loading and unloading the slides (SWF's). I need to use the arrow keys to move through the slides. I have that working, but want to load the slides without hard coding everything in each frame of the main timeline. I am using a var to get the currentFrame value. is well exept that if the left arrow key is pressed and the main timeline is on FRAME 1, the playhead seems to think it can go backward to frame zero and then into negative numbers with each press of the left arrow key. I need to be able to stop the timeline from advancing backward at frame one. I have tried several methods that either do nothing or cause the right arrow key to work unpredictably and keep returning to FRAME 1 no matter what if statement and evaluation I perform. Here's the current code on FRAME 1 of the main swf: Code: stop(); stage.displayState = StageDisplayState.FULL_SCREEN; import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("slide1.swf"); loader.load(defaultSWF); addChild(loader); var currentFrameNumber:Number; currentFrameNumber = currentFrame; function setup() { stage.addEventListener(KeyboardEvent.KEY_DOWN, useKeys); } setup(); this.stage.addEventListener(Event.ENTER_FRAME, checkFrame); function checkFrame(e:Event):void { if (MovieClip(root).currentFrame
controlling public embeds (turn on/off)   (111 Views)
This isn't directly AS3-related, but I'm not sure of the best mechanism to do this, so apologies if this isn't in the right forum. We have a video player that we will soon allow others to embed freely with our content. We need some sort of mechanism to be able to turn off the embedding by either a certain video (globally, all embeds of that video), or by a specific embed (one instance of a specific video on a specific site). For instance, if one of the photographers we work with comes back to us and says that we can't allow their work to be embedded on another site, we'd like to be able to turn that specific video off globally in embeds. Instead of the video, an image directing the viewer to our site (where they *can* see the content) might be shown. In another instance, some other site might be showing one of our videos in a manner we don't feel is appropriate, or in violation of our terms. We'd like to be able to turn that specific video off on that specific site only. Can anyone think of a good way to approach this The only thing I can think of is to generate and include a unique ID with each piece of embed code, which we'd have to then track and control via some sort of backend tool. Each time one of our videos is shown, their server has to connect with ours in order to validate the unique ID based on its state (on/off), and then the player is given the OK to play. Another options that would give us much less control, but wouldn't require the same level of technical wizardry, would be to maybe disallow access from a specific domain via the .htaccess file. Any other thoughts
Extending events, passing parameters to event handlers and controlling MCs   (105 Views)
Ok, I assume this issue has been covered to death, but I'm still lost. In my application, I have numerous buttons which, when clicked, will activate numerous movie clips. To avoid having to create individual event ahndler functiosn for each button, I would like to be able to pass parameters to the event handler so it knows which movie clip to activate. In other words, here's what I'd like to do: Code: for (i=0; i
controlling an object placed by a class   (111 Views)
sorry if duplicated... i have two movieclips on stage, one load as a class an mc with animation, the other load a button...how can i send the message, comunicate both clases to let the button start the animation
Problem controlling an embedded SWF   (103 Views)
everybody! I'm having some trouble with a video (FLV) that I am trying to play while inserting an other layer above it. I want my output SWF file to contain the whole video inside. The only method of doing so was to convert the FLV file into a SWF file, and embedding the SWF: [Embed(source="file.swf")] The embedded video is uncontrollable. I can't stop or mute the embedded swf.... Even before adding it to the stage, the video's sound is heard. Am I doing something wrong Could there be a different method to embed a FLV file so my output SWF file will contain it (and there won't be a need to load it through a URL).
controlling divs in dreamweaver with flash buttons   (99 Views)
Hi all, thanks in advance for your help. This is the situation: I have created a website in Dreamweaver and it functions entirely upon hiding/showing divs, using the appropriate behavior (very basic html knowledge on my part So it's just one page in which layers are alternatively hidden and shown. I have created a set of flash buttons (they are all in one file, because a very basic Flash animation is supposed to make them fade in one by one when another flash button inserted in the html page is activated). Now, I have two problems regarding this: 1. On page load, this "animation" (the buttons which fade in successively one after another) appears automatically, even though it is located inside a div which is invisible by default and should only be visible at the trigger of a button. This is not acceptable for me because it is a submenu which should be invisible at first. 2. Let's suppose item #1 is resolved. Different html divs are supposed to appear/be hidden when rolling over each of these Flash buttons, and I haven't been able to find out how to do this. I know I should work with the Flash code in order to do this, "on (rollover) {//no idea what to place here to call the Javascript function from dreamweaver which I don't know how to create, if it's not applied directly to an object//} So if anyone can help me out with this, I'd really appreciate it! Don't hesitate to ask for clarifications... thanks! ps: This is the site: www(dot)wise-ls(dot)comlu(dot)com (I'm working on expanding the width, that's why it looks funny The section in question is "soluciones", and what I want to do is replace the text links with Flash buttons.
AS3:KEEP DYNAMIC BUTTONS DOWN when controlling image galle   (124 Views)
, please help me on this last part of my project. I'm sure it's really simple but I can't seem to figure it out: I have dynamically loaded buttons (thumb) and images (galImage) going to container_mc and full_mc containers respectively. I can't get the buttons to stay down when pressed using MOUSE_DOWN and MOUSE_UP. When I use CLICK instead, they all stay pressed. Please help! //Load Gallery Images and Thumbs for (var i:Number = 0; i < sub_menu1.selectedItem.gallery.length(); i++) { //Load Gallery Images var galImage:Loader = new Loader(); var galUrl = sub_menu1.selectedItem.gallery[i]; galImage.load(new URLRequest(galUrl)); //Create Thumbs var thumb = new ThumbButton(); thumb.image = galImage; thumb.name = i; thumb.y = 20*y_counter; thumb.buttonMode = true; thumb.graphics.lineStyle(1,0xFFFFFF); thumb.graphics.beginFill(0xFFFFFF,0); thumb.graphics.drawRect(0,0,15,15); thumb.graphics.endFill(); y_counter++; //Add Thumbs to Container container_mc.addChild(thumb); thumb.addEventListener(MouseEvent.MOUSE_DOWN, showFull); thumb.addEventListener(MouseEvent.MOUSE_UP, stayClear); function stayClear (ev:Event):void { ev.target.graphics.clear(); ev.target.graphics.lineStyle(1,0xFFFFFF); ev.target.graphics.beginFill(0xFFFFFF,0); ev.target.graphics.drawRect(0,0,15,15); ev.target.graphics.endFill(); } function showFull (evt:Event):void { full_mc.x = 420; full_mc.y = 100; full_mc.addChild(evt.target.image); evt.target.graphics.lineStyle(1,0xFFFFFF); evt.target.graphics.beginFill(0xFFFFFF,1); evt.target.graphics.drawRect(0,0,15,15); evt.target.graphics.endFill(); }
controlling an external SWF   (143 Views)
I can't find a way to control an external SWF in AS3 like I used to be able to in AS2. This used to be a real simple way (among others) in AS2: loadMovieNum("yourMovie.swf",1); onMouseDown = function(){ _level1.stop(); } onMouseUp = function(){ _level1.play(); } Unfortunately this has been abolished in AS3 . To load a SWF externally from a separate SWF file (on a separate CPU) in AS3, you now must now use a URL request along with a load request. However, the SWF is tied into this loader object of which's class does not contain "play", "stop", "currentFrame", "nextFrame", "prevFrame", "gotoAndPlay", "gotoAndStop", etc..... According to the help panel, you can target any of the loader's child's methods by virtue of calling "loader.content".... but it doesn't work. When I trace my "loader.content".... all I get back that it is an [Object Main Timeline] when I would expect it to be [Object MovieClip] if it were to have the methods I need. Inevitably.... I need to do all sorts of gotoAndStop / gotoAndPlay functionality with external SWFs on another CPU. I have a nice XML server running successfully... I just hit this brick wall.... any suggestions thx
controlling a movieclips timeline from within itself   (156 Views)
Greetings. How do I control the timeline from a movieclip from within itself I made a menubutton for a school assignment. To make it, I created a movieclip of the button's graphic, with on the second frame the button again but with the menu open (haven't added anything in it yet). Opening the menu is as easy as Code: menu_mc.addEventListener(MouseEvent.CLICK,openMenu); function openMenu(evt:Event):void{ this.menu_mc.gotoAndStop(2); } Inside of the menu is a CLOSE button (just a movieclip) that should, when clicked, take menu_mc back to frame one. A simple gotoAndStop() doesn't work. Using a parent to issue the order to the movieclip doesn't work either. -How can I make menu_mc go back to frame 1 when clicked on inside itself note: I am also open to the suggestion that I'm just going the wrong way about this. I'm really learning as I go here.
controlling the browser scrollbar with as3   (209 Views)
, I have a simple gallery that rearranges itself when the stage is re sized. Can anyone help me with adding a scrollbar to the browser once the stage size is small enough. I want to add a scrollbar to the browser window when the stage height is reduced below a level.
controlling movieclip from hierarchically equal movieclip   (103 Views)
, first flash website. I'm a designer, wanting to make a portfolio website. So i have 4 movieclips on stage, with - when you click on it - a dynamic drop down menu, each placed within these respective movieclips. This works fine. Now I should add next functionality: when the movieclip1 is clicked (and the menu drops down), the other 3 should be with menu dropped in (so one of these three will have a menu dropping back in, while movieclip1 menu is dropping down.) So i guess i could put my question this way: 1) how can i control from within movieclip1 actions in hierarchically equal movieclip2, 3 , 4, ... 2) how to do it efficiently in code I tried already a lot of stuff, please check the fla file in attachment. It's only this step away from a website... http://www.sendspace.com/file/2hluz9
XML text: controlling the MC   (112 Views)
Hi! I am loading text from an XML file into dynamically created MCs. How do I target those MCs so that I can change where they are, their alpha, etc. For example, I want them to have zero alpha until the image from the XML node they're in is loaded, then make them visible. XML: PHP Code: portfolio/01.jpg one AS: PHP Code: functionxmlLoaded(e:Event):void{ varloadedxml:XML=newXML(e.target.data); for(vari:uint=0;i
Parent SWF controlling Child SWF variables   (130 Views)
1) The code below works but the browser sends an annoying alert message Received Parent Message and you are obliged to click OK before the program can run. How can it be fixed 2) Why this code needs to use the ExternalInterface class if the Child SWF gets loaded and becomes incorporated in the Parent SWF 3) Is there a simpler and more straightforward way for a Parent SWF to communicate with a Child SWF package { import flash.external.ExternalInterface; import flash.display.Sprite; import flash.text.*; public class ChildMovie extends Sprite { public function ChildMovie():void { // } public function alert(msg:String):void { ExternalInterface.call('alert', msg); txt.text = msg; } } } package { import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.display.LoaderInfo; import flash.display.Sprite; public class ParentMovie extends Sprite { public function ParentMovie():void { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, onLoadComplete); loader.load(new URLRequest('ChildMovie.swf')); } private function onLoadComplete(e:Event):void { var loaderInfo:LoaderInfo = e.target as LoaderInfo; addChild(e.target.content); var swf:Object = loaderInfo.content; swf.x = 75; swf.y = 50; swf.alert('Received Parent Message'); } } }
bulleted links: controlling margins / splitting   (105 Views)
I have been working on an animation with Actionscript 3.0 (see link below) that utilizes an xml file to dynamically populate a text field with links. I am then putting them into some sort of bulleted list. I am having a problem fine-tuning the formatting of links whether they be in a ul list or some approximated styling. I first put bullet styling in as3. But I could not control the margin spacing between the bullets and the links so it was too big for my the small space for the rounded rectangles. I then tried to put it in an ul html list, same thing, couldn't control that margin space. I don't think Flash/Actionscript allows for this type of formatting. Is this true Then I tried to add a break and a space in the xml. For some reason, flash breaks it into 2 links, even though I put the break and the space within the link. I even tried to put in a placeholder symbol in the xml and then replace it after importing the xml into flash. When Flash parsed the html text. it again broke it into 2 links. I also tried to add the break and the space in the Actionscript, same thing 2 links. (See the first bullet point in the yellow popup). The text needs to indent and not wrap under, any suggestions
controlling main swf through sub swf   (110 Views)
i have main fla its name "sections.swf" it loads sub swf files "sec1.swf" that has animation that open window movie clip with instance name "cont" and a close btn inside "cont" with instance name "close" i want to play a specific frame on "mainSection.swf" when i click the "close" button my code: Code: close_btn.addEventListener(MouseEvent.CLICK, closeBox, false, 0, true); function closeBox(evt:MouseEvent):void { // This tell the window to play its timeline cont.play(); // This tell the "mainSection.swf" play its timeline, lets say label "sec1" MovieClip(parent).play("sec1"); }
controlling an embedded movie   (96 Views)
I have embedded a move clip into flash. I want to control it, loop and and move to frame. I tried myMovie.stop() and myMovie.gotoAndPlay(20); 1061: Call to a possibly undefined method stop through a reference with static type flash.media:Video.