-
Custom Object with dot Format
This is kind of a stupid question...
How can I create a custom object with properties grouped together using dot format? Sort of like the TextFormat Object....
I tried this, but it doesn't quite work
var myObject:Object = new Object();
myObject.groupOne.prop1 = "prop1";
myObject.groupOne.prop2 = "prop2";
myObject.groupTwo.prop1 = "prop1a";
myObject.groupTwo.prop2 = "prop2a";
myObject.groupThree.prop1 = "prop1b";
myObject.groupThree.prop2 = "prop2b";
myObject.groupThree.prop3 = "prop3b";
-
FK's Giant
This works:
code: if (myObj == undefined) {
myObj = new Object();
}
myObj.prop1 = "prop1";
myObj.prop2 = "prop2";
trace(myObj.prop1);
trace(myObj.prop2);
You can add more properties to it as necessary. The first bit of code is required, I dunno why, just is. It basically asks Flash if there is something somewhere named "myObj". Since there is not (undefined), make it.
The next bit is assigning properties and values to those properties.
Hope this helps.
The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...
-
Deathbringer
Your problem is that your code doesn't define what groupOne, groupTwo or groupThree are. this will make your code work:
Code:
var myObject:Object = new Object();
var myObject.groupOne:Object = new Object();
myObject.groupOne.prop1 = "prop1";
myObject.groupOne.prop2 = "prop2";
var myObject.groupTwo:Object = new Object();
myObject.groupTwo.prop1 = "prop1a";
myObject.groupTwo.prop2 = "prop2a";
var myObject.groupThree:Object = new Object();
myObject.groupThree.prop1 = "prop1b";
myObject.groupThree.prop2 = "prop2b";
myObject.groupThree.prop3 = "prop3b";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|