ActionScript 3.0 :: MovieClip Class - How To Add Another Child
Apr 27, 2010I have a MC that I added from the main class, and in that MC class I want to add another child, but it doesn't work, any idea why?
View 3 RepliesI have a MC that I added from the main class, and in that MC class I want to add another child, but it doesn't work, any idea why?
View 3 RepliesI have a movieclip (faceup) contained in another movieclip (card1), which is an instance of Card. I want to add a child to faceup from Card's class, however, I get a #1009 error.[code]...
View 1 RepliesBasically, I want to access a movieclip child created in a function called 'main' in my 'main' class that links to the fla.
Code:
var player:Symbol3 = new Symbol3();
addChild(player);
[code].....
I have a document class with a child MovieClip on the stage. I have the clip already on the stage because it's part of an complex layout provided by the designer and it seems easier to leave it on the stage than to use addChild (since I would have to add about 60 objects).What is the best way to reference the document class from inside the child MovieClip class?
View 1 Repliesadd a movieclip to the stage from a child class? My setup is as follows:
DocumentClass
->SubFolder
--->ChildClass1
[code].....
I'm trying to call a function in one child class (Circle.as) from another child class (Wedge.as). Circle.as is instantiated by the document class (Tree.as), and Wedge.as is instantiated by Circle.as. How do I do this? This is my code:
Tree.as
package com.treediagram
{
public class Tree extends MovieClip
{
[code]....
How to call a function in a Class from another Class?but it was a bit hard to follow as it relates to my problem. One of the solutions worked, but was commented as being bad form, and another did not work, so I want to make sure I structure my code properly.
i have a parent movieclip mcA and i want to add another movieclip mcB (child movieclip) inside mcA such that the extra part of mcB is hidden. The size of movieclip remains same as of mcA
For ex:-
mcA = 300x300
mcB = 400x400
then only 300x300 of mcB movieclip is visible and rest of the part is hidden.
I have a movieClip with one frame on the timeline containing one child whose instance name is "myContent"I am using this function to swap "myContent" with any number of possible class instances.
Code:
function setContentAsClass(c:Class)
{
[code].....
how to remove all child of a movieclip if no of child are not known
View 2 Repliesi have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:
code:
package Mushroom{
import flash.display.Sprite;
[code]......
I think this is a pretty simply problem but I do not seem to be able to pull it off. Basically I have a parent class A, and a child class B.Class A instantiates class B with addChild.There is a shared object which is being updated from a java server (red5) that has an event listener attached to it in class A.I have a function in class A which will pass certain, specific updates from this shared object to class B.The problem occurs is that when class B is instantiated, the event listener from class A doesn't work anymore. I have not removed the event listener from A.?
View 1 RepliesLets say I have a Main Document Class called Main. I also have a child class called childClass that call a function from the Main class and is also imported in the Main class. How should I call the function? I tried this , but when calling the function, it's getting me error.
Main class :
Code:
package {
import flash.display.Sprite;
import com.childClass;
[Code].....
The name of my DocumentClass is Main. So, what's the difference between :
var myClass:Main = new Main();
var mcInLibrary:MovieClip ;
/////////////////////////////////////////[code]............
I have movieclip which contains child movieclip. when child movie clip finish to play i want to run a function in a parent movieclip. so I made a custom event dispatcher in the first frame of the child movieclip:
[Code]...
I have load child swf in parent swf, from child swf i am trying to run my parent swffunction I am trying this code
MovieClip(parent).testfun()
but this code is giving error.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@2b1aa061
[code].....
below shows how to add child in a movieclip. ebd.target.addChild(info_grd); there is button named my_btn inside the movieclip info_grd.I would like to remove movieclip info_grd.parent
View 2 RepliesI'm trying to access a parent movieClip from the child movieClip
Here's what I want to do,
I've got a movieClip named wrong_mc, which plays for a couple of frames and on the last frame, its got a close button "close_btn" inside of it, now I wanna write the code such that when close_btn is played the movieClip "wrong_mc" should go and stop at frame1, I'm just not able to access this movieClip from the button.
I want to create a movieclip class that subclasses another movieclip class and inherits all its properties (rather than having to rely on the include statement). In my project I'm using:An abstract parent class that extends a movieClip: "infantryDroid".[code]However everytime I try this, flash acts as though nothing was imported from the parent movieclip class.If I was to try the above code I would get the message that _root and speed (which were defined in the parent class) "are undefined".
View 6 RepliesI've got a dozen movie clips on stage, each with 3 children, and each of those have 8 children, as example named u01-u08.
Is it possible to access u01 directly without the parent names? like a wildcard? like the xml way of getting to nodes with a .. ?
sort of like: stage..u01.alpha = .5;
I have a picture on the stage that has multiple items that have hotspots/links over them that should open a child swf on top of the background and show details about the items. then have a button in the child swf itself that removes the child from over the background so the user can click on another item etc.I found this code in someone's post and I am trying to modify it so that works for multiple swf files...it currently works for a single swf.I wan to pass the name of the button in front of the .swf in the URLRequest to have the same name as the instance name of the referring button. But I can't figure it out. Here is the code I am using on the stage
View 2 RepliesI'm having trouble adding images to the screen from an AS3 class that's being called from within a flex application. I'm writing the application using flash builder CS5.
As far as I understand it, display content is added to the screen using the addchild() method of the display object. Every which way I try to add an image to a display object I get an implicit coersion error from image to whatever.
Is there a specific set of steps I need to take?(i.e. wrap the image in a container and then add that) Or is there another way to display an image on the screen programmatically?
This application is for a game and I need to be able to display these images via a class that handles the tiling. I've been able to work around the problem so far by declaring the images as native mx:Image flex components and then referencing them via my program, but that's only suitable as a temp fix. Is there some other way to display the images from actionscript?
I need to create a new Stems object as a child of the scene when the user stops dragging a Star object, but do not know how to reference the scene from within the Star class's code.
I've tried passing the scene into the constructor of the Star and doing sometihng like:
this.scene.addChild (new Stems ());
But apparently that's not how to do it... Below is the code for Stems and Stars,
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.utils.Timer;
[Code].....
If I dispatch a CustomEvent in the parent class, and I add an EventListener in the child class, is the event listened ?
View 2 RepliesI have one custom class named player, which plays video from RTMP Server. It has property named cliptime:Number and it holds the video's duration through the metadata.duration property. I have other class named controlbar which holds the control bar for the video. I use TweenMax.to to move It's video slider and I want the tween's duration value to be the player class' cliptime property. But I can't get this value. Both classes are child of ramesCont class and are added to it. framesCont and controlbar extends Canvas class, and player extends Sprite if it matters.
[Code]...
Im trying to build a class that moves around some movieclips on the stage, but it would never be that easy would it!
Code:
package {
import flash.display.MovieClip;
public class Rotation extends MovieClip {
[Code]...
So I waddled it down to the "stage.addChildAt(mcContainer[i], i);" bit and I've tried everything that I could think of, but nothing seems to work.
With this version of the code, I would get "The supplied index is out of bounds." error, I can change it to addChildAt etc, but that just gives me a different error.
I had this working when it was in a flash file, its converting it into a usable class thats bugging me. All the MovieClips in the array are being exported for Actionscript.
I've been using greensock classes in a parent movie, but am now looking to use the same classes from within some child movies, but it doesn't work (I presently have to import them into each child movie - what a waste).
Do I need to create the classes as a shared library object perhaps? If so, how would I go about it? as I've only ever done this for MCs or MP3s.
I want to add a child to the stage for 5 seconds and then remove it. When I use the following code I get a "1120: Access of undefined property WordoScreen." error.
In particular the problem only occurs when I use the "removeChild(WordonScreen);" using the TIMER_COMPLETE. If I remove that statement I don't have a problem.[code]...
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.
I got a Homepage set up and I have a Contact Form on Frame 55 of my main movie clip.The form is created on runtime using AS with the following code:
ActionScript Code:
import com.warmforestflash.ContactForm;
var contactForm:ContactForm = new ContactForm();
[code].....
I have a SWF with a document class called ClassA. I'm loading in an external SWF with a document class of ClassB. Then ClassB is loading in an external SWF that is used for graphical assets.
The problem is that all of the assets in the third SWF all extend a class called Actor. The assets swf is loaded and set as the var "_assets".[code]...