A Flash Developer Resource Site

View Poll Results: Was this post clear and to the point?

Voters
1. You may not vote on this poll
  • Wait what? say that again....complete jibberish

    0 0%
  • i don't think u knwo what yoru talking about

    0 0%
  • you could clarify your post better

    1 100.00%
  • VERY CLEAR POST!

    0 0%
Multiple Choice Poll.
Results 1 to 20 of 27

Thread: array and indexing movie clips

Hybrid View

  1. #1
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Code:
    var lastDown:MovieClip = null;
    That line does two things. First, it declares the lastDown variable as a MovieClip. Then, it initializes that variable to null. Strictly speaking, initializing it is not necessary as the default value for an Object type variable is null, and there's no way the code will reference it before it's properly set anyway. I just like to be explicit.

    The lastDown variable is intended to hold a reference to the last movieclip which was touched, as long as it is being held down. Setting it to null means that there is no such movieclip, meaning nothing is being held down. In the press1 function, we set it to the clip which was touched. It should remain with that value until either the timer fires, or the mouse is lifted. If the timer fires, then the user held down for the duration of the timer. If the mouse is lifted, then we reset lastDown and the timer to be ready to try again.

  2. #2
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    oh ok sweet ur an AS3 genius. i bet u created it or somethin

  3. #3
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    im havin the same problem now with an array of sliders. everytime i click on any random slider, the LAST slider in the array is the only one that moves. even if i'm clicking on a different slider somewhere else on the screen, and moving the mouse upward, the last slider in the array will mimick the mouse's movement and move up, while the one i actually clicked on wont' move at all.

    it's got to be similar to the problems i've had before, i need a way to let it know that it cant just pick up the last slider in the array, it needs to move the one thats being clicked on.

    Code:
    var FADERarray:Array=new Array("fader1","fader2","fader3","fader4","fader5");
    
    for (var iFADER:uint; iFADER< FADERarray.length; iFADER++) {
        var FADER:MovieClip=getChildByName(FADERarray[iFADER]) as MovieClip;
    	FADER.addEventListener(MouseEvent.MOUSE_DOWN, dragScroll);
    	addEventListener(Event.ENTER_FRAME, loop);	stage.addEventListener(MouseEvent.MOUSE_UP, dropScroll);
    	FADER.buttonMode = true;	
    	var bounds:Rectangle = new Rectangle(FADER.x,795,0,205);
    	var draging:Boolean=false;
    }
    
    function dragScroll(evt:MouseEvent):void{
    	FADER.startDrag(false,bounds);
    	draging=true;
    }
    
    function loop(e:Event):void{	
    	svalue.text=String(Math.round((FADER.y-bounds.bottom)/(bounds.top-bounds.bottom)*8.00));
    	
    }
    
    function dropScroll(evt:MouseEvent):void{
    	FADER:stopDrag();
    	draging=false;
    }
    
    }
    lookin though the code again, i think the problem may be with the bounds, perhaps here:

    Code:
    svalue.text=String(Math.round((FADER.y-bounds.bottom)/(bounds.top-bounds.bottom)*8.00));
    or here:
    Code:
    var bounds:Rectangle = new Rectangle(FADER.x,795,0,205);

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