Problems with removechild

I wonder if someone can help me with removeChild

i made a class preloadContent, it preloads content

but when i want to load the next external image or swf he doesn't remove the old content, can someone help me with that, its a reocuring problem for me i dont understand the removechild stuff.

this is my class:

Code: package { import gs.*; import gs.easing.*; import flash.display.*; import flash.display.StageAlign; import flash.display.StageScaleMode; import; import*; import*; public class PreloadContent extends MovieClip { public var main; public var xmlmenu; public var imageLoader:Loader; public var container; public var placeholder; public var changeSize; public var url; public var firstTime:Boolean = true; public var hoog; public var breed; public function PreloadContent(mainClass, container, placeholder, changeSize):void { this.main = mainClass; this.container = container; this.placeholder = placeholder; this.changeSize = changeSize; } public function preloadContent(contentUrl, hoog, breed):void { this.url = contentUrl; // Show Preloader this.placeholder.preloader.visible = true; this.hoog = hoog; this.breed = breed; // Set properties on my Loader object imageLoader = new Loader(); imageLoader.load(new URLRequest(url)); imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded); } public function imageLoaded(e:Event):void { // Hide Preloader this.placeholder.preloader.visible = false; this.changeSize.changeSize(this.hoog, this.breed); // The container animation takes 1 seconde so wait until the animation is done and then load the image, 1, {onComplete:placeContent}); } public function placeContent():void { // remove content if (firstTime == false) { this.placeholder.imageLoadArea.removeChild(imageLoader); } // Load Content this.placeholder.imageLoadArea.addChild(imageLoader); trace(image); firstTime = false; } public function imageLoading(e:ProgressEvent):void { // Get current download progress var loaded:Number = e.bytesLoaded / e.bytesTotal; // Send progress info to "preloader" movie clip this.placeholder.preloader.SetProgress(loaded); } } }

Posted On: Thursday 25th of October 2012 10:33:21 PM Total Views:  252
View Complete with Replies

Related Messages:

problems with line breaks in a "Input Text Field"   (51 Views)
Hi all, I've create a email form in flash that uses ac3 and php to send out an email when the users click on the submit button. However, the email I receive loses all line break information. example: user inputs: hi there form I will get an email that is 1 line only "hithereform" Here is the ac3 code: function submit(e:MouseEvent):void { if(contactName_txt.text == "" || contactPhone_txt.text == "" || contactEmail_txt.text == "" || contactMessage_txt.text == "") { message_status.text = "invalid text."; } else if( !validate_phone(contactPhone_txt.text)) { message_status.text = "invalid phone."; } else if( !validate_email(contactEmail_txt.text)) { message_status.text = "invalid email."; } else { message_status.text = "sending"; var email_data:String = "name=" + contactName_txt.text + "&email=" + contactEmail_txt.text + "&subject=" + "Web Form Message" + "&message=" + contactMessage_txt.text; var URL_vars:URLVariables = new URLVariables(email_data); URL_vars.dataFormat = URLLoaderDataFormat.TEXT; = URL_vars; var_load.load(URL_request); var_load.addEventListener(Event.COMPLETE, receive_response); } } And the php code: Can anyone tell me what I did wrong Thank you very much in advance
exporting problems   (93 Views)
I did post this elsewhere but think it was the wrong forum. Basically I have made a flash animation and published it as a .swf and everything is lovely and as it should be. Then I go to export it as a quicktime (which I have done loads of times before with no problem) and no matter what size the stage is, it exports portrait, so as my .fla is 640x480 it looks distorted and completely unwatchable. When I go through the export settings it says '640 x 480' - so what's going wrong I must have changed some crucial setting at some point, because as I said, I've never had this problem before. Does anyone have any ideas
[CS3] Flash Lite 1.x button navigation problems   (77 Views)
basically I have a grid of 9 icons, exactly like a typical phone menu, but unfortunately I can't post any more details about it (Ive signed ND forms) - Just imagine a standard menu, with 9 icons (3x3). They have rollovers that play movie clips. Now all except one of them function normally, when you press the phones "right" button, it highlights the icon to the right (and so on), but when I reach this one Icon, it skips it and highlights the Icon after it... Which messes up the navigation as it's very difficult to highlight that particular one... any clues
[F8] Preloader problems   (75 Views)
For a preloader where an 100 frames movie advances as it loads, I used these actions: stop(); onEnterFrame = function () {totalBytes = _root.getBytesTotal(); loadedBytes = _root.getBytesLoaded(); percent = Math.ceil((loadedBytes/totalBytes)*100); _root..gotoAndStop(percent); if (percent=100) {play(); } }; If there's a stop action in a later frame, it is ignored. If I use gotoAndStop(x) instead, if there's a play button at that frame, it won't work. What should I do or event.currentTarget problems   (67 Views)
Ok, I have a Flex 4 List component which I have tied a click event to. In my event, my assignment of the source file paths works just fine --> my larger image displays just fine when a thumbnail click happens. My problem comes when trying to attach elements of the dataProvider to text inputs on another panel. Actionscript is throwing an error. Can someone point me in the right direction Error: ReferenceError: Error #1069: Property keyword not found on __AS3__.vec.Vector. and there is no default value. Here is my AS code (my commented code was me attempting to use a changingHandler that did not pan out): ActionScript Code: [CDATA[ import mx.controls.Alert; import; //var thumbsPic:Event = mediaThumbs.dataProvider.getItemIndex(event.newIndex); //This getImage function will handle a click event when user clicks //on thumbnail to get a bigger image to show in viewer panel private function getImage(event:MouseEvent):void { bigView.source =; kywrd.text = event.currentTarget.selectedItems.keyword; //"Now is the time for all good men to come to the aid of their country"; } //protected function mediaThumbs_changingHandler(event:IndexChangeEvent):void { // TODO Auto-generated method stub //bigView.source =; //bigView.source = thumbsPic.imageFile; //bigView.source = mediaThumbs.dataProvider.getItemAt(event.newIndex).imageDisplay.source; //var item:* = mediaThumbs.dataProvider.getItemAt(event.newIndex); //bigView.source =; //} ]]> Any shove (no matter how NOT gentle) in the right direction would be appreciated. Tony
Tween problems   (69 Views)
I have a class in my project that reacts to mouse over and mouse out events. Code: public class cPanel extends MovieClip { private var _panel:Loader = new Loader(); private var _panelData:Object = {posX:int, posY:int, p:String, endPos:int}; private var _url:URLRequest; public function cPanel(panel:String, pX, pY, prop, end) { _url = new URLRequest(panel); _panel.contentLoaderInfo.addEventListener(Event.COMPLETE, startPanel); _panel.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorPanel); _panelData.posX = pX; _panelData.posY = pY; _panelData.p = prop; _panelData.endPos = end; } public function loadPanel() { _panel.load(_url); } private function startPanel(e:Event) { _panel.addEventListener(MouseEvent.MOUSE_OVER, panelUp); _panel.addEventListener(MouseEvent.MOUSE_OUT, panelDown); addChild(_panel); this.x = _panelData.posX; this.y = _panelData.posY; } private function panelUp(e:MouseEvent) { var tween:Tween = new Tween(_panel,_panelData.p, None.easeOut, _panelData.posY, _panelData.endPos, 1,true); } private function panelDown(e:MouseEvent) { var tween:Tween = new Tween(_panel, _panelData.p, None.easeOut, _panelData.endPos, _panelData.posY, 1,true); } This is instantiated at main level and added to stage. When I move my mouse over the instance displayed it disappears from stage. Probably something basic I do wrong but I'm codeblind at the moment so... Anyone /T
problems with addChild in an imported *.as file/package   (90 Views)
I'm trying to get an image to appear on a screen through a class, and I keep getting: Quote: Location:, line 21 Description: 1180: Call to a possibly undefined method addChild. Source: addChild(sp); I've tried to fix it on my own, but it isn't working. my code for the files is below. ActionScript Code: package newRPG_Class { import flash.display.Sprite; import flash.display.Shape; public class Stuff{ //height, width, allow move over protected var occup:Array; protected var desc:String; public function Stuff(a:int, b:int):void { addToStage(a, b); } public function addToStage(c:int, d:int):void { description("This is stuff"); var sp:Sprite = new Sprite(); with( { beginFill(0x0000FF); drawRect(c, d, 5, 5); endFill; } addChild(sp); //line 21 occup = [5, 5, false]; } function description(words:String):void { desc = words; } function takeUpSpace():Boolean { if (occup[2] == true){ return true; } return false; } } } RPG.fla ActionScript Code: import newRPG_Class.Stuff; import flash.display.Sprite; var grape:Stuff = new Stuff(4,4); addChild(grape); So, what am I doing wrong, and how can I fix this and prevent this in the future
making a text box draggable.. (problems)   (76 Views)
ok so it seems so simple, ive got a text box a user can enter some information, an add_btn whcih will place the text onto an image inside a UILoader. i keep getting this error : Quote: TypeError: Error #1010: A term is undefined and has no properties. at DLS_fla::MainTimeline/onClickadd_btn() when i hit the add_btn... why has it got no properties ActionScript Code: function onClickadd_btn(evt:MouseEvent):void{ //and the work around for removing the old text when new confession is added. if(newTextBox!=null){ if(newTextBox.text!=""){ newTextBox.text=""; } } // this block of code is the formatting of the text box if(confessinput.text!=""){ //removeChild(newTextBox); didnt use line but leavng for ref newTextBox = new TextField(); newTextBox.defaultTextFormat = myFormat; //newTextBox.border = true; newTextBox.width = 500; newTextBox.height = 200; newTextBox.x = 100; newTextBox.y = 150; newTextBox.wordWrap = true; newTextBox.textColor = 0xff0000; newTextBox.selectable = false; newTextBox.mouseEnabled = true; //newTextBox.opaqueBackground = true; newTextBox.text = confessinput.text; cardContainer.loadPhoto.addChild(newTextBox); //trace(newTextBox.text); } cardContainer.newTextBox.addEventListener(MouseEvent.MOUSE_DOWN, onClickText); // hit area for dragging cardContainer.newTextBox.addEventListener(MouseEvent.MOUSE_UP, onReleaseText); } function onClickText(event:MouseEvent):void { var target:* =; //referance the target object - the text var bitmap:BitmapData = new BitmapData(target.width, target.height, true, 0); bitmap.draw(target as Sprite); //hit test on the textbox if(bitmap.hitTest(new Point(target.x, target.y), 150, new Point(mouseX, mouseY))) { setChildIndex(target as Sprite, numChildren-1); //if press start dragging the text target.startDrag(false, null); } } function onReleaseText(event:MouseEvent):void{; } this is been a pain for a good hour of fiddling and still nothing... any ideas
Youtube API problems.   (79 Views)
. I'm a bit of an actionscript noob and have run into a problem when trying to embed a youtube video into a flash project I'm working on. The problem I'm receiving is that every time I test the movie, I navigate to the frame where the video player is to appear and I get this error thrown at me from the output box: Error opening URL - (Youtube's API URL - can't post links yet) SecurityError: Error #2000: No active security context. I changed the security settings and set the swf file to allow access to the internet but this has made no change. Am I missing something Thank you in advance!
Having image loader problems   (67 Views)
, I made a swf in which I load an image into a movieclip. When I run the swf locally on my computer it works fine. When I put everything on the server and look at it with a browser it does not work. Does anyone see anything wrong here Code: /*** If there is an image being called out in the XML, load it. ****************************************************/ if (loadedSlide.imgName!="") { var req:URLRequest=new URLRequest("images/"+loadedSlide.imgName); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress); loader.contentLoaderInfo.addEventListener(Event.INIT, loadComplete); loader.load(req); function loadProgress(evt:ProgressEvent):void { var perctLoaded:Number=Math.ceil(evt.bytesLoaded/evt.bytesTotal); //trace("Loading: "+perctLoaded+"%"); } function loadComplete(evt:Event):void { loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress); loader.contentLoaderInfo.removeEventListener(Event.INIT, loadComplete); loader.x=0; loader.y=0; mcImageHolder.addChild(loader); } }
OSMF audio loading and playing problems in Chrome and Safari   (72 Views)
If been trying to refurbish my website using solely OSMF but, the sound part gives problems in various browsers. It works in IE6 and FireFox but, it doesnt in Chrome and Safari. Does anyone know what is happening and what their differences are when it comes to file loading I've made a small unit test : check it for yourself clicking the buttons in various browsers the Flash button uses native flash sound libs the OSMF button the OSMF implementation I hope someone can help me, I getting quite frustrated at this point... Code: package { import org.osmf.elements.AudioElement; import; import; import flash.display.Sprite; import; import; import; import; import; import; /** * @author Aduen */ public class Main extends Sprite { public var osmf_btn:Sprite; public var flash_btn:Sprite; //OSMF private var sound_click:AudioElement; private var snd_player:MediaPlayer; //FLASH private var sound_chn:SoundChannel; private var sound_tran:SoundTransform; private var sound_over:Sound; public function Main() { osmf_btn.buttonMode = true; flash_btn.buttonMode = true; osmf_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); flash_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler); //OSMF sound_click = new AudioElement(); sound_click.resource = new URLResource("HTTP://"); snd_player = new MediaPlayer(); snd_player.volume = 0.7; snd_player.autoRewind = true; snd_player.autoPlay = false; snd_player.loop = false; = sound_click; //FLASH sound_tran = new SoundTransform(0.7); sound_over = new Sound(new URLRequest("HTTP://"), new SoundLoaderContext(100)); } private function mouseHandler(e : MouseEvent) : void { switch({ case osmf_btn: if(snd_player.canPlay); break; case flash_btn: sound_chn =, 0, sound_tran); break; } } } }
Menu transition effect problems in Flex   (60 Views)
I've added some cool effects for menu items in one of my games, for options and pause menu's etc. When you open them they zoom out from a spec, and when you close them the collapse and fade out. The menu's are defined on the Canvas with visible set to false and properties are changed based on the visual state. I'm doing the effects using mx:Sequence and calling the function on whichever panel in the init state functions. The problem is that on the zoom out effect, the full size, fully visibly menu will flash really fast before the effect happens. Does anyone know why this is happening
more problems with FLV playback   (59 Views)
, I am having a problem with stopping flv playback. I have a simple Mouse over function to play the video which works fine but I also want to add a Mouse Down function which stops it. When I test it on my computer it works fine, but when I load it to my site only the mouse over play function works. The code looks like this: video.stop() box.addEventListener(MouseEvent.MOUSE_OVER, player); function player(e:MouseEvent):void { } video.addEventListener(MouseEvent.MOUSE_DOWN, stopper); function stopper(e:MouseEvent):void { video.stop() }
Image Loading problems?   (64 Views)
Alright so there's a section in my code where I load an Image file into the swf. This is what the code looks like: Code: public function loadImage() : void { imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, displayImage) imageLoader.load( new URLRequest("C:/Users/fizzy/Documents/Gallery/imga/" + src)); } public function displayImage(_e:Event) : void { trace(src) /*Bitmap( imageLoader.content ).smoothing = true imageLoader.y = imageLoader.y*700/imageLoader.x imageLoader.x = 700 addChild(imageLoader)*/ } I commented out most of the displayImage function in order to test something, and, as it turns out, the displayImage function isn't being run at all. Is there something obvious that I'm missing here
Upcasting problems   (65 Views)
I have two classes: Class1 and Class2. Class2 extends Class1. I have an object that is defined below: Code: var obj:Class2 = new Class2() Is there any way to manipulate obj so that when I do: Code: trace(obj) I get: Code: [object Class1] I think I've tried: Code: 1.trace(obj as Class1) 2.trace(Class1(obj)) 3.var otherObj:Class1 = obj as Class1 trace(otherObj) 4.var otherObj:Class1 = Class1(obj) trace(otherObj) But they always trace: [object Class2] Maybe what I'm trying to do breaks the laws of OOP... I was trying to do the same thing with Java and it didn't work either: Code: Class2 obj = new Class2(); Class1 otherObj = (Class1)class2; System.out.println(otherObj); //Prints: Class2@addbf1 Is it possible to cast upwards, losing all traces of the original dynamic-type
Image Loading problems?   (62 Views)
Alright so there's a section in my code where I load an Image file into the swf. This is what the code looks like: Code: public function loadImage() : void { imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, displayImage) imageLoader.load( new URLRequest("C:/Users/fizzy/Documents/Gallery/imga/" + src)); } public function displayImage(_e:Event) : void { trace(src) /*Bitmap( imageLoader.content ).smoothing = true imageLoader.y = imageLoader.y*700/imageLoader.x imageLoader.x = 700 addChild(imageLoader)*/ } I commented out most of the displayImage function in order to test something, and, as it turns out, the displayImage function isn't being run at all. Is there something obvious that I'm missing here
menu problems with flv video   (65 Views)
Hi folks, long time lurker with a question. i'm a flash newbie, i've been making a minisite and what i'm trying to do is create a sort of video gallery. so one frame with a bunch of thumbnail buttons linking to a series of labelled frames (this part works fine) on each of the frames (which before you ask are on their own layers) there is a movieclip which has one frame, onto which i imported an FLV for progressive download via file>import>import video. now there is also a back button which in theory SHOULD go back to frame 1 of the main timeline. it's on the main timeline and works with no video objects in place, but once i add video, the button to go to the frame works, the movie plays BUT i can't get the back button to work. any ideas google's turned up nothing, i know it's not the button code that's at fault and i know it's not a case of the video not unloading, because i tried it with the video scaled right down thinking the original buttons might be underneath, but that's not the case. i also tried loading the flv's by having an external swf with the file imported the same way, which again worked but disabled the buttons. any ideas
xml parsing problems... big big problems :(   (73 Views)
I am having a problem parsing xml data, I know how to get it into as3, and that is working pretty well after following a brilliant tutorial on kirupa: But I am having a problem tracing the data that I want. Seemingly it is connecting to the database and is working in that sense but when I try to trace data I am getting a couple problems. The first is that I need to somehow specify a value of a single item to get the rest of the data. Here is the xml: XML Code {$line["name"]} {$line["id"]}"; $query2 = "select * from circle where owner={$line["id"]};"; $result2 = mysql_query($query2) or die("Query failed2 : " . mysql_error()); while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)) print " \n {$line2["id"]} {$line2["name"]} {$line2["ordinal"]} {$line2["pref"]} {$line2["colour"]} {$line2["comment"]} {$line2["question"]} {$line2["comment_viewed"]} {$line2["question_view"]} "; print ""; Now it seems that I need to input an ID for the user to be able to trace their circles/information so I tried using this as3 code to do this: AS3 Code var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, LoadXML); xmlLoader.load(new URLRequest("")); function LoadXML(e:Event):void { xmlData = new XML(; Parse(xmlData); //trace(xmlData); } function Parse(parse:XML):void { trace("XML Output"); trace("------------------------"); var userList:XMLList = parse.user; for each (var userElement:XML in userList) { trace(userElement); if (userElement.text() == 1) { trace(; } } } Can anyone help me out here
performance problems   (68 Views)
Hi I've been building a flash character builder in AS3 and have been getting really high CPU usage while it's running. I'm trying to narrow down the problem so I was wondering if there was any app or something in Debug that i'm missing that would help me track down what specifically is causing such high CPU usage
flash gallery thumbnail linking problems   (152 Views)
im working on a photo gallery, and working with AS3, basically i have a slider where when the mouse moves to the left or right of the thumbnail "strip", it slides to that direction, therefore the layout of the gallery is like so: (for the thumbnail slider) MAIN TIMELINE -> gallery_mc -> imagebar_mc -> imagebarinside_mc the thumbnails all have instance names and are buttons. (for the full images) MAIN TIMELINE -> gallery_mc -> images_mc im having problems getting the thumbnail buttons to play the images. heres the AS ive been using: import; thumbnailinstancename.addEventListener(MouseEvent.CLICK, thmb24Click); function thmb24Click(event:MouseEvent):void{ gotoAndPlay("frameanchorpointforimagemovieclip") } i would really appreciate it if i could get some help on this