Class :: FLA File - Adding Child To Stage

Apr 12, 2012

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.

View 1 Replies


Similar Posts:


Flash :: Adding Child To Document Class Vs Adding Child To Stage?

Nov 24, 2011

The name of my DocumentClass is Main. So, what's the difference between :

var myClass:Main = new Main();
var mcInLibrary:MovieClip ;
/////////////////////////////////////////[code]............

View 1 Replies

Actionscript 3.0 :: Adding Child To Stage From Class?

Nov 24, 2009

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?

View 1 Replies

ActionScript 3.0 :: Adding MovieClip To Stage From Class File?

Jan 15, 2009

Does flash have an equivalent to Flex'sApplication.application.[insert application method or propertyI want to get access from an as3 class file to the mainstage. a call to this.root from the stage to the class will notwork because I need the root object stage to execute an addChild

View 6 Replies

ActionScript 3.0 :: Adding A Stage Event Listener In A Class File?

Sep 5, 2009

im trying to create a separate class so i can create a custom mouse. But i need to make it so that every time the mouse moves then something happens. as in it dissapers and after 5 seconds the timer resets. I have the code and it works in my .fla file, but im not sure its possible to put it in a class file and have it be the class of the .fla.

View 16 Replies

ActionScript 3.0 :: Child-parent Relationship \ Adding Them All As Children Of The Stage And Creating A Parent-child Hierarchy Between Them?

Jun 6, 2011

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).

View 5 Replies

ActionScript 3.0 :: Adding A Child To The Stage In First Swf

Aug 4, 2009

I am adding a child to the stage in my first swf

Code:
addChild(new donkey());
var l:Loader = new Loader();
l.load(new URLRequest("next.swf"));
addChild(l);

in my next.swf, I have a button which I want to remove the donkey with::

Code:
removeChild(donkey);

OK - doesnt work - it doesnt let me export the swf anyhow because the next.swf has no 'reference' to donkey existing at all. What's going on?

View 11 Replies

ActionScript 3.0 :: Delay Adding Child (Movie Clip) To Stage?

Dec 15, 2011

I am attempting to add a movie clip to the stage when a button is triggered. When the user clicks the button the movie clip is added to the stage; it works fine, but the following problems occur:

1) The appearance of the movie clip is delayed.

2) The sound in the movie clip starts to play but the movie clip appears when the sound is finished.

Additional information: 1) The movie clip has the sound in the timeline.Here is the code:

Actionscript Code:
//Buttons: Adds movie clip to stage.readtomeShortA1.addEventListener(MouseEvent.CLICK, playShortAReadMe1);var playShortA1:ShortAReadMe1function..[code].....

2) However, I also want to know is keeping the sound in the timeline of the movieclip the most efficient way to use sound in the movieclip? Or is there better, more efficient way to do it?

View 3 Replies

ActionScript 3.0 :: Adding Menu Popup Child And Tween Off Stage

Sep 30, 2011

I have several objects on the stage and a MouseOver on any of these will add a menu popup child and tween it from off the stage. A MouseOut will tween the menu away and remove the menu with removeChild. Heres the bug: If I mouse out and then quickly mouse over the same object while the menu is tweening away before it has been removed, it doesn't add the menu again, and then on the next mouse out, it tries to remove the child menu, which isn't currently a child because it was just removed, and

I get the error:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/removeChild()
at menucaller/tweenOffTimerEnd()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Is there a way I can use an if statement to make sure that the menu is a child of the parent before removing it?

View 1 Replies

ActionScript 3.0 :: Remove A Child Of The Display List If It Exists Before Adding Another To The Stage?

Mar 3, 2009

I'd like to remove a child of the display list if it exists before adding another to the stage. This gives me Error the first time I call it because 'myMC' doesn't exist.

HTML Code:
function callMc(){
if(myMc) removeChild(myMc);

[Code]....

View 5 Replies

ActionScript 3.0 :: Class Access Child On Stage?

Jan 28, 2009

I need a class code to access a child instance of another class code that is on the stage. I have a class code named Ball.as. On the Time Line is a child of the Thing class. It is call newThing. Here is the code in the Ball.as file:

Code:
package {
import flash.display.MovieClip;
import flash.events.*;

[Code]....

I get an error message saying that newThing is an undefined property.

View 2 Replies

ActionScript 3.0 :: Adding Stage On The Class

Mar 22, 2011

i've been getting difficulties regarding how to put a stage on a .AS how should i declare it? I want to put my movie clip on the stage using a class only. i want my hero to go at the middle of the screen but it doesnt come out.

[Code]...

View 9 Replies

ActionScript 3.0 :: Adding Stage On The Class?

Mar 22, 2011

i've been getting difficulties regarding how to put a stage on a .AS ow should i declare it? I want to put my movie clip on the stage using a class only. i want my hero to go at the middle of the screen but it doesnt come out. here's my current code

Code:
package {
import flash.display.Stage;

[code]....

View 2 Replies

Actionscript 3 :: Add Movieclip To Stage From Child Class In Flash?

Aug 5, 2010

add a movieclip to the stage from a child class? My setup is as follows:

DocumentClass
->SubFolder
--->ChildClass1

[code].....

View 1 Replies

ActionScript 3.0 :: Adding Mc To Stage From In A Custom Class?

Jul 14, 2009

I have created a custom class called SceneNavagation.as which i use to add my navigation to the stage. I was having problems getting the addChild to display my mc on the stage. So I passed the stage instance into my class and used that to attach my movieclips. _stage.addChild();

This worked but Im new to as3 and just wanted to know if this was a good way to do this below is my code.

package com.lessons{
import com.caurina.transitions.Tweener;
import flash.display.*;

[Code]....

View 0 Replies

ActionScript 3.0 :: Adding Movieclips Dynamically Onto From A Class Stage

Aug 15, 2009

ok. so here's the thing..i have a class from where i created an array with the time, name, and position of each movieclip data.. and wanted it to go through each one and execute at a certain time.. So i tried something like this:

[Code]...

the first part works well.. but its when i try and add it to the stage that i get confused.. i tried something but i think its wrong.. can anyone help me? Basicly i want flash to get the array.. use index 1 for the name.. index 2 for the x position and index 3 for the y position.. but all this name referencing in as3 really confuses me.

View 7 Replies

ActionScript 3.0 :: Adding MC From Library To Stage From External Class

Oct 14, 2009

I'm trying to create an application with an extensive user interface. I've come pretty far and decided I wanted to really take advantage of the object oriented features that AS3 has to offer.

I've started off by created a few classes: User, Background and Main. Main is the document class of course. In the document class I have a function "resetStage" that clears the display list of all children. This is because I have many layers of images making up the UI and they all show up at startup unless I remove them. Besides I want to see where the stuff is positioned in the Authoring tool so I don't want to just create movieclips and then delete them.

My issue is with my Background class. Basically what I want to do is create a new DisplayObjectConatiner called bgContainer or something and then put all the background stuff in it. (The main background image and a status bar image). Then add the bgContainer and its children to the stage. This should all happen when the object is constructed.
 
Main .as
---------------------
package
{
public class Main extends MovieClip
{

[Code].....

View 4 Replies

ActionScript 3.0 :: Adding Movieclips Dynamically Onto From A Class Stage?

Aug 15, 2009

i have a class from where i created an array with the time, name, and position of each movieclip data.. and wanted it to go through each one and execute at a certain time.. So i tried something like this:[code]the first part works well.. but its when i try and add it to the stage. Basicly i want flash to get the array.. use index 1 for the name.. index 2 for the x position and index 3 for the y position.i have already linked the movieclips on the stage

View 1 Replies

ActionScript 3.0 :: Flash Adding MC's To Stage Outside Document Class

May 25, 2010

Im sure this is quite simple but for some reason I cant get it to work, and it does not throw an error so I dont know whats wrong...

In the library of the main swf file a movie called navigation has been exported to class: 'NavMC'[code]...

View 2 Replies

Actionscript 3 :: Load An External Swf To Main Stage From Instanced Child Class?

Apr 15, 2010

I am trying to get an instance of a class to the load an external swf and show it.So far I have the following:

1) I wrote a class that uses the Loader class to load an external swf "loadExtSWF".
2) I have a fla named "MainSWF.fla" that uses a document class "MainSWF.as".
3) I have the MainSWF.as file that instances "loadExtSWF" and calls loadExtSWF.startLoad to load the swf.

This almost works. The instance of loadExtSWF loads the external swf, but the swf is not displayed.If I replace the fla's document class with loadExtSWF (this has an empty constructor) instead of MainSWF, and run loadExtSWF.startLoad, then the external swf is loaded and displayed.[code]

View 1 Replies

ActionScript 3.0 :: Access The Document Class From A Child Movie Clip On The Stage?

Jul 22, 2010

i know this may seem kind of dumb, but how does one access the document class from a child movie clip on the stage?

i have a property in my class. Just a string for testing:

Code:
public var s:String = 'can you see me';

it traces on the root time line, but it errors out if tracing it from a movieclip on the root time line.

View 1 Replies

Adding Similar Movie Clips To Stage From Document Class

Jun 5, 2009

How do you add several similar movie clips to the stage from the Document Class?
 
E.g. I've got four different movie clips called ball0_mc up to ball3_mc.
 
Also, how do I add each movie clip to random points within the stage parameters?

View 1 Replies

ActionScript 3.0 :: Adding Multiple Images To Stage Via The Loader Class?

Dec 28, 2009

I want to move my multiple externally loaded images a little each time they are added to the stage along the x axis via the Loader class. It all works - But HOW do I access the added graphic synatically, so i can change its x pos?! Ive tried picLoader.x ... but that's the Loader - NOT the image...??

Code:
private function setPics():void
{
for(var i:int = 0; i < xItems; i++)

[Code].....

View 2 Replies

ActionScript 3.0 :: Adding MovieClip To Stage Through Click Event From Different Class?

Jan 21, 2012

There is a button inside MovieClip1 and once it is clicked movieclip2 apeares inside movieclip3.

View 3 Replies

ActionScript 3.0 :: TypeError: Error #1009 When Adding Custom Class To Stage

May 18, 2009

I have extended a RadioButton into a custom class in order to store some extra info. I want to dynamically add these RadioButtons to the stage to create a dynamic menu box. So I started simple in order to make sure I knew how to do this.Here's the error (I love Flash IDE error reporting):

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::RadioButton/drawLayout()
at fl.controls::LabelButton/draw()

[code]....

View 3 Replies

ActionScript 3.0 :: Adding Objects To Stage Through As File

Nov 19, 2009

Hey this is my as code

Code:
package
{
import flash.display.MovieClip;

[Code]....

Am I not referring to the stage of the flash movie (the one that is calling this action script) properly.

View 6 Replies

Flex :: ViewStack.addChild Adding Multiple Child And Only The Last Child Is Visible?

Mar 10, 2010

var viewStack:ViewStack = new ViewStack();
viewStack.percentWidth = 100;
viewStack.percentHeight = 100;

[Code]....

Its only displaying canVas3 contents not canVas1 and canVas2

View 1 Replies

ActionScript 3.0 :: Access Child Vars/functions Without Adding Code To Child?

Mar 11, 2010

I've seen some discussion on how to load a child swf using swfLoader and accessing it's variables but I am wondering if it is possible to do this without adding any code to the child swf.Either accessing public vars or listening for funciton calls would work fine

View 2 Replies

Actionscript 3 :: Flash Call Function In One Child Class From Another Child Class?

Dec 1, 2011

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.

View 3 Replies

ActionScript 3.0 :: Controlling Labelled MovieClip On Stage From A Child .as File

Jun 20, 2009

I have an FLA file with a movieclip on the stage which is labelled "blok", and a button on the stage labelled "button1". This FLA is attached to a file called main.as through the document class.

In the same folder where I am storing main.as I have a second .as file called secondFile.as. I have imported this class into main.as using: import com.tests.secondFile;

and in the constructor of main.as I have put:

loadB=new secondFile(button1);
addChild(loadB);

Within secondFile.as my constructor looks like this:

public function secondFile(button1:SimpleButton){
button1=button1;
button1.addEventListener(MouseEvent.MOUSE_DOWN, buttonPushed);
}

[Code]....

Basically I'm trying to get the MovieClip labelled "blok" to move by 50 pixels on the stage when button1 is pressed, but when I test my FLA I get the following error:

1119: Access of possibly undefined property blok through a reference with static type flash.displayisplayObjectContainer.

I would have thought that this.parent.blok would control my movieclip labelled blok on the stage of my FLA from within secondFile.as since secondFile.as is a child of main.as which is the document class of my FLA, but obviously this is not right.

how to access labelled items on the stage from within a child object.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved