A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: If someone could please debug

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    8

    If someone could please debug

    Code:
    for (var i:Number = 0; i < 100; i++) {
    	duplicateMovieClip("FWloop", "FW"+i, i);
    	var randX:Number = Math.floor(Math.random()*728);
    	var randY:Number = Math.floor(Math.random()*90);
    	setProperty("FW"+i, _x, randX);
    	setProperty("FW"+i, _y, randY);
    	setProperty("FW"+i, _alpha, 50);
    	var currentTime = Math.round(getTimer() / 1000);
    	var endTime = Math.round(getTimer() / 1000 + 4);
    	trace(currentTime);
    	trace(endTime); 
    	while (currentTime < endTime) {
    		var currentTime = Math.round(getTimer() / 1000);
    	};
    };
    	
    stop();
    If someone could please explain to me why this isnt working, I would appreciate it. I traced all the components that make it up, and they all run fine individually, but once put together it just locks up. I am no developer, i fear.

    .ryan.

  2. #2
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hey there, there are a lot of problems with this.
    Can you tell me exactly what you want to happen.

    This is just ablind attempt by going with what you already had.
    If this is not correct let me know.

    PHP Code:


    //actionscript

    stop();
    endTime Math.round(getTimer() /1000 4);    

    this.onEnterFrame=function()
    {

    currentTime Math.round(getTimer() / 1000);

    if(
    300)
    {
        
    duplicateMovieClip("FWloop""FW"+ii);
        
    randX Math.floor(Math.random()*728);
        
    randY Math.floor(Math.random()*90);
        
    _root["FW"+i]._x randX;
        
    _root["FW"+i]._y randY;
        
    _root["FW"+i]._alpha 50;

        
    trace(currentTime);
        
    trace(endTime); 
    }
    // instead of for loop
    i++;

    if(
    currentTime >= endTime) {
            
    trace('completed')
            
    delete this.onEnterFrame;
        }

    3P

  3. #3
    Junior Member
    Join Date
    Oct 2007
    Posts
    8
    Hey thanks for the response.

    First, I apologize for being vague in my origional message. Heres what I am attempting:

    After a web banner finishes animating, small fireworks continue to burst in the background. There is a symbol that is the burst animation (FWloop), I just needed a way to play it in an endless loop that placed it at random across the stage. The traces were not important, I just had those to help me track where i was going wrong.

    So basically I am not a coder (that last time i wrote code was in Pascal if that is any indication of how long it has been) but I am getting thrown into actionscript for coding bits of web banners for the design firm i work for. That beubg said, I want to know how to do more, and hope to not just have code written for me, but figure out what I was doing wrong and need to do differently in the future.

    Thanks for your help, Im throw it in the mix and see what happens!

    .ryan.

  4. #4
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hey there,
    I think this is what you want.
    I added a few other things to make it a work a bit better.

    Hope it helps you and gives you some ideas.

    3P


    PHP Code:
    this.onLoad = function()
    {
    // Width to populate with MCs
    displayW 726;
    // Height to populate with MCs
    displayH 150;
    // Quantity of MCs to generate
    quantity 15;
    // How fast to remove MCs
    speed 3;

    // dont change
    i=0;
    j=0;
    //
    }



    this.onEnterFrame = function()
    {
    i++;

    if(
    speed == 0)
    {
    j++;

        
    _root.attachMovie("FWloop""FW"+jj);
        
    randX Math.floor(Math.random()*displayW);
        
    randY Math.floor(Math.random()*displayH);
        
    randXs Math.floor(30+Math.random()*70);
        
    randA Math.floor(15+Math.random()*40);
        
    randR Math.floor(30-Math.random()*60);
        
    randYs randXs;
        
    // There are a few extra changes for variety.
    // comment out or remove any you do not need
        
    _root["FW"+j]._x randX;
        
    _root["FW"+j]._y randY;
        
    _root["FW"+j]._xscale randXs;
        
    _root["FW"+j]._yscale randYs;
        
    _root["FW"+j]._alpha randA;
        
    _root["FW"+j]._rotation randR;


    = ((j)-quantity);
    removeMovieClip(_root["FW"+k]);
    }


  5. #5
    Junior Member
    Join Date
    Oct 2007
    Posts
    8
    Okay so with some minor tweaks it works, the problem now is the depth. Currently the movie clip plays on top of everything else.
    Now I have been struggling with depth issues for two days now with no luck. I just dont understand how depth is assigned or even works. I tried using the line
    _root["FW"+j].swapDepths();
    to dump it to a lower level, but nothing works, not even -1,000,000,000. I also tried changing
    duplicateMovieClip("FWloop", "FW"+j, j);

    to
    duplicateMovieClip("FWloop", "FW"+j, j- (insert number));

    but that didnt work either.

    I think i may have something to do with placing the code in one of my subroutines, most likely the sub routine containing the FWloop animation, but that hasnt helped me either (nothing happens).

    So: how the heck does depth work in flash?

    .r.

  6. #6
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hey there. Add this to a blank movie clip.
    When its within the clip you can place it above or below the main timeline objects.

    Cheers,

    3P


    PHP Code:
    stop();

    // Width to populate with MCs
    displayW 726;
    // Height to populate with MCs
    displayH 90;
    // Quantity of MCs to generate
    quantity 15;
    // How fast to remove MCs
    speed 3;

    // dont change
    i=0;
    j=0;
    //

    this.onEnterFrame = function()
    {
    i++;

    if(
    speed == 0)
    {
    j++;
        
    this.attachMovie("FWloop""FW"+jj);
        
    randX Math.floor(Math.random()*displayW);
        
    randY Math.floor(Math.random()*displayH);
        
    randXs Math.floor(30+Math.random()*70);
        
    randA Math.floor(15+Math.random()*40);
        
    randR Math.floor(30-Math.random()*60);
        
    randYs randXs;
        
       
    // There are a few extra changes for variety.
       //comment out or remove any you do not need
        
    this["FW"+j]._x randX;
        
    this["FW"+j]._y randY;
        
    this["FW"+j]._xscale randXs;
        
    this["FW"+j]._yscale randYs;
        
    this["FW"+j]._alpha randA;
        
    this["FW"+j]._rotation randR;

    n1=j-interval
    this
    ["FW"+j].txt j;
        
    if(
    this["FW"+n1]._x >= Stage.width -this["FW"+n1]._width)
        {
        
    this["FW"+j]._y this["FW"+n1]._y this["FW"+j]._height;
        
    this["FW"+j]._x 0;
        }
        else
        {
        
    this["FW"+j]._x this["FW"+n1]._x this["FW"+n1]._width;
            
    if(
    this["FW"+n1]._y Stage.height)
        {
            
    this["FW"+n1]._y 0;
        }
        else
        {
        
    this["FW"+j]._y this["FW"+n1]._y;
        }
        
        }


    = ((j)-quantity);
    removeMovieClip(this["FW"+k]);
    }


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