ActionScript 3.0 :: Accessing DisplayObject From Insde An Object?
Dec 30, 2010
Document Class have a stageRef:MovieClip object (same size as the swf) that all the other displayobjects are added.And I have 2 more classes: createLevel and Player. Player class generates a box object and adds it to the stageRef from inside the class itself with:stageRef.addChild(this)createLevel class is used to generate a 11x15 sized grid and also have one container named blockHolder that holds the grid pieces.hat I am trying to do is I cant reach the creteLevel's blockHolder object from Player Object. I am also adding some related code below:Document Class:
PHP Code:
private var oPlayer:Player;
private var oLevel:CreateLevel;
[code].....
View 6 Replies
Similar Posts:
Dec 16, 2009
how can I add attributes to a Display Object, that I have created in the Authoring Tool, so I can acces it by:
myDisplayObjectInstance.myNewAttribute
Is a DisplayObejct a dynamic class, that can be extended from anywhere?
View 2 Replies
Apr 2, 2010
I have an xml say in following format
[Code].....
What I should do is parse an xml and from its node name create object property and then create an object array based on those property. Am I able to make myself clear.
View 4 Replies
Nov 7, 2009
I have 2 classes, Display holds the currently selected Component:
public class Display
{
public static var selectedComponent:Component;
}
Component has an ID string and the selectedComponent variable is set on click:
public class Component extends MovieClip
{
public var id:String;
addEventListener(MouseEvent.CLICK, function() {
[Code]...
Removing the selectedComponent variable type so it reads public static var selectedComponent; removes the conversion error and seems to change the ID variable but it appears to only be a copy of the object.
View 2 Replies
Aug 1, 2009
I'm putting together a project where I'm loading different images at different times. The first image loads when the app starts. After the user answers some questions, I load a different image, replacing the first. When I try to do that, I get an error:
[Code]....
View 4 Replies
Oct 26, 2010
I would like to be able to quickly check if a given DisplayObject is a descendant (not in the inheritance sense - ie. child, grandchild, great-grandchild, great-great-grandchild, etc.) of another DisplayObject. There doesn't seem to be a native way to do this and I can only think of two ways to achieve it: Create the mother of all nested loops. Seems a bit, I dunno, wrong? Dispatch a bubbling event at the 'child' and check if the potential 'parent' receives it.
[Code]...
View 2 Replies
May 31, 2009
I have problem with accessing object created by function imported from another package.
I have 2 packages DragDrop and UserInterface. In UserInterface I create methods for buttons and later add them in DragDrop . I make it in two different ways:
One(this one works):
[Code]....
View 6 Replies
Jul 20, 2011
I'm just starting with OOP in AS3 so apologies if this question is too simple...The goal of this script is to have a button change it's own features (colour and transparency) and change the alpha value of a loaded picture.There are 27 buttons for 27 (stacked) pictures.In the fla is the following code:[code]When I try to access the picture (= portrait class and the test_portrait var in the fla) it can't be found. The object and the loader have for example this path when I debug: Movie Clip: Frame=0 Target="_level0.p_4.l_4. But when I do trace(getChildByName("p_"+tmp_name)); in the P_button class it returns null. Doing the same trace from the fla returns: [object Portrait] Why can't I access it from the P_button class?
View 6 Replies
Nov 14, 2009
Can a flash.display bitmapData object be converted to flash.displayObject? i bump with an error when i tried to convert a bitmapData to DisplayObject
=> setChildIndex(DisplayObject(bitmapData),0);
"TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::BitmapData@35f4779 to flash.display.DisplayObject."
View 2 Replies
Nov 25, 2009
Ok, so I made a custom class, but I did not want to add all the text to it through code (much easier to type it in flash on the frame). I name the instance aScoreBoard.
As my code runs, I need to call some of the functions that are part of the ScoreBoard class. As the code gets to this point, I try this line:
aScoreBoard.UpdateScores(passArray);
which will update the scores on the scoreboard. When that line in AS3 tries to execute, I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main/Main:ayEnd()[C:projectsDev_LearningLongJumpsrcMain.as:616]
at Main/Main::ButtonAfterJump()[C:projectsDev_LearningLongJumpsrcMain.as:606]
Is there a way to do things this way? or will I have to go and do all the extra text entering in the code?
View 2 Replies
Jan 19, 2011
I am trying to access a shared object declared in a certain function, from another function. I am having
difficulty doing so. My code are as follows:
[Code]...
View 1 Replies
Dec 20, 2010
I am trying to access an object I created from an another object.I have the document class main.as and two other classes player.as and console.ascircle.as is draws a circle on the stage and logger.as is a simple class that I will use to trace stuff and record data.In main.as I created both two objects and I want to be able to access the console class methods from player class (and all the future classes that I will write)Main.as:
PHP Code:
packagecom.tolgainam
{
[code].....
View 8 Replies
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
Apr 9, 2010
I have a project that i'm working on, and in the project it's important that i have an object that i can create with actionscript that already has two arrays inside of it. To do this, i made the movieclip, i checked export for actionscript in the library, and in the custom class that corresponds to that object i made the arrays with the following code:
package {
import flash.display.*;
public class cont extends MovieClip {
[code]......
View 6 Replies
Jul 1, 2010
I have have a problem loading and accessing data from a value object in my new project.. I load an xml file via a service, which contains title and locations of asset files, I need to be able to access the location of an asset file by specifying the title and retrieiving it from a value object.. I'm using the Robotlegs framework, here's an example of the xml:-
<?xml version="1.0" encoding="utf-8" ?>
<files id ="xmlroot">
<file title="css_shell" location = "css/shell.css" />
[code].....
View 1 Replies
May 13, 2011
ActionScript Code:
//Main.as -- document class
public var content:Content;
something something ;
[code]....
What I need to do in Carousel.as is that, get the images in the MC to carousel (d'uuh).So, how do I get those objects from the Carousel.as class? I have declared the names of things in it as public vars but no luck so far.
Hierarchy of content:
content --on some frames-->carouselcontent(named in IDE - of Carousel type)-->image1, image2, image3(all named in IDE)
Hierarchy of all:
stage-->content(Content.as)-->carousel(Carousel.as)
View 4 Replies
Oct 20, 2007
How do I access the object of an event? Can't quite figure it out. This is what's happening.
object.contentLoaderInfo(Event.INIT, someFunction);
private function someFunction(e:Event):void{
trace(e.target);
}
Output = [object LoaderInfo]
I want to access the parent of the object, but I'm hitting a dead end.
View 3 Replies
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
Mar 19, 2010
In actionscript an object's property can be accesses in this way: object["propertyname"] Is something like this possible in c#, without using reflection?
View 2 Replies
Oct 17, 2010
I have a HTML page that contains a flash file and some a JavaScript function that returns the object of the flash file.So far I can call the JavaScript function from C# and have it return an Object, but I want to cast it as AxShockwaveFlash and access the COM Object directly from C#.I have seen this done with Windows Media Player imbedded in the a HTML page, but it doesn't seem to work with flash.[code]When I try to cast the Object to AxShockwaveFlash it fails, but I have seen it work casting the object to WindowsMediaPlayer.I tried to find if AxShockwaveFlash supports QueryInterface calls, as per the error message but Google returned nothing of value.
View 1 Replies
May 1, 2011
I have an engine I created a while back that loads objects into a container based on XML data. A really quick example of the XML would be like this:
<level>
<object cname="enemies.Robot">
<pos x="200" y="400" layer="mobiles" />
</object><object cname="Player">
<pos x="12" y="89" layer="mobiles" />
</object></level>
I have a class Environment that has a method loadLevel(data:XML) which I parse the XML through, then the function runs through the XML finding all object nodes and uses getDefinitionByName to determine which Object I want to create based on object.@cname. From here, I have to manually define each property based on the XML like so:
obj.x = xml.pos.@x;
obj.y = xml.pos.@y;
etc.
I was wondering if there's an inbuilt method for setting a property based on a String. By this I mean something like so:
var mc:MovieClip = new MovieClip();
mc.someInbuiltFunctionThatSetsAProperty("alpha", 0.5);
This way I could change my XML to be more like so:
<object cname="Player">
<props>
<x>200</x>
<y>221</y>
<alpha>7834</alpha>
<health>Something</health>
<power>3</power>
</props></object>
And iterate through all the children of props to set all of my properties on the fly. I know if I create an Object and set properties within it like so:
var obj:Object = {
var1: "hello",
var2: "there",
name: "marty"
};
That you can then iterate through names/values using the for(String in Object) loop like this:
var i:String;
for(i in obj){
trace(i + ": " + obj[i]);
}
/**
* Output:
* var1: hello
* var2: there
* name: marty
*/
Surely there's a way, as here's an example of identifying a property using a String:
var ar:Array = [new MovieClip(), new MovieClip()];
ar.sortOn("alpha", Array.ASCENDING);
So just to make my question more to-the-point: I want to be able to get and set properties that I can identify using a String.
View 2 Replies
May 18, 2011
I'm using FlashDevelop as IDE and I'm trying to connect to AMF3 service (amfphp) and get user details.I can connect to AMF service with this code in AMFinit() function...
private function AMFinit():void{
AMFService.objectEncoding = ObjectEncoding.AMF3;
AMFService.connect(AMFServiceURL);
AMFService.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
[code]....
But to use outside the AMF_MyUserInfo() function I want to copy that "res" object to another object. I tried with specifing an object in Class and set res to this object in AMF_MyuserInfo() function with "this.myobject = res" but it didn't work.
I also tried "this.myobject.username = res.username" but it didn't work also. how can I use this res object globally or in AMFinit() function?
View 1 Replies
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
Nov 30, 2009
I am new to action script working with flash cs4 with action script 3.0. How do i access a UI object(stored in .fla) in action script. I have already linked these two files. It is working fine. I have a button as UI object, that was converted as symbol and instance name has already given. I cannot access the button using the instance name in actionscript. If i tried so there is no intellisense. How do i access it in script. I am using oops style of coding.
View 2 Replies
Jan 23, 2010
How do you access a child that has been added to an object?For example if I have a movieClip on the stage and I add a child to it, how do I then access that child?
Code:
var newClip:MovieClip = new MovieClip();
newClip.addEventListener(Event.ADDED, checkClip);
[code]......
View 4 Replies
Nov 16, 2010
I need to store a users username that has successfully logged onto our system.
The user will be accessing a directory behind the corporate firewall.
I've talked to IT about it... they have said.
Quote:
I can put an integrated security virtual directory in place.
In turn, you would need to figure out how to get the �current logged on user� details from the environment variables that are in the request object (that comes from the user�s browser to the webserver).
View 3 Replies
Mar 4, 2011
Is there a way out there to essentially loop through a generic object to find out what parameters/properties are being used and/or what there names are?
ActionScript Code:
var obj:Object = new Object();
obj.foo = "hello";
obj.bar = "world";
//... and on for however many params you need
[Code] .....
I might be trying to do something that is essentially not possible, but I'm just thinking it would be very nice sometimes to access different parts of an object without having to directly know what the param name is...
View 3 Replies
Aug 26, 2011
How would I go about accessing the object I am moving with a tween through TweenEvent? or is this even possible? I think e.currentTarget will give me the tween object instead of the movieclip it is controlling, but I'm not sure.
Example:
ActionScript Code:
var tweens:Array = new Array();
[code].....
View 1 Replies
Jan 20, 2006
I have created a sharedobject on a local hard drive that stores multiple objects in it. I need to know how to access one particular object in that sharedobject.
View 14 Replies
Jun 21, 2007
I have a custom property called Player (like a basketball player) that has properties for points per game (ppg), rebounds per game (rpg), etc.I'm designing a piece where users can get averages and compare players across many different categories.
I have a String variable "stat" that tracks which property they want to compare. I can use "stat" in a sorton function, but need to use it to access the object property. So when the user chooses "ppg" or "rpg" i can access Player.ppg and Player.rpg by using the stat variable. Player.stat doesn't work.
View 2 Replies