ActionScript 3.0 :: Accessing Properties Of External MXML?

Sep 16, 2010

I have written "components" in external .mxml files like dialogs and such. For example, GamePropertiesDialog.mxml. These components are used by another file, Main.mxml for example. If I instantiate a GamePropertiesDialog I am unable to access its pieces like a textbox with an id of GameName until AFTER I add the dialog to the display list.Doesn't work:

Actionscript Code:
var tmp:GamePropertiesDialog = new GamePropertiesDialog();tmp.GameName.text = 'test';addChild(tmp);

Does work: Actionscript Code:
var tmp:GamePropertiesDialog = new GamePropertiesDialog();addChild(tmp);tmp.GameName.text = 'test';

View 1 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

Flex :: MXML Syntax To Assign Properties Of Subcomponents In Custom MXML Components?

Jun 4, 2011

I am working on a custom Flex 4 component which is an aggregation of two existing flex components. I would like to be able to specify my own custom properties for the component as well as access the existing public subcomponent properties via MXML. For instance I might want to adjust the font color or style for the label and text input. toy component which aggregates both a label and a text input:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"

[code]....

View 1 Replies

Actionscript 3 :: Flex When Mxml Described Component Initialise It's Mxml Described Properties

May 28, 2011

I am trying to override a Button class, i have a few properties which i wish directly initialise with the mxml description of the component, like :[code]which function is triggered ( in order to override it ) when all properties with mxml description is fully initialised with their values ?

View 1 Replies

Flex :: When Do The Properties In A Mxml Declaration Get Committed To The Object

Feb 1, 2010

If I do something like:

<myComponent id="foo" title="bar" />

The parameters don't seem to be available immediately within the component. When do they become available?

View 2 Replies

ActionScript 3.0 :: Custom Class Setting Properties Through MXML

Mar 10, 2009

I have just created a custom AS3 Component to use in an MXML project.[code]but then i lose some re usability.What do i need to do to be able to set properties from mxml?

View 3 Replies

Flex :: Accessing A Class Within Mxml Tag?

Jul 24, 2010

I would like to provide my own sortItemRenderer within an AdvancedDataGrid like so:

<mx:AdvancedDataGrid sortItemRenderer="MyRenderer"></mx:AdvancedDataGrid>

MyRenderer is a class that I wrote, but Flex doesn't see it and gives "defintion not found" error, because it is not within the mx namespace. What is a clean way to make this to work?

View 1 Replies

ActionScript 3.0 :: Accessing A Button In An Mxml Component From Other

Aug 1, 2009

I have a two components Test_Interface.mxml & teacher_fullscreen.mxml. I called teacher_fullscreen.mxml from Test_Interface.mxml by

[Code]...

Now I created an instance of Test_interface in my 2nd mxml by

Code: public var par:Test_Interface=new Test_Interface(); Actually, I wanted to disable a button in Test_interaface.mxml with id = "b1" from my 2nd mxml using the object created above. So I gave par.b1.enabled=false; It did not give any compile errors but during run time cannot access object or method of null reference sandbox error was returned for the statement par.b1.enabled=false. So how do I change the property of a button in one component from other.

View 0 Replies

ActionScript 3.0 :: Accessing AS Classes In A MXML Document?

Sep 21, 2009

how to put actionscript classes into an MXML document? Lets say my class represents a movieclip, a rotating triangle for instance. How do i put that into a <mx:vbox> containter? I can do the AS work in a <mx:Script> tag, but how do i embed my class instance?

View 2 Replies

Flex :: Grid - Error Accessing To Property In (mxml)

Nov 23, 2011

I have an MXML file with this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="30">
<mx:Script>

[Code]....

View 1 Replies

Flex :: Load An External Mxml File Into A Parent Mxml File?

Mar 9, 2012

This is a project I'm working on for a simple demo tutorial application in Flex. I am using mxml pages. You can see to the left that I will have my main application and then other mxml files (In the Examples Package) as the examples that will be loaded into the main application mxml. How can I dynamically pull the value from the object in the list to load the child mxml file into the container that I have further down in the application?

View 1 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

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

ActionScript 3.0 :: Accessing Properties Of Embedded SWFs

May 31, 2009

Is it possible to access variables or even functions of an embedded SWF? (One which has been embedded manually and has not loaded from somewhere)For example, I embed an swf called Movie1 which contains a string variable declared in its root, would it be possible for the parent SWF to access that string?

View 1 Replies

ActionScript 3.0 :: Accessing Properties Of The Document Class?

Nov 14, 2009

when I try to access a property of the document class from another class, I get an error:

Quote:

1119: Access of possibly undefined property _left through a reference with static type flash.displayisplayObject.

Maybe I'm not doing it correctly? This is how I've been accessing document class properties so far. Does the fact that they're private make a difference?

Quote:

root.property

View 1 Replies

ActionScript 3.0 :: Document Class, And Accessing Properties?

May 25, 2009

I'm currently working on an interactive app, (site) which requires me to modify a few textfields, and change images dependant on the user choice (using mouseevent). This is a separate module, thus I'm posting the question in here instead:there are three images, that are lined up, with a textbox next to them. When a image is chosen, and enlarges, the text changes with the chosen image, according to XML.The textFields, 'text_title', 'text_description' are contained in a movieclip, called 'textbox'.This has been built in the Flash IDE (CS3) named info.fla/swf, which refers to a Document class 'com.info', made in Flex Builder 3...I attempted to modify the textfields using this:textbox.txt_title.text = "Loading";textbox.txt_desc.text = "test";But, I was unable to at first to change the text using the document class, as it gives "1120: Access of undefined property <variable>".

View 3 Replies

C# :: - Accessing Object Properties From String Representations

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

ActionScript 3 :: Accessing Properties Via String In Object

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

ActionScript 3.0 :: Accessing Some Properties Of A Custom Component?

Jan 15, 2009

I have been stuck on this problem for a while, and wonder if anyone knows the answer. It is concerning accessing some properties of a custom component. I marked the problem with the keyword [PROBLEM] in the following snippets of code.

components/State1UI.mxml
--------------------------------
<?xml version="1.0" encoding="utf-8"?>

[code].....

View 0 Replies

ActionScript 3.0 :: Accessing Properties Of The Stage From A Class?

Aug 29, 2009

I am trying to access the x and y properties of the stage so I can set an objects' x and y properties to place it on the center of the stage:

this.x=stage.stageWidth/2;
this.y=stage.stageHeight/2;
The call to instantiate the object(*.fla):

[code]......

View 4 Replies

ActionScript 2.0 :: Accessing Properties Of Movie Clip?

Apr 26, 2010

I have the following prob :

I created several instance of the same MC like this

[Code].....

View 1 Replies

ActionScript 3.0 :: Accessing Properties From Stage In A Class?

Feb 28, 2012

I am trying to access a property that belongs to the stage, from a class. For example, let's say I add a textfield with an instance name of "magic_txt" on the stage. In the Document Class, I am able to access magic_txt and update the field like so:

magic_txt.text = "Magic Text"

However, since I would like to work in classes, I am having a difficult time figuring out how to access the property "magic_txt.text" from a class. I know I need a reference, but I am unsure how to set this reference.

I am coming from a strong background in Visual Basic, and in Visual Basic, the way to access a form property is to call the form name (dot) object. In actionscript, it doesn't seem to be as simple.

View 9 Replies

ActionScript 2.0 :: Accessing Object Properties Dynamically?

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

ActionScript 3.0 :: Accessing Properties For An Mc In An Externally Loaded Swf?

May 24, 2010

I am trying to set a couple of properties (specifically width and height) for an mc within an externally loaded swf but am having bigtime troubles. Keep getting the 'Error #1010: A term is undefined and has no properties'. The code is attached below. I have tried to figure this out and searched for solutions but could not resolve this myself.

import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;

[code]......

View 1 Replies

ActionScript 3.0 :: Accessing Object Properties Dynamically?

Jun 27, 2010

hat is the correct way to access an object dynamically? I have tried this with no success:

Code:
i += 1;
var myVar = this[myObject. + "myProperty" + i];

[code].....

View 3 Replies

ActionScript 2.0 :: Accessing (Nested) Component Properties From Class

Jul 29, 2009

(Actionscript 2 btw - and actually cs4, not that it really makes any difference?) I have a class that instantiates a movieclip from the library, e.g.:
Code:
debugbar:MovieClip = thing.AttachMovie("debugbar", "debugbar_mc", 999);
So attaching it to the where ever "thing" is - could be movie clip or level0 or whatever, doesn't matter as "debugbar" is a private variable of the class. Now the important part - debugbar in the library is a movieclip that contains some components - buttons and textInputs. The problem comes when trying to access these components.

I would have thought that this would work:
Code:
debugbar.input_txt.text = "hello";
In order to set the text of "input_txt", the instance name of a TextInput component on the timeline of the movie clip (put there in author time). However, this does not work. Infact, I cannot access any specific "component" properties - they come back undefined. I can however set and retrieve MovieClip properties for the "input_txt", such as _x. However there is one added strange thing with this too - setting _visible to false doesn't seem to work (however perhaps a component by default overrides this).

I also appear not to be able to add event handlers to the component - at least for the usual component events. I tried casting it to a component, such as:
Code:
var temp:TextInput = TextInput(debugbar.input_txt);
trace(temp);
which gave "temp" as null.
However if you trace the thing itself without casting to what it is, it gives the path to correctly. It almost seems like the components are somehow broken when trying to access them this way - or that they cannot be accessed this way?

The thing is, I was able to access all of this before, when the code to do it was placed on the timeline (frame 1, the only frame) of the debugbar itself, where the components were child instances. This meant I could just reference them directly too - so input_txt rather than debugbar.input_txt , although that is probably largely irrelevant. I need to have it in a class though, as I need to pass in certain objects that need to be accessed by the mc.

View 2 Replies







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