I am trying to replace a child on the stage. For this, I am checking if it exists first and then calling removeChild method, then adding the child to the stage.
flash code:
PHP Code:
btn.addEventListener(MouseEvent.CLICK,onClick);
function onClick(e:MouseEvent):void{
var lineShape:Shape = new Shape();
[code]....
The second time I press the button, I get this error:
PHP Code:
removed
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Untitled_fla::MainTimeline/onClick()
I have a mainSwf in which I load an external swf, which loads an external swf.( a child of a child). I am trying to set the framerate via AS3 for the childs child by using stage.frameRate= 15;
It doesnt work when the children are loaded into the mainSwf. how to access the stage of a child's child? I have tried root, Movieclip, this but can not get it to work
i am slightly confused about the parent and child relationship. lets assume we have several different instances, what would be difference of adding them all as children of the stage and creating a parent-child hierarchy between them(other than the access path).
for some reason escapes me: using AS3 how can a swf load another swf to replace itself in the same loader on the stage, while simultaneously calling a randomizing function in the first frame of the main timeline, to randomize the next swf?At the end of each swf (called "koan_#.swf") there is the following old AS2 code...it was used to randomly select and then play a swf from koan array:
I can't seem to unload a movie, I've tried every possible actionscript code and still it won't go away. My objective is to run in the main stage a sub menu and for that I've done sub pages each one with a previous and next button (inside the movie that will be loaded), and that's the catch. I can't put the loadMovieNum in 0 level because it would replace the main stage. So I'm trying to do on the button:
on (release) { unloadMovieNum(1); // it was loaded into level 1 loadMovieNum("new_item.swf",1); // he overlays both movies with transparency }
Is there anyway to remove the actual movie and replace it with the new one?
I'm having some real trouble getting .replace to actually replace something. Here's my code...
[Code]...
I can trace both newFiles[i] and keywords[i][whatever], but the replace doesn't replace anything. The regex is valid as well. I'm using regexr to test it, and it works perfectly there... but will not for me and I don't know why.
var servicosMc:buscaServicos = new buscaServicos(); this.addChild(servicosMc); servicosMc.name = "servicosMc1";[code]...........
Yeah this work but my application start with 24 mb of ram consumed. After I have clicked 3 times on this button and did this code above the application use 60 mb on the memory and the application do the same for the others button.
I created movie clips that I want to add to the stage (from the library) by the use of buttons. I have a total of six buttons (and six moviclips) but I am trying to get the first two to work before I move on to the next buttons. The problem is I can't seem to remove the movie clip when another button is clicked, or the same button... Like I said I am new at this and I think a created a mess of things... I am getting error 2007 now
I have a menu with three buttons and a head "scene" where i present my information. When I push a button in the menu three small pictures are shown on my "scene". Each picture should show a bigger version of the picture and here is the problem. The first picture is shown and it is possible to make it disappear with removeChild. But how do show the other two pictures?! I have tried to do the same as i have done with this picture but with no success.
function visaGolf(e:MouseEvent){ var headBtn:MovieClip = new btn(); headBtn.name = "headBtn";[code]....
I am trying to remove a swf that I import to the stage, but it is not working. Code: function btn_cima_3call(clickEvent:MouseEvent):void{ page = 5; esconder(); content.gotoAndStop(page); ld.load(new URLRequest("trabalhosV0.swf")); ld.x = 0; ld.y = 100; addChild(ld); }
So when 1 button is pressed this swf is imported to the stage. but im now trying to remove this when another button is pressed and it isnt working? Code: function btn1call(clickEvent:MouseEvent):void{ removeChild(ld); page = 1; content.gotoAndStop(page);}
I am writing a program where the user can, in the simplest terms, drag and drop things on to the stage. I need the user to be able to save what they have done and when they come back choose to reload their previous project. My plan was to write all the information(object class, x and y values etc) to an xml file and when the user chooses to load a particular project, rebuild the stage with all objects in their correct locations. My problem is, how do you add an xml element with all of its attributes and child elements dynamically for each object added to the stage?I'm relatively new to XML, but I figured this would work:
ActionScript Code: var test:XML = <test/>; test.title = "Test XML"; for (var i=0; i<platform.numChildren; i++) {
[code]....
in a for loop as well. But, these give me a warning that says "adding an element with more than one item is not supported" or something like that.
I have some code that adds a child using addChild(dragsquare); dragsquare is what I used as the class for a movieclip, mcsquare.
Everytime a child is added to the stage, it is called: ObjectX The "X" increments everytime a new object is added using ++objNum.
E.g:
Object1 Object2 Object3
etc...
When the child is added to the stage, it can be dragged, resized, rotated, etc...
I have used this code so when someone clicks the "save" button it loops through all objects on stage (increasing the last number by 1 to get the next object) and finding their properties. Here is the code I have used.
ActionScript Code:
Code: save.addEventListener(MouseEvent.MOUSE_UP, saveObjects); function saveObjects(event:MouseEvent):void { for (var i:uint=0; i<numChildren-23; i++) {
[Code]....
23 children already exist on stage so I have to minus that number to get whatever is added on stage by the user.
However, scaleX is getting the childs ORIGINAL properties and not its current stage properties (where it has been resized, rotated etc..) and only returns a 1 for scaleX. How would I make it track the properties it has on stage?
I am creating a fullscreen (no scale) site, so I am placing the position of my movieclips by referring the stage.[code]...
that code sets the x property of the movie clip fine when stand alone but when loaded into another swf it has trouble accessing the stage.
How can I access the height and width of the stage from a child swf? I have already tried both parent and root which give no errors, however they are not tracing proper values and are throwing everything in the wrong place
I am trying to make a "Achtung! die kurve" - like game in Actionscript 3.0. So far I've done the movement of one of the 'worms', and it works alright. I wanna divide it into different class files, but I can't seem to get it to work. I have a .fla file and 4 .as files. So far I only have code in two of these. When I put all my code directly into the fla file, it works perfectly fine, but when I put it into my player class, it won't 'add the child' to the stage. Here is my player .as file: [URL].
The reason why I commented the addChild, is because I wanna do this in my mainFile.as. This is from the main file: [URL]. I'm not quite sure how to call it in the main file, so I'm guessing that this would be the issue. All the files are named and placed correctly in the same folder, and flash says that each of my .as files are targeting the .fla file, so this doesn't seem to be the issue. How I can change the speed of my sprite.
Is it possible to check, using Javascript and without altering the ActionScript code at all, if a child has been added to the stage? I have in mind something like being able to call GetChildByName in Javascript, and if the child exists, call another javascript function.
I am not sure if I'm being completely stupid here, so my apologies in advance. If I have an object on the stage for example:
ball:Ball = new Ball(); addChild(ball);
it already has .x and .y values as it is placed on the stage.Then I have some value inputs, such as force, angle etc.Now when I click an event listener I want it to activate a function in Ball that will move it from the values I have just set.My question is how do I carry those values across after the ball has already been place on the stage?
I feel like I should know this by now, but I'm having trouble. I want a function in one of my child functions to increment an integer in its parent function.
OK this has been a process but i have gotten to the point where i am calling a feedback image for the different categories, I just need to clear the foodfeedback and artfeedback children when music is pressed and the same for the others
chat.fla Code: Select allimport maero.entities.*; var p:Player = new Player(1, "player one");
[code]....
There we go. What i want to do is, I want to create an instance of the Player class, which then creates an instance of the Actor class, which in the _draw() function should add an image to the stage, but I can't figure out how to do that. I want this image to be an instance in the Player's Actor instance, so i later can move it around, the same goes for the user name text. how do i add an image and a user name text field to the stage at player.__x and player.__y?