Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,255
Total Threads: 81,172
Total Posts: 566,872
There are 43 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Flash and Actionscript :

startDrag problems(as3)

Thread title: startDrag problems(as3)
Closed Thread    
    Thread tools Search this thread Display Modes  
10-20-2007, 01:37 PM
#1
vfistri1 is offline vfistri1
Status: Junior Member
Join date: Jul 2007
Location:
Expertise:
Software:
 
Posts: 60
iTrader: 0 / 0%
 

vfistri1 is on a distinguished road

Send a message via MSN to vfistri1

  Old  startDrag problems(as3)

i have been trying to convert as2 code to as3 for scrollbar. and i managed to do everything except startDrag.
so basicly i want to be able to drag mc called *drag* but i need x coordinates to remain same only y coordinates should change.
I have been reading tutorials and help file for about 3-4 h now and still dont understand how to do it.
everything works just fine if i dont try to make it move only on y and that x remains same(if i put only startDrag()

this part is what needs to be changed (i think)


function fonpress(event:MouseEvent):void {
drag.startDrag(true, Mysprite);
}

var mySprite:Sprite = this.drag();
this.addChild(mySprite);
drag.addEventListener(MouseEvent.MOUSE_DOWN, fonpress ) ;


and this is how it looked in as2
startDrag(this, false, drag._x, min_y, drag._x, max_y);

here is the full code:
Code:
/////////////////////////////////////////////////////////

 import fl.transitions.Tween;
 import fl.transitions.easing.*;
 import flash.events.MouseEvent;
 import flash.display.Sprite;




var animacija_skrola:Boolean = true;  	// kasnjenje scrolla DA/NE
var time:Number =50;  					// kasnjenje u milisekundama
		// y pomak kod skrola 

/////////////////////////////////////////////////////////


sadrzaj.mask = maska;
drag.y = maska.y;					 // pocetna pozicija - drag
var min_y:Number = maska.y;
var max_y:Number = maska.y+maska.height-drag.height;	
var dy:Number = maska.height-drag.height;
var d_height:Number = sadrzaj.height-maska.height;

function fdrag(event:Event):void {
	
	var pozicija:Number = Math.round(maska.y-d_height*(drag.y-min_y)/dy);
	if (animacija_skrola == false) {
		sadrzaj.y = pozicija;
	} else {
		 var motion:Tween = new Tween(sadrzaj, "y", Strong.easeOut, sadrzaj.y, pozicija, time, false);
	}
}
this.addEventListener(Event.ENTER_FRAME, fdrag);


//////////////////////////////////////////////////////////////////

function fonpress(event:MouseEvent):void {
	drag.startDrag(true, Mysprite);
}

var mySprite:Sprite = this.drag();
this.addChild(mySprite);
drag.addEventListener(MouseEvent.MOUSE_DOWN,fonpress);

function fonrelease(event:MouseEvent):void {
	drag.stopDrag(true, Mysprite);
	drag.alpha=30;
}
drag.addEventListener(MouseEvent.MOUSE_UP,fonrelease);


function fdragover(event:MouseEvent):void {
	drag.alpha=100;
}
drag.addEventListener(MouseEvent.MOUSE_OVER ,fdragover);


function fdragout(event:MouseEvent):void {
	drag.alpha=30;
}
drag.addEventListener(MouseEvent.MOUSE_OUT,fdragout);


/////////////////////////////////////////////////////////////////

03-21-2008, 03:48 PM
#2
taf is offline taf
Status: I'm new around here
Join date: Mar 2008
Location:
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

taf is on a distinguished road

  Old

Did you try use startDrag(false, new Rectangle(drag._x, min_y, drag._x, max_y)); (there rectangle is to limit your motio as it was in as2)?

Closed Thread    


Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed