Targeting dynamic mc question
- Started
- Last post
- 11 Responses
- djthemoose
Hi.
I have some dynamic mc's generated on root which i've traced and return:
_level0.menu
_level0.menu.1
_level0.menu.2etc..
However, when I try to apply the following syntax
_level0.menu.2.gotoAndStop(10);
from either a button or a function, i receive the following syntax error.
**Error** Symbol=item, layer=actions, frame=10:Line 3: Syntax error.
_level0.menu.2.gotoAndStop(10);Total ActionScript Errors: 1 Reported Errors: 1
Why can i not target a mc that is clearly there? Any help would be appreciated. This is for F7.
Thanks.
- unclesize0
if it is on the root and you've instantiated it when you call it dynamically, you should be able to call it like:
_root.menu.gotoAndPlay(10);
- djthemoose0
I would like the ability to control each instance, ie:
_root.menu.2.gotoAndStop(10);
_root.menu.3.gotoAndStop(11);But I receive the aforementioned syntax error.
- acescence0
methinks naming a clip with just a number is not wise
- unclesize0
"I would like the ability to control each instance, ie:
_root.menu.2.gotoAnd Stop(10);
_root.menu.3.gotoAnd Stop(11);But I receive the aforementioned syntax error."
first: be sure that you aren't typing this in the actions panel as you are in this thread:
_root.menu.2.gotoAnd Stop(10);
should be:
_root.menu2.gotoAndStop(10);second: what method are you calling the MC's dynamically by?
createEmptyMovieClip()?
attachMovie()?
- unclesize0
^ damnit! that messed up when I pasted it. What I meant was:
_root.menu2.gotoAndStop(10);
- djthemoose0
unclesize,
yeah, it adds a space in this thread.
I've tried _root.menu2 and it doesnt produce the syntax error, but it also doesn't control the mc, which from the trace is at _root.menu.2
;)
Also, they are being called by attachMovie
- acescence0
i think the prob is you are naming your clip with a number
- djthemoose0
acescence,
To build these menu buttons I iterate through an array, and creates a new mc for each item, naming them sequentially. I don't understand, does using a numeric naming conventions disable my ability to target an object? If so, how would you go about this?thx.
- StratusGD0
Using #s as instance names or labels (or the first character of one, AFAIK) seems to mess up Flash. Name them menu1, menu2, etc.
i.e. attachMove("menu", "menu"+n, level);Then, to access us something like:
this["menu"+n]._x = 15;
- unclesize0
Also keep in mind that if you are iterating through an array, that the first number would be 0 not 1.
- lebowski0
the point of arrays is to iterate