
Welcome Guest
|
#1
|
||||
|
||||
|
dynamically attach duplicated MC to dynamically created Parent
Objective: To create a program that will take as inputs, a base MC and a template MC which contains the base movie clip arranged in a pattern, and to duplicate that pattern on N levels as to create a fractal.
Problems: attachMovieClip() only works with movies that are already in the Library. Any dynamically created MCs generated by using createEmptyMovieClip() cannot be attached to any other movies. Possible Fixes: I have used duplicateMovieClip() to duplicate the first level fractal, but have yet figured out how to define the parent of those duplicated MCs so that I can then duplicate that parent, creating the second and subsequent levels of the fractal. Possible Code Refactoring: Use a For... In loop instead of the For loop. For(movieclip in _parentMC){...}, but looking at the help files and duplicating the help files code has not worked... I have the following code that creates the first pattern: Code:
//Variables listed in order of appearance
var fractalNum=0;
var movieCnt = 10;
var originalX=[28,28,28,14,42,42,14,56,0,56,00];
var originalY=[28,42,14,56,00,56,00,56,0,42,14];
var currentCanvasSize = 1078;
var maxLevel = 2;
function attachMovieClip(){
_root.createEmptyMovieClip("fractal"+(fractalNum+1),fractalNum);
for(movieNum=0;movieNum<=movieCnt;movieNum++){
_root["fractal"+(fractalNum+1)].attachMovie("fractal"+fractalNum,"movie"+movieNum,movieNum);
_root["fractal"+(fractalNum+1)]["movie"+movieNum]._x=originalX[movieNum];
_root["fractal"+(fractalNum+1)]["movie"+movieNum]._y=originalY[movieNum];
}
centerMovie(_root["fractal"+(fractalNum+1)]);
fractalNum++;
if(fractalNum<=maxLevel){
attachMovieClip();
}
}
function centerMovie(movie){
movie._x = (currentCanvasSize - movie._width) / 2;
movie._y = (currentCanvasSize - movie._height) / 2;
}
__________________
|
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Working with dynamically created multiple instances | homdog | Newbies |
3 | 12-15-2010 09:56 AM |
| Help: addressing dynamically created MC/BMP and dynamic videos!? | fechan | Flash CS3 / Flash 9 |
1 | 09-27-2007 10:13 PM |
| Loading a movie into a dynamically created clip | PUP100 | Flash MX ActionScript |
3 | 12-12-2004 11:57 AM |
| Dynamically Import and Attach AS to Movie Clips | thebeige | Flash MX ActionScript |
2 | 09-26-2003 03:57 AM |
| Problems with setMask() and Dynamically Created Text Boxes | Artificer | Flash MX ActionScript |
1 | 08-22-2003 05:55 AM |





