LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-05-2005, 04:35 PM
debonaireFlash's Avatar
debonaireFlash debonaireFlash is offline
Registered User
 
Join Date: May 2002
Location: KS - USA
Posts: 78
Rep Power: 12
debonaireFlash is on a distinguished road
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;    
}
Thanks to the Flash Gurus that help make up this site.
__________________
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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




All times are GMT. The time now is 01:50 PM.