tags:

views:

695

answers:

1

that's about it. I want a big movieclip or image to be dragable around the screen like a map. i'm very new to actionscript so please be descriptive. thank you in advance

A: 

Option 1: Your easiest option would be to use the ScrollPane control in Flash.

You could get away with no code at all initially.

  1. Drag a ScrollPane component from the Components Panel (Ctrl+F7/CMD+F7)
  2. Set scrollDrag to true in the Parameters tab
  3. Input the path to a movie clip's linkage id in the ScollPane's source parameter.

Have a look at the documetation and examples.

Option 2: Use a mask 1.set a mask in the IDE or using actionscript to your 'big movieclip' 2.add event listeners for MOUSE_DOWN and MOUSE_UP to setup dragging

bigMovieClip.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);

function dragOn(event:MouseEvent):void{
event.currentTarget.startDrag();
}
function dragOff(event:MouseEvent):void{
bigMovieClip.stopDrag();
}

Option 3: Use the scrollRect property of MovieClip If your clip is 1000x1000 for example, and you want your visible area to be 500x500 starting from 0,0 all you need to do is

bigMovieClip.scrollRect = new Rectangle(0,0,500,500);

then when you need to scroll, you store the rectangle, modify the x or y depending on your needs and update the scrollRect

var sRect:Rectangle = bigMovieClip.scrollRect;
sRect.x += 20;
bigMovieClip.scrollRect = sRect;

Good luck

George Profenza
ok. first, thank you for the answer.second, i tried the scrollpanel example, and it's more or less what i'm searching for, except i don't want to have horizontal and vertical bars, and i would like the little map to be on the left. is that possible?the second and third examples i don't understand, if you could be even more specific, like you're talking to a 7 year old, it would be great :)(i don'tknow what IDE is, and how to do a mask)
Agata
ok so i did the mask thing!! but now it is saying something like this:ReferenceError: Error #1069: Property stopDrag not found on flash.display.Stage and there is no default value. at Untitled_fla::MainTimeline/dragOff()so it just keeps glued to the mouse and i can't drag anymore. Is it not compatible with as3, or it's something else?
Agata
hey i'm sorry to be commenting so much, but i think i got it, i just changed "stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);" to "bigmovieclip.addEventListener(MouseEvent.MOUSE_UP, dragOff);" and i think it is working. thank you!
Agata
Hi, IDE means Flash, the editing tool itself, so what I meant was manually drawing the mask on a layer above your big clip and setting the layer mode to Mask. I've fixed the error thingy, the mouse up should be set on stage because you can press on the big clip, but release outside and dragging might not stop.
George Profenza