Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Object.property.property ?



I'm making a movie that will read data from an object and build some rows and columns of radio buttons, but I'm having some trouble dealing with the objects that I'm using to store data on the _root.

Here's what I'm trying to test:

I have the following code on the root of my movie:


PHP Code:


radio_button_object = new Object ();
radio_button_object.row_2 = 2;
radio_button_object.row_2.radio_button_1 = true;
radio_button_object.row_2.radio_button_3 = true;



Within a movie clip named "radio_button", I've got the following code:


PHP Code:


myObj = eval ("_root." + this._name + "_object");

// inside a for loop I'm going through rows
// inside that for loop, I have another for loop that goes through columns

for (i...) {
  for (j...) {
    if (myObj ["row_" + i]) {
      if (myObj ["row_" + i + ".radio_button_" + j]) {
        (eval ("row_" + i + ".radio_button_" + j)).gotoAndStop ("selected");
      }
    }
  }
}



I've tried:


PHP Code:


myObj ["row_" + i ["radio_button_" + j]]



and:


PHP Code:


myObj ["row_" + i] ["radio_button_" + j]



But I've had no luck.

Essentially, I'm looking for object.property.property, except that the object name and all property names are variables.

Can anyone help me out?

Thanks!
cooper
www.pigdogtoad.com



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-24-2004, 04:21 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Get Property Visibility Set Property Visibilty
I am trying to work out some navigation on a site to make it more user friendly.
I have a number of buttons which when clicked set their correspoding graphic to visible and all the other relevant graphics to invisible.
This is so I can get the graphics to appear in the same place but only one visible at any time so no overlap.
What I already have is a rollover so that when the user rolls over the buttons the corresponding graphic will appear. Then dissappear on rollout. And the script to place my graphic in the right place and make it visible. Here is the script.

on (rollOver) {
setProperty("_root.drag0", _visible, "1");
setProperty("_root.drag1", _visible, "0");
setProperty("_root.drag2", _visible, "0");
}

on (rollOut) {
setProperty("_root.drag0", _visible, "0");
setProperty("_root.drag1", _visible, "0");
setProperty("_root.drag2", _visible, "0");
}

on (release) {
setProperty ("_root.drag0", _x , 323.4);
setProperty ("_root.drag0", _y , 360);
setProperty("_root.drag0", _visible, "1");

}
The bit I can't work out is how to get the graphic which has last been clicked and locked visible (rather than temporaly visible on rollover/out)to revert to being visible on the rollout of the other buttons.
I think I need to use the get property and set property but can't quite work out how to link the two so that it checks which graphic is visible before the rollover on a different button, makes it invisble on the rollover and reverts it back to being visible on the roll out.

Sorry That was long finding it hard to explain.
Thanks for any help you can offer. I am using flash mx 6.0.

Preloder ScaleX Property And X Property
Hi!

within the loader listener's progressevent I had my preloader mc update the scaleX property and works fine, thus, it moves and scales just like a preloader does until it reaches 100. My only concern is when scaleX updates the preloader mc 'x' location seems to be moving as well making the preloader clip looked liked it scales on both sides (both ends of the line). As i examined the preloader mc 'x' property it stays the same all throughout. This is weird.

anyone?

thank you in advance.

Object Property Leak
Heres some simple code I was using, but for some odd reason, the points 1-7 appear in the trans object??

In frame 1:

Code:
function new_Mesh(type){
mesh = new Object();

if(type == "cube"){

mesh.numPoints = 8;
mesh.point0 = [-50,50,50];
mesh.point1 = [50,50,50];
mesh.point2 = [50,-50,50];
mesh.point3 = [-50,-50,50];
mesh.point4 = [-50,50,-50];
mesh.point5 = [50,50,-50];
mesh.point6 = [50,-50,-50];
mesh.point7 = [-50,-50,-50];
}

return mesh;
}

function new_IdentMX(){

var matrix =[
[1,0,0],
[0,1,0],
[0,0,1]];
return matrix;
}

function new_XrotMX(deg){
var rad = (deg*(Math.PI/180))

var matrix = new_IdentMX();

matrix[1][1] = Math.cos(rad);
matrix[1][2] = -Math.sin(rad);
matrix[2][1] = Math.sin(rad);
matrix[2][2] = Math.cos(rad);

return matrix;
}


In frame 2:

Code:
MyMesh = new_Mesh("cube");
Trans = new_XrotMX(30);
stop();


put this code in two keyframes, and goto debugger, and look at the contents of Trans. points are there, which shouldn't.

Is this some sort of bug? Most likly not, but its apparent that nothings wrong.

Object Colour Property
Hey guys,

Is it possible using purely actionscript to draw a box in a specific location, and give it a certain colour value, then 'tween' it to another colour value?

What Im trying to do, is setup a movie which changes scenes by smoothly changing the background colour to the colour of the next scene.

This obviously poses a problem .. because depending on what scene you are in, and what link you chose, the starting and finishing colour of the box must be different in each case.

Any ideas?? Would be awesome

Object Property Question
Hello,

fieldname = object.name?

I'm curios as to how the 6th line of code works --
-- _root.txtName = c.name. In particular the c.name oop syntax. I thought the correct name property was written as... _name not just ...name? This code only executes if the word "name" is used -- no substitue words will work. I can't find anything on this in Flash Help.

Any enlightment will be appreciated.

Thank You

iaustin

var c = new loadvars();
c.onload = information;
c.sendandload("http://www.digitizedi.com/test.php", c, "POST");
function information(success) {
if (success) {
_root.txtName = c.name;
// Or you can also use:
//_root.txtName = c["name"];
} else {
_root.txtName = "operation failed";
}
}

How Do U Assign A Property Name To An Object?
here's the problem I want to assign a name to a property in a object dynamicly. Normaly I would just do this

rooms = {}
rooms.bedroom = ["bed", "tv", "hamper"]

but the name of the property is generated dynamicly and is a string. So if i have a string, how do i make it the property name. Example:

rooms = {}
rooms.["bedroom"] = ["bed", "tv", "hamper"]

Any ideas?

Can't Add A Property To Simple Object
var tester:Object = new Object();
var tester.loaded:String;

gives the error 1086: Syntax error: expecting semicolon before dot. How can I give my object a property?

[CS3] Having An Array As A Property To An Object
Hey folks!

Does anyone know how to create multidimensional properties in an Object?! (ie. Having an array as a property to an Object)

This works:

Code:
data = new Object();
colName = "some_name";
data[colName] = "the data";

trace(data.some_name);

trace(data[colName]);


But I need to to this on a deeper level. Like this:

Code:
data = new Object();
colName = "some_name";
data.property.[colName] = "the data";

trace(data.property.some_name);

trace(data.property[colName]);


I been trying several ways to solve this problem. Searching google over and over. But I just can't find the solution!
Does anyone know how to have an array as a property!?

Getting Just The First Enumerable Object Property
Does anyone know of a direct way to get the first enumerable object property?
I know using a for in loop would work, but I was hoping for an alternative that's a little less round-about

Er...oh...and I need to be able to get the property name, not value.

Limitations Of Object / Property Name
Say I am creating a movie clip like so:

_root.createEmptyMovieClip("someString",someDepthI nt);

What character limiatations are there for the "someString" parameter? For instance, can i have a '.' or a '_' in this string and still be able to access the new movie clip via _root.someString or _root["someString"] ?

Remove Property From Object
Hi,

I have an ObjectCollection class which I need to allow me to add and remove props from an object.

The adding is easy, and I can remove a property's value, but how do I remove the prop itself:


Code:
delete myObject["prop"]
... removes the value, but if I iterate through the object, the property still remains, just with the value of null. So how do I get rid of the property?

Thanks

Object Property - Can It Have A Space?
for instance, in a for loop i have the following code
clearly it will not compile because of the "Total Verts" code, is there anyway to make a space in a property?

The reason i ask is because im populating a data grid with the property names, and I wanted the section to be named "Total Verts"


var frameObj = new Object();

frameObj.Total Verts = framesArray[i].totalVerts;
frameObj.Elements = framesArray[i].totalElements;
frameObj.Frame = framesArray[i].frameNum;

Object Property Typing
heres my problem

slideshowimage[slideshowimages]=new Object;
slideshowimage[slideshowimages].isinshow=true
slideshowimage[slideshowimages].address=testpic1.jpg
slideshowimage[slideshowimages].xoffset=0
slideshowimage[slideshowimages].yoffset=-50


How can i define each of these properties so that they are the correct type

for example :

i would like the property "isinshow" to be defined as a boolean and "xoffset" defined as an int and etc...

Anyone know how to do this?

Using A Variable To Specify An Object Property
Hey all,

Suppose I have

columnName : String = 'name';

and then I have a dataGrid that I want to add an item to via:

dG.addItem({columnName:'joe'});

This creates a column called "columnName". Is there a way to use the value of the string "columnName" instead as the column title?

Thanks in advance!
fitz

Object.constructor Property
<definition from ActionScript 2.0 Language Reference>
...constructor (Object.constructor property) ... Reference to the constructor function for a given object instance. The constructor property is automatically assigned to all objects when they are created using the constructor for the Object class ...

//--- --- - - -

i thought i understood this until i started doing some multiple level inheritance ..

imagine three classes:
-- class Object . . . (top level class)
-- class ParentClass . . . (implicitly inherits from Object)
-- class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)

and three objects:
-- var obj:Object . . . (an instance of Object)
-- var parentObj:ParentClass . . . (an instance of ParentClass)
-- var childObj:ChildClass . . . (an instance of ChildClass)

what we get:
obj.constructor == Object //-- as expected
parentObj.constructor == ParentClass //-- as expected
childObj.constructor == ParentClass //-- i would have thought it would be == ChildClass

//--- --- - - -

furthermore .. if i change my class definitions to be a bit less ambiguous:
class Object . . . (top level class)
class ParentClass extends Object . . . (explicitly inherits from Object)
class ChildClass extends ParentClass . . . (explicitly inherits from ParentClass)

what we get:
obj.constructor == Object
parentObj.constructor == Object
childObj.constructor == Object

//--- --- - - -

if this is the intended functionality of the constructor property i'm not sure i understand what its purpose is .. or am i completely misunderstanding something here .. if anyone has any answers i would be happy to hear them

also .. feel free to ask for clarification (if i was unclear) or more complete code samples.





























Edited: 04/26/2008 at 02:16:39 PM by _peabulls_

Object Property List?
Hi,

I was wondering if there was a list somewhere of the different kinds of flash objects with all their associated properties that can be changed via Actionscript?

Keith

Using_alpha Property To Fade An Object::
I'm wanting to ask what actions to apply to an object to make it fade in rather than using a motion tween to achieve this. The reason is that I understand by doing this, you save overall file size because the motion tween makes for larger file size. - Can somone please enlighten me?

Property Of Framerate In Movie Object
How do i change the property of framerate in a movie object during runtime.

Accessing Object Property Indirectly
Hi. I am trying to set (and retrieve) an object property through a constructed variable.

Items = new Array();
Items[0] = new Object();
propName = "Description";

tempVar = "Items[0]."+propName;

eval(tempVar) = "This is the description";

======

The above eval does not assign "This is the description" to Items[0].Description.

What command do I use to make the assignment?

Many thanks,
Tracy Boland

Adding An Array As A Property Of An Object
Hi all,

I'm generally familiar with addProperty and all of it's little foibles (ho-hum). The one thing I can't seem to get working is having an array as a property.

code: Tracker = function (){
this.addProperty("_sprites", Tracker.prototype.getSprites, Tracker.prototype.setSprites);
}
Tracker.prototype = new Object();
Tracker.prototype.getSprites = function(){
return this._sprites;
}
Tracker.prototype.setSprites = function(newSprite){
if (!this._sprites){
//the sprites array does not exist, create it
this._sprites = new Array();
}
for (x = 0; x < this._sprites.length; x++){
exists = 0;
//assume the sprite doesn't exist
if (this._sprites[x] == newSprite){
//the sprite does exist!
exists = 1;
theSprite = x;
//mark where it is in the array
break;
//no need to search any more, leave the for loop
}
}
if (exists){
//it exists, so remove it
this._sprites.splice(theSprite,1);
}else{
//it doesn't exist, create it
this._sprites.push(newSprite);
}

};
So, how do you create an array as a property of on object?
I think I see Catbert coming

Please Help - Variable Object Property Names
I need to create variable object property names for use with the data grid component.

This works:

data = new Object();
data.some_name = "the data";

But this does not:

data = new Object();
colName = "some_name";
data[colName] = "the data";

Can anyone help me? Can object property names be variable?
Thanks.

Changing An Object Property With It's String Name?
If I have the full path name of an object like:

var1 = "parentObject.firstChild.secondChild";

and I want to change the value:

parentObject.firstChild.secondChild.price

How can I do this with access ONLY to the string variable var1?

My situation is more complicated than given above... but essentially it's the problem given above, where I only have access to the string variable.

I've tried something like:

this[var1].price

But that doesn't work.
I can get access to the variable with eval(var1 + price)... but with the rules of the use of eval changed from Flash5, I can't use this.

Any ideas?
Does anyone understand my mad problem?
Any help would be appreciated.

Thanks.


OM

Removing Property From A Predefined Object
How do you remove a user defined property from a predefined object?

For example, if I set a property of a movie clip:

myMC.myProp = myValue;

I can retrieve the value with a for..in loop.

Later I want to clear the property so that 'myProp' does not get evaluated in a for..in loop.

How do I do this?

Using JS SetVariable To Change The Value Of An Object Property
Hi, I know this JS code can change the value of a simple variable which resides on the root ("myVar")


Code:
<SCRIPT LANGUAGE=JavaScript>
<!--
function doPassVar(args){
var sendText = args.value;
window.document.myFlash.SetVariable("myVar", sendText);
}
//-->
</SCRIPT>

link: http://www.macromedia.com/cfusion/kn...fm?id=tn_15683

can this method be used to change a property of a class instance?

Assuming I have a myClassInstance which is an instance of a myClass(), the class has a property named "value".
Will putting this code in the JS change the myClassInstance.value?


Code:
window.document.myFlash.SetVariable("myClassInstance.value", sendText);

Does Textformat Object Have Alias Property?
Hi im applying the text format object to a list of dynamically created textfields...but isnt their an alias/anti alias of the text format object property that i can apply to dynamically generated text fields? Cause at present the text doesnt look very crisp!!

thanks

Passing To Object.text Property
I can't understand why the text string will not pass to the variable userAnswer.

AnswA.distractor.text = "My text string here";
userAnswer = AnswA.distractor.text;
trace(userAnswer);

I can't get the string to trace, i've tried other formats including...
trace(AnswA.distractor)//0
trace(AnswA.distractor.text)//0

thank you

iaustin

Line Object Property -> Array
I am attempting to step through a line and copy information into an array.
I tryied creating a class but got errors.


Code:
class node {
private var x:number;
private var y:number;
private var percent:number;
private var distance:number
}
all the same, even using an array to store my data did not work
Please help!!!


Code:
// create a clip to draw to
_root.createEmptyMovieClip("mc", 1);

// set our line style
mc.lineStyle(1, 0x000000);
// draw the line based on handle locations
mc.moveTo(10,10);
mc.lineTo(100,100);
mc.lineTo(50,150);
mc.lineTo(200,200);
mc.lineTo(100,250);

var myArray = new Array();
var count:Number = mc.length;
trace(count);
trace(mc(0).x);

myArray(0).x = mc(0).x
myArray(0).y = mc(0).y
myArray(0).percent = 0.2
myArray(0).distance=12

//for ( var i=0; i<myArray.length; i++) {
// trace(myArray[i]);
//};
also any help on using the debug to view my variables.
I couldn't see any of my local variables in the debug window.

Object Property Via A Class, Is There A Tutorial?
I am less than 3 weeks into both Flash and AS3. My main problem is that when I try to apply what I read or see in a video to a class I get lots of problems if I don't have the exact setup they did.

Can someone make a tutorial that shows what needs to be added to the class and timeline to target specific movieclips? For example, with the information I provide below, what would need to be added to target each level of the hierarchy:

FLA file: Geometry.fla [b]document class:[/B] none, left field blank

AS file: MoveMC.as package: lesson

1st MovieClip: (library name) mRect base class: lesson.MoveMC class: Rectangle instance names(3):mRect1, mRect2, mRect3 nesting: all are nested in a MovieClip that is on the stage with an instance name of mBorder

2nd MovieClip: (library name) mTri base class: lesson.MoveMC class: Triangle instance names(3):mTri1, mTri2, mTri3 nesting: all are nested in a MovieClip that is on the stage with an instance name of mBorder

So what I would love to know is the following:
What needs to go in the MoveMC.as (and timeline?) file in order to change the .x property of all movieclips with:
note: answer 1)-3) seperately please
1) base class of lesson.MoveMC
2) class name of Rectangle
3) instance name of mRect3

please mention any variable declaration and importing that would be needed along with the actual property assignment code

Dynamic Property Names Of AS3 Object
Ladies and Gentleman's,
Following code creates Object class instances out of Objects on stage (components in flex)...

var mNewObject:Object = { (component.id) : (component.text) };

It is beautiful. the code creates an Array of these object which are sent to the server. What a lovely story.
as such:
[componentID: value],
[componentID: value],
[componentID: value],
[componentID: value]

my question has to do with the recipient of the object, which can even be a function on the same client.
How does one access the (string value) Key of the objects when they can all differ between one run to another ?
hope this was clear. many thanks in advance, this is a great forum.
Peace and love from Israel

Offset Property (a Bug In The Sound Object)?
Hi, can anyone confirm that there is a bug in the offset property / Sound objects start([offset], [no of loops]) method!

Basically offset works as it should starting the sound at the offsets no of seconds, but fails to play all the way to the end and stops playing the sound before it should!

Any ideas, nothing on technotes at Macromedia and nothing wrong with my code, so i just need confirmation that it is a bug to save me wasting my time!

Try offsetting a long 10-15 secs + sound at 7 secs offset, start the sound and you'll see it doesn't reach the end!

Cheers

Sam

Video Object _width Property
Hi all,

I have a class which has a private property 'screen' containing a
reference to a Video object like:

private var screen:Video;

A few lines below there's a public method returning the width of the
video object:

public function getWidth():Number{
return this.screen._width;
}

Now, when I compile I get the following error:

**Error**
D:aloftFlashLibrarycurrent
laloftmediaphpflvScreenView.as: Line
35: There is no property with the name '_width'.
return this.screen._width;

However, when i run the code and call the method I get the width of the
object without any problems.

If I have the method return any of the properties without the underscore
(like: width, smoothing, deblocking etc.) I get no compile error.

What am I missing here?

Thanks in advance,
Manno

--
----------
Manno Bult
manno@xs4all.nl

Using Data From Combobox As A Property Of Object
Hello guys,

I have a combobox:

ActionScript Code:
search_cb.addItem({data:date, label:"Date"});search_cb.addItem({data:name, label:"Name"});search_cb.addItem({data:measures, label:"Measures"});var searchcbListener:Object = new Object();searchcbListener.change = function(evt_obj:Object) {    var item_obj:Object = search_cb.selectedItem;    var i:String;    for (i in item_obj) {        _root.searchin = item_obj[i].data; //this is not good    }}search_cb.addEventListener("change", searchcbListener);


Now I have some objects like (all attributes are strings):
myObj1.date = ...
myObj1.name =...
my Obj1.measures =...
myObj2.date = ... and so on.
Now I have a function, which I would like to use for searching in the properties of objects. The user should type the request into input field, choose the property from dropdown and press "go". Just that I can't pass the data from dropdown to the search function. Any ideas?
This is the search function:

ActionScript Code:
function search(string:String, where):Void{    for (var i=0; i<objectArray.length; i++){    trace("in for"+i);    if (objectArray[i].measures.indexOf(string) > -1)        trace(objectArray[i].measures+" - "+objectArray[i].name);    }}


just that now the property set is "measures", I need to change this dynamically (name, measures, date).
Thanks for advices!

Poco

PS: _root.searchin should be the variable in root holding "where to search".

Watch Object Property With AddEventListener?
Hi there!

I am looking for a simple way to watch for Object property change, something like:

Code:
myMovieClip.x.addEventListener( Event.CHANGE, onPropertyXChange );
but of course the above doesn't work. Anybody can redirect me to a Class or a way to do this?

Thanks!

How To Strong-typing Object Property?
var obj :Object = new Object();
obj.name = "James";

trace(typeof(obj.name)); // object

How to force the object type to string?
It cause me problem when my function only take String input

function whatever(name :String):Void
{
....
}

Changing An Object Property With It's String Name?
If I have the full path name of an object like:

var1 = "parentObject.firstChild.secondChild";

and I want to change the value:

parentObject.firstChild.secondChild.price

How can I do this with access ONLY to the string variable var1?

My situation is more complicated than given above... but essentially it's the problem given above, where I only have access to the string variable.

I've tried something like:

this[var1].price

But that doesn't work.
I can get access to the variable with eval(var1 + price)... but with the rules of the use of eval changed from Flash5, I can't use this.

Any ideas?
Does anyone understand my mad problem?
Any help would be appreciated.

Thanks.


OM

Dynamic Object Property Creation
hi all ----

i am struggling with creating dynamically named object properties based on an XML doc in an associative array format. ex:


subArray[j] = {title:title, file:file, location:location, active:active, visited:visited, type:type, wildCard:wildCard, ID:ID};

how do i add a set of proerties based off a loop check of an XML doc ex:

if(var exists in XMLnode i){
subArray[j] = {this["newProp_"+i]:existingXMLvar};
}

so that ---- subArray[j].newProp_i==existingXMLvar;

the format i have above does not work, any suggestions would be appreciated. thanx

Setting Property Of An Object In Another Class
Hello,

I have a little problem of understanding on how to set properties of an object that is in another class. The firstclass draws a circle and set's it's alpha to a random number.
from the secondclass i call the public function in the fristclass which sets a new random alpha. i can trace the call of the function but the alpha is still the same.
can me anyone explain what i do wrong?

Code:

package {   
   import flash.display.Sprite;
   public class FirstClass extends Sprite{      
      private var _cont:Sprite;
      
      public function FirstClass() {      
         _cont = new Sprite();
         _cont.graphics.beginFill(0xFF0000, 1);
         _cont.graphics.drawCircle(30, 30, 10);
         _cont.graphics.endFill();         
      
         addChild(_cont);         
      
      setAlpha();
   }
   
   public function setAlpha():void {      
      trace(_cont);      
      _cont.alpha = Math.random() * 1;
      
   }   
   }   
}

and the second class:

Code:

package {
   
   import flash.display.Sprite;
   import flash.events.MouseEvent;
   
   import FirstClass;
   
   public class secondClass extends Sprite{

      private var _btn:Sprite;
      private var _first:FirstClass;
      
      public function secondClass() {   
      
      _first = new FirstClass();
         
         _btn = new Sprite();
         _btn.graphics.beginFill(0x00FF00, 1);
         _btn.graphics.drawCircle(30, 80, 10);
         _btn.graphics.endFill();
         
         _btn.addEventListener(MouseEvent.CLICK, onClick);
         
         addChild(_btn);
   
   }
   
   public function onClick(e:MouseEvent):void {
      _first.setAlpha();
   }
}
}

Using String Concatenation To Get Property Object, Please Help Me
Hi, I'm an ActionScript newbie, and I would like to ask you a very simple question because this problem is making me crazy.
This is a simplified part of my script:

Dati_colori = new LoadVars();
Dati_colori.load("immagini/colori/"+_root.num_img+".txt");

The file is this:

&num=3&colore1=0xFF0000&colore2=0x00FF00&colore3=0x0000FF

The first variable is the number of colors (that are the other variables)
After the file is loades, I can access to the values by writing:

Dati_colori.colore1, Dati_colori.colore2, ecc ecc.

Now the problem: I would like to put this in a for cicle:

colors is an array containing the values

for (a=1;a<Dati_colori.num<a++){
colors[a] = Dati_colori.colore+a //this concatenation DOES NOT WORK!! I cannot access this way to the property containing the
}

Maybe it is just a formal problem but I cannot succeed in using string concatenation to get the property value.

Thanks in advance for any suggestion!

Davide (from Switzerland)

Can I Use Object Property For List Item Display Name?
I use an ArrayCollection of objects as my list's dataProvider and I want the list to display each objects 'name' property as the visual part of the list item.

My class is called Alert so the list displays [Object Alert] in each line. How can I customize what is displayed? (e.g. alert_item.name)

Returning The Class Object That A Property Belongs To
Hi all,

say I have a class with a sprite as one of its properties...


ActionScript Code:
public class PropertiesClass
{
    internal var _sprite:Sprite;
    internal var _someOtherProp:Number;

    public function PropertiesClass():void
    {
        _sprite = new Sprite();
        _someOtherProp = 42;
    }
}

in another class I instantiate this class & add the sprite property to the display list & an event listener to it...


ActionScript Code:
public class DisplayClass extends Sprite
{
    public function DisplayClass():void
    {
        var obj:PropertiesClass = new PropertiesClass()
        this.addChild(obj._sprite);
        obj._sprite.addEventListener(MouseEvent.CLICK, clickHandler);
    }
    private function clickHandler(e:MouseEvent):void
    {
        trace(e.target.parent);
        // I want to be able to get to the _someOtherProp value in the first class
    }
}

the click handler trace refers to the display list of the DisplayClass, I would like to be able to access the other properties in the PropertiesClass object that _sprite is a member of.

My solution would be to make _sprite a movieclip instead (not a sealed class) then add a dynamic property to it which gives a reference back to the original class - seems to be a bit heavy handed tho with lots of un-needed overhead.

Thanks,

PMF

For Loop Problem And Property Assignment Of Object
Related to my other thread on retrieving object names from an array, I'm running into an issue where clips that are dynamically assigned names and attached to a "container" along with a _type property are getting caught up in for... loop being used to sort through all of the clips attached to "container".


PHP Code:



function collectAndSort() {    for (var obj in container) {        if (typeof container[obj] == "movieclip") {            whichType = container[obj]._type;            whichItem(whichType);            trace(whichType);        }    }} 




the whichItem function looks like this (nothing fancy):

PHP Code:



function whichItem (whichType){    //trace("whichItem function was called");    if (whichType == "1mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Double Door Display";        unitItem.item_desc = "80 x 96 Display Frame"        unitItem.item_dimensions = "80 x 96";        unitItem.unit_price = 100;    }else if (whichType == "2mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Single Door Display";        unitItem.item_desc = "42 x 96 Display Frame"        unitItem.item_dimensions = "42 x 96";        unitItem.unit_price = 85;    }else if (whichType == "3mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Side Window Right";        unitItem.item_desc = "Side Window Panel With Right Window"        unitItem.item_dimensions = "30 x 96";        unitItem.unit_price = 150;    }else if (whichType == "4mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Beam";        unitItem.item_desc = "Vertical Connector Beam"        unitItem.item_dimensions = "12 x 96";        unitItem.unit_price = 75;    }else if (whichType == "5mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Side Window Left";        unitItem.item_desc = "Side Window Panel With Left Window"        unitItem.item_dimensions = "30 x 96";        unitItem.unit_price = 150;    }else if (whichType == "6mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Shelf";        unitItem.item_desc = "Brochure Display Shelf"        unitItem.item_dimensions = "24 x 48";        unitItem.unit_price = 100;    }else if (whichType == "7mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Poster Panel lg";        unitItem.item_desc = "Large Top Mounted Poster Panel"        unitItem.item_dimensions = "80 x 24";        unitItem.unit_price = 40;    }else if (whichType == "8mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Poster Panel sm";        unitItem.item_desc = "Small Top Mounted Poster Panel"        unitItem.item_dimensions = "0 x 24";        unitItem.unit_price = 40;    }    _root.purchaseArray.push(unitItem);} 




And just for reference, here's how those pesky clips got there (again, posted in a previous thread):

PHP Code:



for (k=1; k<9; k++) {    this["btn"+k].kvar = k;    this["btn"+k].onPress = function() {        getclips(this.kvar);        trash.enabled = true;        btn_trash_all.enabled = true;    };}/******************************************************************************   Clip handling: attaching, dragging and also tracking (via "reportMe")    ******************************************************************************/   function getclips(l) {    clip = container.attachMovie(l+"mc", "mc"+i, i);    clip._type = l+"mc";// "_type" property used for clip type comparisons    reportMe = clip;    myType = reportMe._type;    //trace(reportMe._type);    addSubtotal(myType);    clip.k = l;    clip._x = 180;    clip._y = 180;    clip.onPress = doDrag;    clip.onRelease = clip.onReleaseOutside=noDrag;    cliparray.push(clip);    clip.ivar = i;    i++;} 




Now when I run it and attach a few clips, I get their proper _type, but whichType is assigned the same thing for each(?). Here's what I get in a trace after dragging out 3 clips and calling the collectAndSort function:

Code:
6mc
4mc
2mc
Single Door Display
Single Door Display
Single Door Display
clip 6mc, 4mc, and 2mc are correct but the matching for a text output via whichItem isn't and it's called in that for... loop. They shouldn't each be matched to "Single Door Display".
I'm thinking this needs to be approached differently but I don't have the option of writing out (php or whatever) and then reading back in to to split etc. (was reading the "best of" archives as saw a great one on this).

So, here's my tangled mess. I know that it is at least getting that far which is encouraging, just that the final sorting through to populate a text field as a purchase list gives me a match for the first clip attached (ie "Single Door Display").

Later edit....sorry forgot to mention that "Single Door Display" string comes from the unitItem.item_name property matched in the whichItem function (also shown above).

Can anybody help out a guy in over his head?

Does Text Format Object Have Alias Property?
Hi im applying the text format object to a list of dynamically created textfields...but isnt their an alias/anti alias of the text format object property that i can apply to dynamically generated text fields? Cause at present the text doesnt look very crisp!!

thanks

For Loop Problem And Property Assignment Of Object
Related to my other thread on retrieving object names from an array, I'm running into an issue where clips that are dynamically assigned names and attached to a "container" along with a _type property are getting caught up in for... loop being used to sort through all of the clips attached to "container".


PHP Code:



function collectAndSort() {    for (var obj in container) {        if (typeof container[obj] == "movieclip") {            whichType = container[obj]._type;            whichItem(whichType);            trace(whichType);        }    }} 




the whichItem function looks like this (nothing fancy):

PHP Code:



function whichItem (whichType){    //trace("whichItem function was called");    if (whichType == "1mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Double Door Display";        unitItem.item_desc = "80 x 96 Display Frame"        unitItem.item_dimensions = "80 x 96";        unitItem.unit_price = 100;    }else if (whichType == "2mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Single Door Display";        unitItem.item_desc = "42 x 96 Display Frame"        unitItem.item_dimensions = "42 x 96";        unitItem.unit_price = 85;    }else if (whichType == "3mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Side Window Right";        unitItem.item_desc = "Side Window Panel With Right Window"        unitItem.item_dimensions = "30 x 96";        unitItem.unit_price = 150;    }else if (whichType == "4mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Beam";        unitItem.item_desc = "Vertical Connector Beam"        unitItem.item_dimensions = "12 x 96";        unitItem.unit_price = 75;    }else if (whichType == "5mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Side Window Left";        unitItem.item_desc = "Side Window Panel With Left Window"        unitItem.item_dimensions = "30 x 96";        unitItem.unit_price = 150;    }else if (whichType == "6mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Shelf";        unitItem.item_desc = "Brochure Display Shelf"        unitItem.item_dimensions = "24 x 48";        unitItem.unit_price = 100;    }else if (whichType == "7mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Poster Panel lg";        unitItem.item_desc = "Large Top Mounted Poster Panel"        unitItem.item_dimensions = "80 x 24";        unitItem.unit_price = 40;    }else if (whichType == "8mc"){        unitItem.item_id = whichType;        unitItem.item_name = "Poster Panel sm";        unitItem.item_desc = "Small Top Mounted Poster Panel"        unitItem.item_dimensions = "0 x 24";        unitItem.unit_price = 40;    }    _root.purchaseArray.push(unitItem);} 




And just for reference, here's how those pesky clips got there (again, posted in a previous thread):

PHP Code:



for (k=1; k<9; k++) {    this["btn"+k].kvar = k;    this["btn"+k].onPress = function() {        getclips(this.kvar);        trash.enabled = true;        btn_trash_all.enabled = true;    };}/******************************************************************************   Clip handling: attaching, dragging and also tracking (via "reportMe")    ******************************************************************************/   function getclips(l) {    clip = container.attachMovie(l+"mc", "mc"+i, i);    clip._type = l+"mc";// "_type" property used for clip type comparisons    reportMe = clip;    myType = reportMe._type;    //trace(reportMe._type);    addSubtotal(myType);    clip.k = l;    clip._x = 180;    clip._y = 180;    clip.onPress = doDrag;    clip.onRelease = clip.onReleaseOutside=noDrag;    cliparray.push(clip);    clip.ivar = i;    i++;} 




Now when I run it and attach a few clips, I get their proper _type, but whichType is assigned the same thing for each(?). Here's what I get in a trace after dragging out 3 clips and calling the collectAndSort function:

Code:
6mc
4mc
2mc
Single Door Display
Single Door Display
Single Door Display
clip 6mc, 4mc, and 2mc are correct but the matching for a text output via whichItem isn't and it's called in that for... loop. They shouldn't each be matched to "Single Door Display".
I'm thinking this needs to be approached differently but I don't have the option of writing out (php or whatever) and then reading back in to to split etc. (was reading the "best of" archives as saw a great one on this).

So, here's my tangled mess. I know that it is at least getting that far which is encouraging, just that the final sorting through to populate a text field as a purchase list gives me a match for the first clip attached (ie "Single Door Display").

Later edit....sorry forgot to mention that "Single Door Display" string comes from the unitItem.item_name property matched in the whichItem function (also shown above).

Can anybody help out a guy in over his head?

Does Text Format Object Have Alias Property?
Hi im applying the text format object to a list of dynamically created textfields...but isnt their an alias/anti alias of the text format object property that i can apply to dynamically generated text fields? Cause at present the text doesnt look very crisp!!

thanks

Setting A Property For A Specific Type Of Object
I have about 40 textinput components on stage and I want them all to have their enabled property set to false when my message box movie clip becomes visible.

Insted of typing 40 lines of the same code setting each instance of the textinput component to .enabled = false, could I just loop round each textinput component and set it to .enabled = false?

How would I do this?

I know in VB I can use a FOR EACH satement but how would I do it in flash?

persudo code>

if(msgbox._visible = true){
FOREACH (instance OF textinput) {
.enabled = false
}
}

Assigning A Variable Value To A Dynamically Created Object Property
OK... here's a code snippet. I'm trying to take the value from a variable being loaded from a text file which could be named utFormat1_font, or utFormat2_font, utFormat3_font, etc...

untfFont = ("utFormat"+i+"_font");
eval ("utFormat"+i+".font") = untfFont;

I think the problem here is the part that states:
eval ("utFormat"+i+".font")

How can I dynamically assign the value of untfFont to utFormat1.font, or utFormat2.font, etc...

The reason I'm doing this this way is because I have no idea how many iterations this loop will have to execute at this time. It needs to be able to dynamically expand to accomedate 30, 300 or 1 utFormat??.font values.

CAN ANYONE HELP??????

Cannot Access A Property Or Method Of A Null Object Reference.
The problem:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at badijalaShooter_fla::MainTimeline/badijalaShooter_fla::frame1()

here is the project
the code is in the first frame at as layer:


Code:
http://rapidshare.com/files/80311497/badijalaShooter.fla.html

Name Property Of Loader Object Lost In CLICK Event.
PHP Code:



private function loadIcons():void{
            count = 0;
            iconArray = new Array();
            for(var i:uint = 0; i < menuArray.length; i++){
                loader = new Loader();
                loader.contentLoaderInfo.addEventListener(Event.INIT, placeIcons);
                loader.load(new URLRequest("assets/icons/" + menuArray[i] + "_icon.swf"));
            }
        }
        
        private function placeIcons(event:Event):void{
            iconArray[count] = (loader.content as MovieClip);
            var loadedContent:MovieClip = (loader.content as MovieClip);
            //loadedContent.play(); needed for later to play ani.
            iconArray[count] = loadedContent;
            iconArray[count].addEventListener(MouseEvent.MOUSE_DOWN, menuSelected);
            addChild(iconArray[count]);
            count++;
        }
        
        private function menuSelected(event:Event):void{
            //addChild(loader);
            trace(event.target.name);  //PROBLEM GETTING THE INSTANCE NAME OF THE BUTTON PRESSED!!!! Look into
        }




Well, hard title.. sorry.

the object is to load a couple of swf's which serves as icons in a menu. I place these in an array so I can reference them later, then when clicked I need to know the id, name or anything about that swf to load the appropriate page which goes with the icon swf.

The problem is that even after I make the coercion to MovieClip on the "loadedContent" I am not allowed to set the "loadedContent.name = "instance name"" and no matter what I try all I get in the menuSelected function is "instance27" or what ever the player calls it at runtime..

I am quite sure I did this a thousand times, but now it does not work?

Thanks for any help given

Cannot Access A Property Or Method Of A Null Object Reference
I am getting this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main$iinit()
I used the same code on another fla and it worked so it's the fla. I just don't know what it means.

The only difference I have on the non working fla is that the button is on frame 50 and the working fla is just 1 frame long.


Thanks a bunch!

Copyright © 2005-08 www.BigResource.com, All rights reserved