Object access

  • Galvitron
  • Newbie
  • Newbie
  • Galvitron
  • Posts: 5

Post 3+ Months Ago

ok i think this is how this works



Code: [ Select ]

_global.Selected = "";

Car = function(){
this.NumberOfDoors = 0;
}

Mustang = new Car();
StationWagon = new Car();

Mustang.NumberOfDoors = 2;
StationWagon .NumberOfDoors = 4;

//no probs so far!!

Selected = "Mustang";

trace(this[Selected].NumberOfDoors);

Selected = "StationWagon";

trace(this[Selected].NumberOfDoors);

this[Selected].NumberOfDoors = 3;

trace(this[Selected].NumberOfDoors);

//DOH!
  1. _global.Selected = "";
  2. Car = function(){
  3. this.NumberOfDoors = 0;
  4. }
  5. Mustang = new Car();
  6. StationWagon = new Car();
  7. Mustang.NumberOfDoors = 2;
  8. StationWagon .NumberOfDoors = 4;
  9. //no probs so far!!
  10. Selected = "Mustang";
  11. trace(this[Selected].NumberOfDoors);
  12. Selected = "StationWagon";
  13. trace(this[Selected].NumberOfDoors);
  14. this[Selected].NumberOfDoors = 3;
  15. trace(this[Selected].NumberOfDoors);
  16. //DOH!


ok this seems to work but when i try it between different moviclips it doesn't

as well when objects are defined is that definition global to any movieclip
like can i create an instance of that object in any movieclip and can i make that instance global to all parent movieclips(some of this i suspect is related to my problems above)

thanks for any help on this
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • stinger
  • Graduate
  • Graduate
  • stinger
  • Posts: 157
  • Loc: San Jose, CA

Post 3+ Months Ago

this may seem trivial, but. . . .

your code:
Quote:
Mustang.NumberOfDoors = 2;
StationWagon .NumberOfDoors = 4;


should be changed to:

Quote:
Mustang.NumberOfDoors = 2;
StationWagon.NumberOfDoors = 4;


There was a space between the StationWagon.NumberOfDoors
Thus I believe your coding should work now.

Quick fix? I hope this was it!

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.