ActionScript 3.0 :: Accessing Methods And Properties Via GetChildByName

Dec 2, 2007

I seem to be having a bit of a problem here. I'm generating a load of class instances using the following code:

maxpersons=25;
for (var i:Number=1;i<=maxpersons;i++)
{
var person:Person = new Person;

[Code].....

OK. I then need to run through each of them and check for a collision with an object from the main stage (called redDot), which I pass to a method (called doDamage) within the class. I'm using the following code:

for (i=1;i<=maxpersons;i++)
{
if (game.getChildByName("person"+i).hitTestObject(red Dot))
{
game.getChildByName("person"+i).doDamage(redDot);
}
}

I keep getting an error saying "1061: Call to a possibly undefined method doDamage through a reference with static type flash.displayisplayObject."!

It just won't work. I've tried altering the code to:

game["person"+i].doDamage(redDot);

but I get an unexpected trace output saying "TypeError: Error #1010: A term is undefined and has no properties."

View 6 Replies


Similar Posts:


ActionScript 3.0 :: Accessing Properties And Methods Of External SWF

Oct 2, 2011

I can't access the props and methods of an external AS3 swf after it's loaded by Main.as. Here's a very simplified version of the code for Main.as (the calling swf):

Code:
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
public class Main extends Sprite{
private var imgLoaded:Boolean = false;
[Code] .....

View 5 Replies

ActionScript 3.0 :: Setting Properties Of Objects Found Using GetChildByName

Mar 9, 2009

I am attempting to set the propreties of a navigation button (movie clip) that has been built dynamically. The button contains a text field that I want to format and a movie clip that I want to adjust the alpha. I find the object using getChildByName(), however do not seem to be able to set the properties using the code below.[code]

View 2 Replies

ActionScript 3.0 :: Accessing Property Of A Custom Component Through The GetChildByName Method

Jul 23, 2010

I have written a piece of code where I have created a custom class containing some of my custom properties.I have used multiple instances of this custom class in my main class and added it to a container.Now I need to access one of my custom property in the main class through container.getChildByName()."custom property", but I am not able to access my custom property using this.I get an error saying
Access of possibly undefined property orientation(this is my custom property) through a reference with static type ..name of my main class.

Is there no way that can i access custom property of components through the getchildbyname method of the parent container ??

View 0 Replies

ActionScript 3.0 :: Accessing Multiple Movie Clips With Loop And GetChildByName

Nov 3, 2010

All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.The first snag I hit was that I couldn't create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn't get it to work..So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.However, the movie clip I'm trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I'm very new to AS3...)I thought the trace(target1_mc.target2_mc.name); at the bottom of the following code would output the name of target2_mc but it doesn't...[code]

View 2 Replies

ActionScript 3.0 :: Access Methods / Properties Of Embedded Swf?

Feb 11, 2012

Access methods / properties of embedded swf? [code]...

View 7 Replies

ActionScript 2.0 :: Cannot Add Custom Methods N Properties To Every Class

Nov 7, 2004

In AS2 we can not add methods n properties to built-in classes in the way we do in AS1. Like we would -say- write the custom "isNatural" method on the "Math" class as follows : * The following code is valid in AS1 but not in AS2


[Code]...

As the "Math class" is static internally. We know why we can not add custom methods n properties to every class, as the way we do in AS1. Later I came up with senocular' s very nice tutorial on OOP in AS2. And now i know how we can do it in AS2 style in an efficient n organised way. But i have a problem with the following code. It should not work ! but it does... * Following code is valid for both in AS1 and AS2.

[Code]...

View 5 Replies

AS3 :: Accessing Methods In Loaded Swf

May 20, 2011

I'm loading an external AS3 SWF using the Loader class but i need to access a method inside the loaded SWF. how can i do this?

View 1 Replies

ActionScript 3.0 :: Access FileReference Class Add On Properties And Methods Of CS4 In CS3?

Apr 7, 2009

I have an urgent task to implement in my project code. I can't able to access the new properties and methods which are present in FileReference Class. For load() ,save() methods needs runtime version of Flash Player 10. I need to include the flash player 10 in CS3 publish settings Version. Otherwise you can suggest how i can able to access the FileReference class new properties and methods without CS4.

View 7 Replies

ActionScript 3.0 :: Class Errors : Undefined Methods And Properties?

Mar 21, 2011

i have a document with objects in the library with the class Hitte, Kern, Ring and Ring_01 [to Ring_16]tge Ring_ pieces have a subclass of RingSegment.the code of RingSegment.as is as following. [code]....which should add a Hitte_mc to the stage, make it draggable , and make the Ring_ objects react to a hittest with the Hitte_mc. but I get tons of errors:

View 11 Replies

Flex :: Access The Public Properties And Methods Of A Loaded SWF

Mar 18, 2011

How would you go about calling the public properties and methods of a SWF you load in actionscript?

I have been using stackoverflow for years to answer my programming questions so I wanted to give back by writing a guide to an issue I had a lot of trouble figuring out. This is my first user guide so tell me if there is anything I can do to improve it.

View 3 Replies

Methods Of Accessing/loading External SWF's?

Apr 20, 2010

What are some methods of accessing/loading external SWF's aswell as there variables inside them. I've been using URLrequest and loader methods no luck yet.

View 1 Replies

ActionScript 3.0 :: Classes - Why Static’s (not Available To Any Instances) Properties And / Or Methods Can Have A Public

Feb 17, 2009

I have a question about classes. I just learn that static means that functions and/or properties are specifics to a class, but is it a synonym of private? And why statics (not available to any instances?) properties and/or methods can have a public (available anywhere else (timeline)) access modifier? PS: I just start with classes.

View 6 Replies

Flex :: Getter And Setter Methods Versus Public Properties

Jul 27, 2009

Which is a much better practice in binding a value in Flex?

View 2 Replies

Actionscript 3 :: Can't Access Properties Or Methods Of MC Child That Has Been Added In Script

Apr 24, 2010

I have created a loop to instantiate tiles on a board. In the following example, "Gametiles" is an array containing objects of class "Tile" which is a class that extends MovieClip. "Game" is a MC that I added to the stage in the flash developing environment.[code]This method is a bit cumbersome though. I really don't want to have to create a var and call getChildByName every time I want to interact with these properties or methods. How can I set up these children so that I can access them directly without the extra steps?

View 1 Replies

Actionscript 3 :: Access Properties And Methods Of A Class Without Extending Or Instantiating?

Jan 9, 2012

Let's say I have a defined ClassA. ClassB extends ClassA and there's a Movie Clip instance on the stage linked to ClassB. How would ClassC access the properties and methods of ClassB without extending ClassB or creating a new instance of ClassB? The way I'm currently doing it is by referencing the stage instance linked to ClassB and then using the dot syntax to access ClassB instance variables, and this works only if the the accessed variables are public or internal, depending on what package ClassC is part of. I would like to know if there's a better, cleaner way to accomplish this.

[Code]....

View 2 Replies

ActionScript 3.0 :: Website That Gives A Full List Of Methods Properties And Keyboards?

Dec 4, 2009

Does anybody know of a website that gives a full list of all as3/cs4 methods, properties, keywords, classes, etc?

I bought a book on beginning AS3, but it only introduces some properties and methods as it uses them in examples.

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip Methods From A Class?

Oct 17, 2009

Here is the situation:I have created a movieClip named "tp_crack" on the timeline and created its class using linkage called "tp_crack".The tp_crack mc is like a small rectangle which breaks in 3 seconds when it is played.I have a seperate class in which I have used tp_crack to create many instances of tp_crack going by the names: cracked1","cracked2" etc.These instances are present in another movieClip (this time created within the class) called "crackContainer".Now I have added the following code to check for hitTest of those cracked1,2,3...... with a spaceship.The hitTest works but flash does not recognize the pieces as movieClips and does not play them as required, instead it gives me an error saying:1061: Call to a possibly undefined method play through a reference with static type flash.displayisplayObject.

for (var i:uint=0; i<crackedPieces; i++) {
if (crackContainer.getChildAt(i).hitTestPoint(Spacesh ip.x,Spaceship.y+(Spaceship.height/2),true)) {

[code].....

View 4 Replies

AS3 :: Flash - Accessing Object Methods Given As Value In Dictionary?

Nov 17, 2011

So I am writing a program which uses Dictionary to store objects. For example

var dictionary:Dictionary=new Dictionary();
var myObject = new myObject(var1, var2, var3);
dicionary["key"]=myObject;

where var1, var2, and var3 are simply means of assigning values to variables in myObject.can I access values or functions that are found in myObject? In myObject class I have some getters and setters. Can I use a getter to get the value of var1 for example.

dictionary["keys"].getVar1()?

View 1 Replies

ActionScript 3.0 :: Access FileReference Class Add On Properties / Methods In Flash Player 10

Apr 7, 2009

My aim is to access the FileReference class Flash Player 10 properties,methods and Events using CS3 instead of CS4.For load() ,save() methods needs runtime version of Flash Player 10.I need to include the flash player 10 in CS3 publish settings Version.Otherwise you can suggest how i can able to access the FileReference class new properties and methods without CS4.

View 1 Replies

ActionScript 3.0 :: Return ResultEvent Properties Of HTTPServices Inside Class Methods

Sep 29, 2010

I currently have my own class, for arguments sake, lets say it's called User and is for logging into my own system.

I would like to call a function from the user class called, say, login(), which would send the username and password attributes to a service (in my case, PHP), and then get the data back with the response (either successful or unsuccessful).

This would ideally make my code behave like this:

Code:
var user1:User = new User("Jim", "password");
var loggedIn:Boolean = user1.login();

[Code]....

I don't know of a way of getting the login function to return a boolean based on the result of the HTTPservice it sends, so does anyone know of a better way of doing this?

View 0 Replies

ActionScript 3.0 :: Accessing Global Variables In Functions/Methods?

Jun 2, 2011

Which of the following is better in terms of performance/effectiveness?

public var a:int = 0;
public function Addition():void {
a += 5;

[code].....

View 7 Replies

ActionScript 3.0 :: Accessing Methods In Loaded Document Class

Feb 9, 2009

I'm trying to access an init method I've set in one of my document level classes.

Container Movie loads Main Movie, which has Main.as as its document class, but I want to do a few things before I show the actual content. Here are some functions in Container.as:

Code:
public function moveLogo(e:TimerEvent):void{
loadTxt.visible = false;
var logoMoveUp:Tween = new Tween(logoCont, "y", Back.easeIn, 221, -250, 1, true);

[Code].....

If I trace e.currentTarget.content.init on my EVENT.COMPLETE callback function, I get "function Function()" like I should.

View 2 Replies

ActionScript 3.0 :: Accessing Superclass Methods On An Externally-loaded SWF?

Jul 27, 2009

I'm trying to set up a large project that has a "shell" application that preloads and eventually displays a bunch of SWFs as a "slideshow". Each SWF could be authored by different people but will reference a base document class so they exhibit consistent behaviour. One of these behaviours is to be able to localise the slideshow into different languages. Since each SWF could have a different number of textfields that need to be localised embedded into their main timeline, the SWFs each must declare their stage instances in their document class. In order to implement the common functionality (such as a "localiseText()" method), I have decided to package all common functionality into a superclass (what I'm calling "Base Class" in this example) and using a subclass as each slide's document class.

This Example:This is a simple example I set up because in my actual project my compiler was throwing a coercion error when I tried to cast the Loader.content as my external class. The structure of this example is the following:

+ loader.fla : this is the main "shell" application.
+ SWFLoader.as : the Document Class for loader.fla
+ external_1.fla : this is the external SWF file that will get loaded and displayed

[code]....

I've set it up this way because a hypothetical external_2.fla might have different public variables to declare its stage instances so would need a separate implementation of ExternalBase (presumably External2.as).

The code (in reverse):

base/ExternalBase

[code]....

This just sets up the localiseText() method which is used in this example to change the contents of the text field. Since we don't know the name of the text field in the particular slide's timeline, we have to ask for it from the subclass' implementation of getLocalisableTextField(). We declare an abstract function here that needs to be overridden in the implementation.

[code]....

View 11 Replies

ActionScript 3.0 :: Error #1009: Null Object Reference Can Not Access The Properties Or Methods

Sep 3, 2009

Load external SWF file, an error: TypeError: Error #1009: Null object reference can not access the properties or methods.

View 0 Replies

ActionScript 3.0 :: Accessing An Object Through One Of Its Properties?

Jul 7, 2011

I'm doing some work with JSON in as3 using as3corelib (very useful) and was wondering if it is possible to get an object if all you have is one of its properties, also an object. Here's an example of some JSON:

"parentObject": {
"propertyObject": {
etc.
}
}
so what i'm asking is, if I have propertyObject, can I access parentObject somehow?

View 2 Replies

ActionScript 3.0 :: Accessing Properties From Another Package

Oct 23, 2011

I am working on setting up some simple AI actions for my enemy class in the game that I am working on, but I am having trouble accessing the player's X location within the enemy package to set up a detection function. I have defined the player on my Level package along with the enemy, and I defined the player's and enemies X and Y locations within the Player/Enemies package respectively.

Within my flash file I have linked to my Level.as file. Also within my flash file library I have two movie clips. Both have a square in them that are the same size but colored differently. One is called PlayerSpriteMC and the other is called EnemiesSpriteMC.

[Code]...

View 1 Replies

ActionScript 3.0 :: Accessing Another Class's Properties From A Different One?

Jul 1, 2009

I have two movie clips on the stage at frame 1 and frame 2. Both are instances of seperate classes. (They are not dynamically created, just their linkage is set to their class names)I have created soundChannel and Sound Objects in Class 1 and I want to access them from Class 2. (I want to stop the sound channel that was started in class 1)Is there any way to do this? If yes, will this be true for other properties also?

View 7 Replies

ActionScript 3.0 :: Accessing Parent Through One Of Its Properties?

Jul 6, 2011

I'm doing some work with JSON in as3 using as3corelib (very useful) and was wondering if it is possible to get an object if all you have is one of its properties, also an object.Here's an example of some JSON:

ActionScript Code:
"parentObject": {
"propertyObject": {

[code].......

View 2 Replies

IDE :: Accessing Object Properties On A New Frame?

Apr 25, 2009

I'm having trouble accessing objects on new frames.On frame 1 I have:

Code:
var HelloWorld:Object = new Object()
On frame 2 I have:

[code]....

View 3 Replies







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