Actionscript :: 'addChild' An DisplayObject3d From Another Class?
Apr 5, 2010
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');
[code]....
View 2 Replies
Similar Posts:
Jun 15, 2011
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?
View 8 Replies
Jan 16, 2012
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.
View 9 Replies
Mar 22, 2010
How do I make a DisplayObject3D have mouseEnabled = false. I have a Sprite behind the Papervision3D scene listening for mouse events and so i need to let it pick up those mouse events through some of the DisplayObject3D objects.
I've tried adding the DisplayObject3D to a separate ViewportLayer and setting thats mouseEnabled to false but that doesn't seem to work.
View 1 Replies
Sep 9, 2009
I created a class which extends the displayObject3D, inside the class I tried to do two things that I usually do when I extend the Sprite class. In the constructor I created an EventListener which listens for when the displayObject3D is added to the stage and an Event dispatcher
[Code]...
View 0 Replies
Dec 30, 2009
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).
View 9 Replies
Jun 3, 2010
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.
View 2 Replies
Nov 28, 2011
I've got 2 classes:
Main.as
ActionScript Code:
package {
import flash.display.Bitmap;
import flash.display.Sprite;
[Code]....
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.
View 2 Replies
Jun 9, 2010
I may be losing my mind. I am simply trying to add a textfield and addchild to that textfield.
Here is the textfield class
Code:
package {
import flash.display.*;
import flash.text.TextField;
[code]...
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.
View 4 Replies
Sep 25, 2009
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);
View 2 Replies
May 13, 2011
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 ;
[code].....
View 2 Replies
May 31, 2011
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.
View 2 Replies
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?
View 4 Replies
Jan 25, 2010
i only want to make an addChild on the "root" ( or stage? as3 is really different from 2, im really confused)
the MAIN class:
ActionScript Code:
package com.website
{
import flash.display.*;
[Code].....
View 9 Replies
Aug 18, 2010
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.!
View 2 Replies
Apr 10, 2010
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.
View 8 Replies
Oct 30, 2010
If I want to have a mouseEvent and add an image to a sprite I need to add the image in the class and not after ? See where I have used addChild?
[Code]...
View 2 Replies
Sep 1, 2009
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;
[Code]......
View 3 Replies
Feb 16, 2011
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:
package
{
import Dinos_Control;
[code]....
View 3 Replies
Feb 6, 2012
I have defined some sprites in a class .as file and I want to put them in the screen. How can I do this?
View 2 Replies
Oct 27, 2009
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.
View 0 Replies
Feb 1, 2010
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.
View 0 Replies
Feb 6, 2009
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]
View 1 Replies
Feb 15, 2009
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] .....
View 1 Replies
Apr 20, 2009
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?
View 3 Replies
Nov 4, 2011
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 ?
View 1 Replies
Jan 7, 2010
I want to load an swf into a flex 4 application in order to use its classes.
[Code]...
I receive the error: Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one. at
[Code]...
View 4 Replies
Feb 19, 2012
I have the following scenarios.
[Code]....
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"
View 9 Replies
Jan 18, 2011
I'm new to oop and I'm trying to convert a auto scrolling TextField into a class. I guess it has something to do with there not being a stage when the class is instantiated but I'm not sure how to get around it. my code:
[Code]...
View 3 Replies
Jul 13, 2010
I got this Error : 1061: Call to a possibly undefined method addChild through a reference with static type Class.
what I'm trying to do :I have create a new class called Graph and make it extends Sprite and add a scroolpane to my stage and make an empty movie clip called content_mc and make the source of the scrollpane equals to content_mc
in the first frame i wrote this code
import Graph;
var graph:Graph = new Graph();content_mc.addChild(graph);
View 4 Replies