ActionScript 3.0 :: Moving A Child From A Class To A Holder Sprite Inside That Class?

Feb 12, 2009

i 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]......

View 8 Replies


Similar Posts:


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 :: Dispatching Events From Parent Class To Child Class

Apr 30, 2010

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 Replies

ActionScript 3.0 :: Call Parent Class Function From Child Class?

Nov 25, 2010

Lets 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].....

View 6 Replies

Actionscript 3 :: Class Extending Sprite - Set The Sprite's Width And Height Properties?

Mar 5, 2010

I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite's width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.

What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it's been instantiated, so I don't get it.

package {
import flash.display.*;
public class ScrollBar extends Sprite {[code].....

View 1 Replies

ActionScript 3.0 :: Calling A Function From An Extended Class Inside A Top Level Class

Sep 23, 2009

package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt

[Code].....

I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.

So I added the if (defender._hp <= 0) this.win() which gives me the following error:

1061: Call to a possibly undefined method win through a reference with static type Character.

"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name

Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?

View 6 Replies

ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

ActionScript 2.0 :: SetInterval With A Class - Function Doesn't Work Inside Class ?

Oct 7, 2004

I was wondering why my current code for calling a setInterval on a function doesn't work inside my class.I have this code inside one function, calling a second function.

intID = setInterval(selfReferential, dupe, 30, 0x000000);

The selfReferential keyword refers to the current class,but was defined previously (selfReferential = this; ).I get no errors, but the dupe() function is never called.and I had the selfReferential variable replaced with the this keyword at one point as well.

View 5 Replies

ActionScript 2.0 :: Make Class Instances Into Listeners And Broadcasters From Inside Each Class?

Jul 8, 2007

I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)

Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}

where "u" is another class, the Updater class with this code...

Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){

[code]....

PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?

View 2 Replies

ActionScript 2.0 :: Instantiating Character Class Inside Of Game Class

Feb 18, 2007

I am having a problem instantiating a Character class inside of a game class.I am working on converting URL...l these tutorials to A.S. 2.0.[code]

View 2 Replies

Flash :: Set ScaleX Property On A Sprite Without Altering The Child Inside

Mar 25, 2010

My site is set up with next and prev buttons on the right and left sides respectively, and as you roll over either of the hit areas around the buttons a Sprite fades in which contains a TextField that describes the next page. Said Sprite calls the StartDrag() method, so it follows the mouse within the bounds, which is all fine and dandy on the left side of the page. Adobe, however, seems to have forgotten to put a way to dynamically alter the registration point of a Sprite, MC, whatever else, so when you roll over the right side of the page, the sprite is displayed from the top left and is mostly off the stage.

Trying to hack this problem I have tried numerous things ( classes written by others, other hacks) and the best that I have found is to use the scaleX method on the Sprite, changing the scale to -1. This, of course, makes the Sprite seem like it's reflected from its normal point, which means all its children show up backwards.

Is there anyway I can use this hack without it altering the text?

OR

Does anyone know a different way to go about displaying a Sprite from another corner? Any way to make a Sprite fade in and follow the mouse on the LEFT HAND side of the mouse pointer?

Here is a snippet to give an idea of what's happening:

naxtPage.labelBG.scaleX = -1;
nextPage.labelBG.startDrag( true, nextHitRect );
nextPage.labelBG.x = nextPage.labelBG.parent.mouseX;
nextPage.labelBG.y = nextPage.labelBG.parent.mouseY;

View 1 Replies

ActionScript 3.0 :: Dynamically Create Class Inside A Class?

Apr 19, 2010

This is what i'm trying to do :

I have 1 class that extends movieclip, let's call it Class0. I have 1 class that extends movieclip, let's call it Class1.

I create an instance of Class0 on stage like : var myClip0:Class0 = new Class0(this, "Class1");

The class Class0 when initializing, will create a new movieclip (myClip1) and add it as child, as an instance of Class1, like myClip0.myClip1. But it's when i create that clip, i want to tell it, it's an instance of Class1, like :

private var myClip1:Class1 = new Class1(this);

Where Class1 could be any class.

How do i pass Class1 to Class0 so it can create it dynamically?? Do i have to use the apply function??

inside Class0, i have a function that does :

Code:
if(subClass){
initSubclass(subClass);
}

[Code].....

View 8 Replies

ActionScript 3.0 :: Class Instantiation Inside Class?

Dec 24, 2009

Performance wise, is it better to instantiate inside or outside the constructor?

Code:
public class example {
private var _mc:MovieClip = new Movieclip();

[code]......

View 4 Replies

ActionScript 3.0 :: Can't Swap Child For New Class Instance IF Child Is Exported For Action Script?

Aug 18, 2010

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

View 2 Replies

ActionScript 3.0 :: Moving Document Class .fla Cannot Find The Document Class - WTF?

Sep 22, 2008

So I had a working .fla, with a document class package in the same directory. Everything was fine, until moving both to a new directory, now the fla cannot find the document class. WTF?

View 2 Replies

ActionScript 3.0 :: Actually See The Sprite Class?

Dec 3, 2009

but is possible to actually see the Sprite class?

Is accessable in any way, or written in C++ and embedded into the Flash player?

View 9 Replies

ActionScript 3.0 :: Values Of Holder And Child Alpha?

Dec 16, 2009

If my holder's alpha equals 0 can its child's alpha be effectively > 0 ? In my case I have holders (custom clases) with many children, some of which are holders them selves (with their own children and holders and so on).

I would like to:
-pick out a single holder from the 'tree'
-have all of the 1st level children of that are NOT holders themselves have an alpha of 1.

View 4 Replies

ActionScript 3.0 :: Set Focus On Sprite Class?

Nov 30, 2009

I'm tryin to set the global focus to a specific class that already exists on the stage after I remove a popup dialog from the screen. I pass the name of the class that was on the stage before the popup dialog is shown by string to the popup class.So public function PopupMenu(pClass:String)after I remove the popup dialog, I want to restore focus back to the previous class so it can accept key events again.How would I set focus to an instance of an object on stage. Currently I have something like this:

Main.mainStage.focus = (InteractiveObject)(getDefinitionByName(prevClass));
but it returns this error: TypeError: Error #1034: Type Coercion failed: cannot convert com.cox::IdleScreen$ to flash.display.InteractiveObject.

[code]......

View 5 Replies

Flex :: Draw To A Sprite Outside Of A Class?

Dec 26, 2009

I'm wondering (based on scoping rules) how I might do the following: I want to draw to a sprite that exists on the main stage in which I have a class instantiated.

So something like

public function MyClass(reference:String){
this.reference = reference;
}

[Code]...

Would I use super() in this case, or what's the usual methodology?

View 1 Replies

ActionScript 3.0 :: Accessing A Sprite In Class

Sep 4, 2009

I am trying to build a flip clock that utilizes filmstrip pngs. I have the main class instantiaing instances of the flipper class to hold the different number postions of the clock and then I want to tell the flipper instances to animate when the timer reaches a certain point in the main class. The problem is when I tell the flipper class to start animating I get a null value error from the flipper class.[code]Ok I guess writing it our helps figured out that the flipper wasn't through loading when I tried to call its properties, duh. Now can someone refresh my memory on how to broadcast an event to the Main class when the flipper class is done animating? I know I have to set bubbling to something but can't remeber exactly what it is. Also its not letting me create a singleton instance of the Main class in the Flipper class, I've done this before in other projects can someone tell me what I am missing on this one?

View 0 Replies

ActionScript 3.0 :: Write A Class For A Sprite?

May 24, 2010

write a class for a sprite?

View 1 Replies

IDE :: Function In Class Subclassing Sprite?

Apr 15, 2010

I have a class which subclasses Sprite (Class1). In this class I draw something on the stage. I have another class (Class2) that creates several instances of the first class (Class1) and places them on the stage. As I am creating the instances of Class1, I am adding an event listener for the CLICK event for each instance.When I click on any of the Class1 instances, I would like to execute a public function in Class1. However e.target is Sprite and I cannot conver it to type Class1.

View 2 Replies

ActionScript 3.0 :: Return A Value From An Extended Sprite Class?

Jul 14, 2009

I created a menu from a created .as extended Sprite class.

Except from this menu, I need it to return a String value of the item name the user selected.

View 17 Replies

ActionScript 3.0 :: Passing In Root From A None Sprite Class (MVC)

Sep 24, 2009

I am working with a simple MVC pattern.

But in my model i try to do this:

Main(root).Message(" model done!");

But i cant pass in the root, couse the model classes are Eventdispatchers and no sprirtes.

View 1 Replies

ActionScript 3.0 :: Attaching A Class To An Exiting Sprite?

Feb 8, 2009

Say I have an image that I loaded using a file loading class I wrote, but then I want to have another class be able to re-size the image anytime the browser is re-sized... can I do something like:

ActionScript Code:
var _fileLoaded:FileLoaderClass;
//this already contains a loaded image

[code].......

View 1 Replies

ActionScript 3.0 :: Set X And Y Position Of A Class That Inherits From Sprite?

Feb 15, 2009

I have a clas that inherits from sprite but i want to know when the x and y is set so i can make changes inside the instance, but i cant figure out how to do that...

i need it so that say if i set the x with the normal x property, it can set another variable or run a function.

View 2 Replies

ActionScript 3.0 :: Class - Thumbnail Extends Sprite

Feb 5, 2007

So I have a class that extends sprite. When I call an instance of my thumbnail object, I apparently can't use typical transforms on it by accessing .x and .y properties. These are not inherited from the superclass? Do I need to tell it to inherit these traits?

View 4 Replies

ActionScript 3.0 :: Reference Sprite Or Movieclip In Document Class

Dec 9, 2009

How do I reference MovieClips or Sprites created in the Document class from a custom class?[code]But I have a lot objects I want to reference so using the above method would take to long.I know I can do this to reference a MovieClip on the main stage from a custom class.[code]Would referencing the sprite created in the document class be similar?

View 1 Replies

ActionScript 3.0 :: Creating A Sprite And Calling It With Document Class

Dec 14, 2009

I want a cass using drawing API which will create a sprite with 2 levels...(item.addChild(sprite.1)......... addChild(item))
 
I want a document class to call this sprite and place it on the stage for animation...
 
how to create a multilevel spirte and then instantiate it using doucment class.

View 2 Replies

Actionscript 3 :: Query - Clicking And Determining The Sprite's Class?

Apr 13, 2010

i'd like to add all or most of my mouse events to stage, but in order to do that i need to be able to tell what is the type of the sprite being clicked.i've added two sprites to the display list, one of which is from a class called Square, the other from a class called Circle.

var mySquare:Sprite = new Square();
var myCircle:Sprite = new Circle();
addChild(mySquare);[code]...........

so far i know how to do is determine if it IS a sprite display object, but since i'll only be working with sprites i need something more specific.rather than checking "is Sprite", is there a way i can check "is Square" or "is Circle"?

if (myArray[myArray.length - 1] is Square)

View 1 Replies







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