-
Senior Member
[RESOLVED] Set drag limits from code?
Hi,
is there any way to set the drag limits from code? I can't figure it out. Need to dynamically set the limits.
Thank you in advance. Have a nice day!
-
When looking in flash9 export code drag & drop are made like this:
public function onMouseDown (_e:MouseEvent):void
{
this.startDrag (false,new Rectangle (100,110,300,190));
}
public function onMouseUp (_e:MouseEvent):void
{
this.stopDrag();
}
so if you handle mouse drag&drop by yourself you can add you own draglimits.
Simple way could be that you add a rectangle variable to your object and use it in "startDrag" function... I could try to make an example later tonight..
-
Senior Member
Thanks! Sounds great. How do you look into the exported code?
-
If you use flash9 export mode then there is white "newspaper like" icon next to green "play movie" icon. I'm not sure if that is real exported code but it should be close enough actionscript3 what it shows..
-
Here is tested code,.. little bit change in event code but I'n not sure which way is the proper way... wont work in 3dfa, just flash9 export:
Execute script below as starting script...
Just add "star" object and then modify / create new Rectangle for myLimits variable in runtime.
Code:
var star = element ("Paint 3");
var myLimits = new Rectangle(0,0,300,300);
star.addEventListener(MouseEvent.MOUSE_DOWN, drag);
star.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(event:Event):void
{
star.startDrag(false, myLimits);
}
function drop(event:Event):void
{
star.stopDrag();
}
There is a better or more dynamic way to do this but anyway.. found above code from flashkit forums
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|