AS help
- Started
- Last post
- 6 Responses
- fues
So I've written a function that creates a new Movie Clip very time you press a button.
Here's the code:
//function
function transition(d, c) {
createEmptyMovieClip("newtarget... c);
newClip = "newtarget"+[d];
};//button actions
nextButton.onRelease = function() {
d++;
c++;
transition(d, c);
};Now I want an onEnterFrame event for every new clip that's created, so I've tried this:
newClip.onEnterFrame = function() {
trace("ok");
}This won't work however. I suppose there's something wrong with the identifiers of the new clips that are created but I can't figure it out..
Can anyone please help?
Thanks so much.
- JazX0
I don't want to say it, but clap your feet three times and say 'unfittoprint' and he will magically appear and give you the solution. ;)
- unfittoprint0
//function
function transition(d, c) {
createEmptyMovieClip("new target"+d, c);
newClip = this["new target"+d];
newClip.onEnterFrame = function() {
trace("ok");
};
}
//button actions
nextButton.onRelease = function() {
d++;
c++;
transition(d, c);
};
stop();
- fues0
I know JazX..
Unfit? Engage?
- fues0
Thanks Unfit but it still won't work. I am dynamically (xml) loading jpg's into the newClips.. maybe that's the problem...
- elkew0
There is no reason why unfit's script won't work.
The only things i can think of are createEmptyMovieClip requires you to define where: ie this.createEmptyMoveiClip or _root.createEmptyMovieClip or _root.myMc.createEmptyMovieClip et al...
To be sure your button is working, put a trace action in there too
ie:
nextButton.onRelease = function() {
d++;
c++;
transition(d, c);
trace("attempting to create transition");
};
- fues0
Thanks Elkew but, apart from the onEnterFrame function, everything works..
Flash creates the new clips and loads a jpg into them but it won't execute the onEnterFrame event.
I've also tried creating the EmptyClip at the _root, same problem..