Forums → Programming Forum → (As3) Can't change name of a timeline placed object?
- 3 Replies
I am getting this weird error, in as2 I could change the name of timeline objects all i wanted thru code... No problemo!
But in as3 its not letting me do this...
(I'm getting this error: "Cannot change name of timeline placed objects"
I'm trying to add objects to an array but I need each object to need a separate name, but As3 isn't letting me change the name...
this.name = ("tile" + MovieClip(root).tiles.length);
Is there a work around for this?
timeline placed objects are named with instance names, that is being declared as it is loaded. So it will not allow you to change the name (it is basically written in stone).
The best practice is to addChild then give the name as you added the MovieClip
How can you do this with timeline placed objects???
pretty easy... you take the frame that the level is on convert to MovieClip (yes the whole level) then clear the frame. Now I like to think of this as a mini-map. Then you can use code to add the children by using the for loop. Once the loop is done, the whole level will be setup and you can then run the enter frame loop to take control of the objects.
Would you like me to make a demo of what I am talking about?
No thanks, I think I get what you're talking about.
You're saying use a bunch of empty movie clips to show where i'm going to place the things with addChild() and then I could do? :
coin.x = coinHolder.x;
coin.y = coinHolder.y;
The thing that confuses me here is that in As2 they let you change names on runtime of timeline placed objects, but in As3 adobe decided to remove that? That seems to only be limiting control over what people can make...
Thanks for your help!
what I like to do is this, and remember copy past wont work due to the less than symbol
var l1:level1class = new level1class;
map = l1;
var l2:level2class = new level2class;
map = l2;
for (var i:int=0; i < map.numChildren; i++)
var object = map.getChildAt(i);
if (object is enemy1MC)
var e1:enemy1 = new enemy1();
e1.x = object.x;
e1.y = object.y;
e1.name = "e1";
You must be logged in to post a reply!
We strive to deliver the best gaming experiences... on the internet and on your mobile phone. Play thousands of free online games for kids, get access to free mmorpg games, online rpg games, fun online flash games, and more.
We offer free flash games in many different genres: online shooting games, online puzzle games, online war games, free online car games, free online hidden object games and dozens more.
This is the best place on the web to play online games for free... play on Armor Games! No matter what game style you prefer, we've got it here.
Gaming websites, passionate bloggers, and quirky streamers are welcome to share or review our games. If you need game keys, art, trailers, screenshots or more check out our press kit website.
Game developer? Visit developers.armorgames.com to request AG developer status, find documentation on our APIs, and get access to our development environment. Let's make sweet, sweet games together.
Looking for a publishing partner that can help your app rocket to success? Contact the mobile team to learn more about how we can help!