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




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!



KirupaForum > Flash > ActionScript 3.0
Posted on: 10-20-2008, 08:37 AM


View Complete Forum Thread with Replies

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

Access Of Undefined Property. Work.addEventListener
Hello Guys,

I am hoping someone can help me, as i have been trying to get this to work for the last four hours.

I am trying to create button that links to URL address with AS3.0 This is the code I am using:


Code:
work.addEventListener(MouseEvent.CLICK, callLink);
function callLink():void {
var url:String = "http://www.hologramdesigns.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_self');
} catch (e:Error) {
trace("Error occurred!");
}
}


However, I am retrieving this error on running.

1120: Access of undefined property work. work.addEventListener(MouseEvent.CLICK, callLink);

I have attached the .fla file if anyone can assist me with where I am going wrong it would be much appreciated.

Access Of Undefined Property. Work.addEventListener
Hello Guys,

I am new to Action Scripting 3.0 - and I am having difficulty getting a button to open a URL.

I have created an invisible button called work (hoping that it would) and this is the action scripting I have created.


ActionScript Code:
work.addEventListener(MouseEvent.CLICK, callLink);
function callLink():void {
  var url:String = "http://www.hologramdesigns.com";
  var request:URLRequest = new URLRequest(url);
  try {
    navigateToURL(request, '_self');
  } catch (e:Error) {
    trace("Error occurred!");
  }
}

When I run/publish this script flash reports back this error. 1120: Access of undefined property work. work.addEventListener(MouseEvent.CLICK, callLink);

I hope someone can help.

Object.watch()
Hi,

I want to register any Changes made to a property of an self defined Object using the watch() method. If I define all properties in the constructor of the object it works fine. But I also want to watch properties which I define later - not in the constructor.

Can anyone help me?

Watch Object
Hello!

I'd like several movieClips (created on the go) to react (change their appearance i.e.) when a variable located on _root is changed; I did something like that,which I placed on my mc's:


Code:
_root.watch('myVar', fReactToMyVar);
function fReactToMyVar() {
trace("myVar changed!");
}
and it works fine, except that if this code is the same for many movieClips, it'll work for only one of them (because the _root.watch object is overwritten I guess), so how do I do to have multiple "watch" objects to react to the same variable? It seems this is a syntax problem but I couldn't find the answer...
Thanks for your help

Object.watch
Hi there

I am altering a flash variable via javascript.
Once altred I want to do something in flash.
The variable is called 'varq' and there is an instance on the stage called 'cat'.

I'm using trace to check the routine but it doesn't work.
This is the code I have in the frame.

var itemIDWatcher:Function = function(prop, oldVal, newVal){

trace("watchit");
return newVal;
}

cat.watch("varq", itemIDWatcher);

Could someone help pls.

Object.watch Problems
I can't get this object.watch stuff to work. I have a dynamic text box on the main timeline. I have given it an instance name of "callMenuText" and it's variable name is menuCall. This is my code, which is on the first (and only) frame of the main timeline...

function test() {
tester = tester+1;
}
menuCallText.watch('menucall', test);


I even added this line to see if the watchpoint was created successfully and it's returning a value of true...

testTrue= menuCallText.watch('menucall', test);

When I pass the variable from the web page with javascript the variable value of menucall is changing ok but my variable, "tester" ( which I'm only using temporarily to see if I can get a function to execute ) is not changing.

Can anybody help?

Setting Up A Watch() Object?
I currently have code like this: check_decimal is my function I've written.

_root.field1.onChanged = check_decimal;

I want to change this code so that the when field1 updates it runs my function. Not just when the user types in it but when the variable changes.

I think I need to set up a watch() object but I don't know the code.

Can anyone help me with this.

Thanks
Jason

Object.watch Oddities
Here's the deal.
I'm writing a class to allow me to watch one property of an object more than once. The problem is that when I'm inside that class and I set the variable that I'm watching (after I unwatch it) it gets set, however, when I trace it in the function I call after I set it (to do just that, trace) it returns undefined.

There's more weirdness though. I have an on mouse up handler set to change the variable that I'm watching to test things out, when I trace the variable from the on mouse up (100% positive the path is correct), before and after the var is set, it traces out just fine and dandy.

Replacement For Object Watch
To be honest, i dont remember if the name was object watch, property watch...it was something like that in AS2 that could watch if some property of a movieClip has changed and do something about it
The first thing i was looking at was the proxy class, however it seems that it cant be used with movieClips so there is any way to do this, without have to check it every frame?
Tnakz

Object.watch Or Am I Off Track?
I am fairly new to flash and have a unique problem I hope someone can help me with. For a project, I have about 1600 legacy SWF files, some with buttons, that that need to be fit within kiosk navigation. Some are just simple displays of a JPG but some contain questions with response required on the screen. The first kind are easy enough, it's the ones with buttons that pose a problem.

The slide SWF's were originally loaded into a navigation SWF using loadMovie. The nav SWF has buttons, FFbutton and RRbutton, that the button in the slide SWF sets states for after user response:

 tellTarget("../../FFbutton")
  {
   ButtonAction = "nextframe";
  }

I am trying to build a replacement for the nav SWF that traps the button presses on the slide. The slides are fully licensed, but FLA's are not available. With my limited knowledge, I have tried setting up a button, FFbutton, and then added the script into frame 1:

 ButtonForward = function(prop, oldVal, newVal){
  // do something
  }
 FFbutton.ButtonAction = "nextframe";
 FFbutton.watch("ButtonAction",ButtonForward);

I have also tried just creating FFbutton as an object but nothing seems to work. It doesn't seem like there is any communication going on between the movies. The slide SWF also looks for a variable in the nav SWF using:

if (thispage == ../:currentpage) {

Although I set currentpage in my nav movie I am not convinced this is working within the slide either.

Any tips?

Listeners V.s. Object.Watch.... How To?
Hello,

With help from this Forum I got my movie with listeners running just fine.. :
Please help...listeners...AARRGHH!

But now that I'm compiling my project which involves loading serveral movies (6 in total) in can see my CPU eating away 36% just by siting there.

I've read posts before on the CPU usage and listeners and Flashers using the Object.Watch Method. I'm basically looking for any method that will take off CPU cycles...

my Q;

If I want to use the Object.Watch method instead of listeners, what should my code look like?
Right now I'm using this code for "listening" which is inside my movieclips :

MC CODE : -----------------------------------------------------

styleobjectcolor1 = new Object();
_global.styleobject.addListener(styleobjectcolor1);
styleobjectcolor1.onUpdateStyle = function(message) {
trace(message);
// getting color value from style movie
temp_color2 = _root.stylemc.GUIcolormain.split("#")[1];
myColor2 = new Color(colormc);
myColor2.setRGB("0x"+temp_color2);

};

END CODE : ----------------------------------------------------


And on my main timeline I use this to setup a broadcaster :


_root.CODE : --------------------------------------------------


_global.styleobject = new Object();
ASBroadcaster.initialize (_global.styleobject);


END CODE : ---------------------------------------------------


Suggestions are very welcome...
grt
Lars

Help With Object.watch() Method
Hi!
I have a movieClip used as a scroller asociated to a class that contains this method:

SimpleScrollBtn.prototype.onMouseMove=function(){
this._parent.link.scroll=(this._y*this._parent.link.maxscroll)/this._parent.maxY+1;
}

so when you press the scroll button, the scroller movie adds a listener to the Mouse and the text scrolls(that piece of code hasn´t been posted), when you release the scroll bar the listener should be removed.

That´s not any problem, the problem is that I would like to use the Object.watch() method to call the function that sets the scroll (now inside of onMouseMove) instead of having to add a listener and remove it all the times.
So I would like to invoke the function every time the _y property of the scroller changes using the watch method.

Can anyone write the script to make that, I mean to make that the scrollerMC has a watch method that linked to it´s _y prop and that invokes a function suppouse called “SimpleScrollBtn.prototype.setTextFieldScroll”?

So the function to invoke would be:

ActionScript Code:
SimpleScrollBtn.prototype.setTextFieldScroll=function(){
this._parent.link.scroll=(this._y*this._parent.link.maxscroll)/this._parent.maxY+1;
}


thanks in advance,
Polaco.

Object.watch() Attn: Dunc
Hi

Dunc gave me this piece of code which enabled me to make a variable call back the movie whenever its value was changed. AND IT WORKED GREAT!!!!! it served my purpose very well.

PHP Code:



function checkVar(id,oldVal,newVal){
    trace(oldVal);
    trace(newVal);    
    trace(id);
}

myVar="content";
mc.onRelease=function(){
    myVar = "content1";
}
this.watch("myVar", checkVar);




AND this gave me another idea: this piece of code in conjunction with an array.push method cud be used to setup a history bar like the one in the petmarket appliation. the problem i have run into is this:

supposing i was to setup a series of buttons which kept on changing the value of the variable (myvar in the above code) it returns the oldval only the first time after that it returns its value as undefined!!! WHY???

Object.watch Checking Value Change
Hi there

I am altering a flash variable via javascript.
Once altred I want to do something in flash.
The variable is called 'varq' and there is an instance on the stage called 'cat'.

I'm using trace to check the routine but it doesn't work.
This is the code I have in the frame.

var itemIDWatcher:Function = function(prop, oldVal, newVal){

trace("watchit");
return newVal;
}

cat.watch("varq", itemIDWatcher);

Could someone help pls.

Object.watch() Or SetInterval, Whats Better? (4 Preloader)
Hi guys,

Just updating a few things on my preloader. At the momment it works off setInterval, but since I have been investigating and using Object.watch() is was wondering whether it would be "more effecient" to replace the setInterval methods with watch() callback functions.... I figure that way, instead of setInterval calling my "checkLoading" function every second, maybe I could use watch() to 'watch' the getBytesLoaded property of the thing im loading and call checkLoading function that way (to update progress bar).
HMmmmmmmm......
What do you think?

Watch Object Properties And Get Calling Function?
I want to watch a property of an object to see when it changes, like so:


ActionScript Code:
var myObject:Object = new Object();myObject.xDirection = -1;function objectWatcher(prop, oldVal, newVal) {    trace ("xDirection is being changed from " + oldVal + " to " + newVal);    return newVal;}myObject.watch("xDirection", objectWatcher);myObject.xDirection = 22;


This works as expected.

But if the value of the property being watched, is changed within a function, is there a way to tell which function that was?

EG:


ActionScript Code:
var myObject:Object = new Object();myObject.xDirection = -1;function objectWatcher(prop, oldVal, newVal) {    trace ("xDirection is being changed from " + oldVal + " to " + newVal);    //I want to be able to output something like this:    trace("It was changed by " + NAME_OF_CALLING_FUNCTION);    return newVal;}function changeTheValue():Void {    myObject.xDirection = 22; }myObject.watch("xDirection", objectWatcher);changeTheValue();


Any help would be appreciated. Thanks.

[How To] Get Object Name In AddEventListener?
Hi all, I would like to ask ...
1.) How can I let the onClickHandler knows, which button has been clicked...
2.) Is it possible to make it to a CLASS or what ??
thanks ~~ ^_^


Code:
button1.addEventListener(MouseEvent.CLICK, onClickHandler);
button2.addEventListener(MouseEvent.CLICK, onClickHandler);
function onClickHandler(e:MouseEvent):void {
/************************************
var url:String;
if (button1.CLICK) {
url = "page1.htm";
} else if (button2.CLICK) {
url = "page2.htm";
}

*************************************/
var vReq:URLRequest = new URLRequest(url);
navigateToURL(vReq);
}

Drag Object Trouble With Stage.addEventListener
I'm having some trouble with ActionScript 3 in Flash creating drag actions on MovieClip Objects. The Actions are working and from an end user perspective everything seems to work fine. Still Flash is popping an error message and things really freak out when the swf is used in a flex layout (The layout moves around in weird ways).

here is the code and error with my labels in all-caps.

THIS SECTION (in the player creation loop) SETS THE EVENTLISTENER


ActionScript Code:
player.addEventListener(MouseEvent.MOUSE_DOWN, startMove);


THIS SECTION DEFINES THE EVENTLISTENERS


ActionScript Code:
function startMove(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, thingMove);
}
 
function thingMove(e:MouseEvent):void {
e.target.x = board.mouseX;
e.target.y = board.mouseY;
board.Players[e.target.ID][1]=e.target.x;
board.Players[e.target.ID][2]=e.target.y;
e.updateAfterEvent();
}
 
function stopMove(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thingMove);
}

stage.addEventListener(MouseEvent.MOUSE_UP, stopMove);

THE PROBLEM IS THIS IS AFFECTING THE STAGE
HERE IS THE ERROR MESSAGE:

Error: Error #2071: The Stage class does not implement this property or method.
at Error$/throwError()
at flash.display::Stage/set x()
at tabletest2_fla::MainTimeline/thingMove()

--------------------------------------------------------

I think it might be that the loop sometimes has the Stage as the target..? What is confusing is that the objects still drag without problems. Help would be appreciated.

Is It Possible To Watch Array Using ChangeWatcher.watch(...) Method?
Hi
Is it possible to watch Array using ChangeWatcher.watch(...) method.
More specifically lets say we have class Host and variable myArray , I want to be notified when element is added or removed from myArray.

I've tried the following:

ChangeWatcher.watch(host, "myArray", onMyArrayChanged);
Also and this
ChangeWatcher.watch(host, "myArray.length", onMyArrayChanged);

but function onMyArrayChanged is never called when I push() or pop() elements from myArray, the funnction is only called when I assign new Array like this

var tempArray = new Array()
host.myArray = tempArray

Is there are better solution?

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

Accessing A Property Of An Object Within An Object
I have modified a simple button object, which I called the OP Button in the library, and it contains two dynamic text fields. I had to add these text fields because I encountered a problem. Having the text above the button caused the button not to activate when the user went over the dynamic text field. Tried to have the text below the button, but the blue highlight with the button made the text fuzzy. I need to have the text dynamic because I need it to hold different values.

I have created the new button. In the library of Flash it is registered as OP Button ( a name I gave the button type ). I can edit the button and see the dynamic text object, which I gave the name of NormalText. I need to know how to change the .text property of the dynamic text located in the modified simple button.

The instance of the newly created button is OP4Button and the name of the dynamic text field within this button is called NormalText. How do I change the .text property from the main stage action script?

The button was created in design mode and not through action scripts. Even though I created in design mode, I need to access it through Action Script. Any help will be greatly appreciated.

Thank you





























Edited: 06/16/2007 at 10:49:18 AM by David Cowdery

Variable.addEventListener OR DynamicVariable.addEventListener
This is my first post on these forums though I've appreciated tons and tons of help from others that have posted their questions (and answers). I'm trying to dynamically create a menu based on the number of entries in an xml file. I need to create a button for each entry which then triggers a function through an eventListener. So I need to either dynamically name my movieClips I'm creating (for my buttons) OR find a way to take "tempName = mc.name" and then use that in tempName.addEventListener.

The relavent code is below! Thanks for the help!


Code:
function drawImage(i) {
for (var item:int = 0; item < i; item++) {
objectType = myXML.slide[item].objectType;

if (objectType == "image") {
dataPath = myXML.slide[item].src;

var mc:MovieClip = new MovieClip();
imageMaster.addChild(mc);
mc.graphics.beginFill(0x00000);
mc.graphics.drawRect(wide*100 - 100, high*50, 40, 40);
mc.graphics.endFill();
mc.name = "mc"+item;

mc.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent){switchSlide(dataPath)});

}
}
}
The code does create all the buttons but when I click on any of the buttons the action performed is the action intended for the last button.

Thanks again!

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

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