A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Stop both objects from dragging?

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    7

    Stop both objects from dragging?

    Hey all,

    I've been searching various sites and forums for a solution to this, but have so far found none, so I was hoping to ask for some advice on the subject.

    Basically I have a movieclip of a photoframe, and I'd like it so when the user clicks the edge of the frame, they can drag it around, while clicking the photo inside the frame will open a new window and show the photo in full view.

    Originally I thought I could accomplish this simply by using:

    (Note: Framemc is the main movieclip, with another mc called "Photo" inside which is the picture)

    Code:
    framemc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    framemc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    
    function pickUp(event:MouseEvent):void {
        event.target.startDrag(true);
    }
    function dropIt(event:MouseEvent):void {
        event.target.stopDrag();
    }
    But this leads to an odd problem: When dragging the frame it works fine, but the user can also drag the "photomc" around too (like, the frame stays in place and doesnt move with it), thus removing it from the frame.

    Is there a way to tell the code to move only certain parts of the mc and not others? Or is there some other way to accomplish this?

    Sorry if this is a simple question, I'm still pretty new to As3 and Actionscript in general, I wasnt sure if I should put this in the newbie section or not, but since my problem is releated to as3 I decided to place it here.

    Thanks in Advance!!

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    7
    Hello,

    I actually managed to fix my problem by using a different method of dragging the objects, so thanks anyway.

    However I have a new question if thats ok, I figure I'll just use this topic rather then start a whole new one:

    I'm making a webpage with different external swfs that load in. I want to be able to close the child swf using a button from within the child swf. So far I have that working perfectly.

    However, I can only open the child swf once. After I close it, if I attempt to open it again I recieve this error:

    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at ImageExample_fla::MainTimeline/movieLoaded()
    Any advice? Thanks in advance!

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