A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Duplicate movie clip adjustments

  1. #1
    ASs 2.0
    Join Date
    Feb 2003
    Location
    Istanbul / Turkey
    Posts
    140

    Question Duplicate movie clip adjustments

    Hello,

    I have found a little FLA which demonstrates how the duplicate movie clip can be used.

    I tried to simplify and adjust the AS according to my needs. With some part i was successful but with some i wasn't.

    My first problem is,
    i want to be able to set the beginning X position of the clips as "0" in X values. but when i assign "0" to the this._x , it naturally generates/duplicates all the clips at the same point. What I'm trying to achieve by doing this is, when the stage is scaled in means of width my clips should start to originate from the very left of the stage whatever the stage's width is.

    my second question is how can i adjust the speed?
    When I stretch the stage width they(duplicated clips) all speed up in order to travel the whole stage in the same amount of time as they do with the initial/beginning stage width. I want the speed to stay constant whatever the distance is.

    I'm sure you'll have more idea on what I'm talking about if you can take a look at the attached FLA. You'll have a better idea about my intention.

    THANK YOU ALL,
    Attached Files Attached Files

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    can u post the code instead ..cheers
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    ASs 2.0
    Join Date
    Feb 2003
    Location
    Istanbul / Turkey
    Posts
    140
    First of all thank you for quick response,
    Here are the codes.

    This is 1st frame of _root
    PHP Code:
    myBg._width Stage.width;
    dot_mc._x 0;

    var 
    stageL:Object = new Object();
    stageL.onResize = function() {
        
    myBg._width Stage.width;
        
    dot_mc._x 0;
    }

    Stage.addListener(stageL); 
    This one is inside the dot_mc movieclip symbol in the first frame

    PHP Code:
    dots 75;
    for (
    k=0k<75k++){
        
    duplicateMovieClip(dotclip"dotclip"+kk);

    And for the last one this code piece is attached to the dotclip inside the dot_mc,

    PHP Code:
    onClipEvent (load) {
        
    //variables
        
    width Stage.width;
        
    //random x,y, and alpha 
        
    this._alpha 20+Math.random()*50;
        
    //random x and y for flakes
        
    this._x = -width+Math.random()*(3*width);
        
    //speed and trigonometric value
        
    rad 0;
    }
    onClipEvent (enterFrame) {
        
    width Stage.width;
        
    // horizontal movement
        
    xmovement 0;
        
    this._x -= Math.cos(rad)+(xmovement-(width/2))/50;
        
    // vertical movement
        // remove clips when they misbehave (overstep boundaries)
        
    if (this._x>(width+50)) {
            
    this._x = -45;
        }
        if (
    this._x<-50) {
            
    this._x width+45;
        }

    Hope the hierarchy isn't complex for you...

    Thank you very much,

  4. #4
    ASs 2.0
    Join Date
    Feb 2003
    Location
    Istanbul / Turkey
    Posts
    140
    Actually my aim is to create a "traffic" animation from side view. 2D.
    And i want my cars(dots in this case) to move from left to right appearing at the very left edge of the stage and disappearing at the very right edge regardless the width of the stage. And travelling the stage with a constant speed again regardless of the total width.
    If i give x a value of zero to make them generate at the far left side of the stage, then all the dynamically created movieclips overlap and act as one dot.

  5. #5
    ASs 2.0
    Join Date
    Feb 2003
    Location
    Istanbul / Turkey
    Posts
    140
    Any ideas? I need this to be done asap... any idea or help is greatly appreciated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center