ActionScript 3.0 :: When Clicked It Should AddChild To The Mc Governed By Class B?
Sep 23, 2009
lets say i have document class 1 that loads class a and class b to the stage. I have a button in class a, that when clicked it should addChild to the mc governed by class b.... is this possible?
I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?
I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
I have an FLA in which there are a number of MovieClips in its library. I also have a document class for this FLA, which I will refer to as Body.as from here out.From Body.as, I call other classes designed to put stuff together and allow for organization due to large amount of MCs I have to use in the FLA. For reference, these classes are called as such: Head.as, Chest.as, Arms.as, etc etc.Now, where Body.as is the document class, and is therefore functioning to operate all areas in the FLA, I wanted to use these additional class files to be used to manage anything related to them, including any MCs I have. I'll use Head.as for explaining. To that end, I have four MCs, each named as follows:hat1hat2hathat4s part of trying to organize it all, I want to be able to call a singular function in Head.as that will retrieve these MovieClips and add them to the stage (Or, as I hope to do once I get a bit further in, add them to a larger MC that will then be added to the stage).
i want to add to stage a movieclip in another class not the .as file as the same name of .fla file how can i get this.When i run same code in main.as i get the result but in another class it runs but no result.
I use two classes for my current project, a document class and a menuscreen class. I have a function in my document class called startGame that i want to run from the menuscreen class when a button is clicked. I'm nearly there but i'm getting an error when i try to run it: 1136: Incorrect number of arguments. Expected 1. The error is at line 17 in the menuscreen class, the line that tries to run the function from the document class. I don't understand what kind of argument it wants. Also, i'm not sure if the startGame function should be (event:Event) Hope someone can enlighten me on what's wrong!
When I do this there are no errors, but the 'addChild' function is not working. if I put the addChild function in the Main.as then everything works just fine. So my question is: How can I Let the addChild function work from another class then the main class.
Works great until I try to addChild to that textField from either Frame 1 or the class itself. I can trace it perfectly, trace the class, trace the functions, trace everything in the functions but I can not addChild.
I have this class called AD. Its attached to my stage. AD then calls a class file called setupBoxes.
setupBoxes sets up a box using box2d (which has nothing to do with my question so dont stop reading here), attaches a movieclip to it, and attempts to "addChild". No errors, but no results.The thing is, in setupBoxes i even tryed using this code which i found on another forum.
PHP Code:
improt AD; //creation of class and brakets and things. public static var ad:AD; //long box2d and setup process and more brackets... ad.addChild(container);
I am trying to pull a funtion that adds a child to a container. This function gets pulled in another class. All the traces do work by the child doesn't show.
pulling the function from StickerBook_Class ---------------------------------------------------------------------- ----- public static var stickBook_Class:StickerBook_Class = new StickerBook_Class ;
For a school assignment I'm making a panorama version of my own room using a cube with 6 pictures in it. It created the panorama, it works great.But now I want to add clickable objects in it. One of the requirements is that my code is OOP focused. So that's what I am trying right now.
Currently I got two classes
- Main.as (Here i make the panorama cube as the room)
- photoWall.as (Here I want to create my first clickable object)
Now my problem is: I want to addChild a clickable object from photoWall.as to my panorama room. But he doesn't show it? I think it has something to do with the scenes. I use a new scene in Main.as and in photoWall.as. No errors or warnings are reported This is the piece in photoWall.as were I want to addChild my object (photoList):
private function portret():void { //defining my material for the clickable portret var material : BitmapFileMaterial = new BitmapFileMaterial('images/room.jpg');
I am trying to add an object to my main stage via the addChild() method. Normally, when working within the FLA itself, using addChild(myObject) works just fine. However, it does not work within an external AS class.
All of the other tutorials I have found showed me how to do something like this, which is not what I need:
var myMovieClip:MovieClip = new MovieClip(); myMovieClip.addChild(myObject); // Works great, but not what I need
how to add an object to my main stage via an external AS class.
I have an array of a custom class. The class includes 3 movieclips that all share the same position. I have 5 items in the array, and in the document constructor I fill them as such:
ActionScript Code: glassArray[0] = new glasses(spot, beam1, glasses2, "index/nav/aboutus", new Point(156, 400));(different string and point for each of the 5 items)
Here's the glasses constructor: ActionScript Code: public class glasses extends MovieClip{ //I am the Constructor. public var spot:MovieClip; public var beam:MovieClip; public var glass:MovieClip; protected var target:String; [Code] .....
It then goes on to fill each of those mclips with properties based on the point received. How to addchild from the class, I've got a simple for loop in the document constructor that adds them all in. Everything works, except what I'm seeing is that as each item in the array is added in, it overwrites the previous items' properties. In effect, I can create 5 items and give them each a different position, but when I go to addChild I see that all of them have taken on the position of the 5th one.!
I can't do many simple things in AS3 that take 1 second to do in AS2,
All I want to do is attach a movieclip to the stage via a .as file that ISNT the document class.
So for examples sake lets say I have Main.swf - Main swf file with a movieclip called "PreloaderGUI". Main.as - The document class, this loads Preloader.as. Preloader.as - This preloads the movie and attaches PreloaderGUI.
I'm working on a Flash Lite 3.0 application using AS2 and I've created a class that extends MovieClip. The problem is that I'd like to dynamically add Child Movieclips using the addChild method... but it doesn't work, it gives me the following compiler error: "There is no method with the name 'addChild'". But I can call other MovieClip specific methods such as this.getNextHighestDepth()
heres a reduced version of my class:
class com.sck.DragList extends MovieClip { //Declarations private var placeHolder:MovieClip; private var listMask:MovieClip;
I have a main package that adds the background image to the project, from here on im trying to have seperate classes that add objects to the background as a parent and control these objects.my code in the main package:
What I describe here is not correct. My full code had some other things in it that was the reason I couln't see mc2. The code described under is actually working!
I have custom class (MyContainer) that extends Sprite. Then:
Code: var mycon:MyContainer = new MyContainer(); var mc1:Sprite = new Ball(); // Ball is a sprite in my library var mc2:Sprite = new Ball();
[Code]....
it works, but I dont want that, as MyContainer has custom variables and functions I use. A simple: if (mycon is DisplayObjectContainer) evaluates to true.
I got a background asset loaded then I want to add a textField above that asset. How do I do this. It sets behind. And I can�t figure out how to override the IDisplay class.
I'm have trouble attaching graphics to the stage from a class. I can do it on the timeline but the code doesn't work in a package.[code]this doesn't seem to work even if I import the picture in the package.[code]
I believe this should be a very simple fix, but I cannot for the life of me get this working, and i've been playing with it all day. Basically I am trying to start working with classes, I want to attach a movieclip to a flash movie, from my class [its for a card game style thing]. But when I attach a movie clip, it does not appear on the screen,. It exists, I can trace its .x position etc.
Code: Select allpackage arrayTrial{ import flash.display.Sprite; import flash.events.Event; import flash.display.MovieClip; public class Deck extends MovieClip{ private var totalCards = -1; [Code] .....
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?
I need to know when an element is added to the stage (using main document class). So i use :
Code: public override function addChild(__child:DisplayObject):DisplayObject{ super.addChild(__child); trace("child added"); return __child; }
Which works fine. I also use a static class, to which i pass the stage using :
Code: public static function setStage(__stage:Stage):void{ _stage = __stage; }
But if i add to the stage (_stage) a MovieClip from the static class, my "real" stage doesn't seem to get that something was added. So i guess _stage !== stage. So why is this happening, why is _stage not getting the methods of stage ?
how can I change the txtField.text without using the addChild function in the main class?? because the Content Class is already visible when you compile it.. and when I remove the that addChild function, the txtField.text is still in its default value which is "Lorem Ipsum"
I am importing multiple class instances into my document class. They are buttons that I want to load larger images when clicked. The problem I have is that I don't know how to tell class instance was clicked to load the appropriate larger image.
this is how I am importing the buttons:
ActionScript Code: package { public class DocumentClass extends MovieClip { private var myProj:Content;
[Code]....
I worked with trying to assign myProj.name but I understand in AS3 that isn't the best way to go about this. I also worked with trying to populate an array but I wasn't sure how to get the addEventListener to work when one of the class instances in the array was clicked.
I am trying to create a simple drag and drop Flash program where a user can drag xmas ornaments onto a tree. Instead of being able to drag the ornament once, I want a function so that every time an ornament is clicked on, it adds a new ornament of the same class to the stage where the ornament is clicked. Currently I have this working but there is one problem. It is not dynamic. Looking in the "drag" function, I have chosen the class "Symbol31" as the default ornament that gets added. Instead, I want the ActionScript to read the class of the ornament that was clicked on and to add that class, not "Symbol31" everytime.
Code: public class DragDrop extends MovieClip { private var originalX:Number;