PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Floating/Moving movieclip within bounds of current location
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Floating/Moving movieclip within bounds of current location

  1. #1
    Member
    Join Date
    Mar 2007
    Posts
    79

    Floating/Moving movieclip within bounds of current location

    Hi,

    I've creating a site that has a long horizontal line of fullscreen background images. Currently, moving the mouse left and right scrolls the images right and left.

    I also have left and right arrows also for cycling through the images.
    I have several arrays with various bits of data about the images to help with the cycling.
    1 array contains all the widths of the images
    Another contains all the x positions of the containerClips within image_mc.

    The images are in a mc like so
    mcholder.image_mc.containerClip0
    mcholder.image_mc.containerClip2
    mcholder.image_mc.containerClip3
    ....

    mcholder is on the root.

    What I would like to do, is instead of continuous scrolling left and right, I only want the user to be able to scroll about 20-30px past each image, (I'm guessing based on the current image_mc._x

    When a user clicks an image it tweens into place and onComplete function stores the current image_mc._x value in a currentImageX var.

    I'm not sure how to this to limit my left and right scrolling when not clicking.

    My current scrolling code is this.

    Actionscript Code:
    speed = 200;
    mcholder.onEnterFrame = function() {
    _global.plotis = Stage.width;
        if (!(menu_bg.hitTest(_xmouse, _ymouse, true)) && mcholder.image_mc._x < 0 && mcholder.hitTest(_xmouse, _ymouse, true)) {
                var X = _xmouse - _global.plotis / 2;
                mcholder.image_mc._x += -X / speed;
        };
    };

    Any pointers?
    As the images are fairly large, the image_mc values are always negative.

    Thanks

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,811
    PHP Code:
    if (!(menu_bg.hitTest(_xmouse_ymousetrue)) && mcholder.image_mc._x && mcholder.hitTest(_xmouse_ymousetrue)) {
                if(
    currentPosition endPosition){
                            var 
    _xmouse _global.plotis 2;
                            
    mcholder.image_mc._x += -speed;
                }
        }; 
    You will have to change currentPosition and endPosition to the appropriate variable but this is the basic idea.
    .

  3. #3
    Member
    Join Date
    Mar 2007
    Posts
    79
    HI,

    Thanks for the reply. Just looking at the code, if the movieclip reaches say the left limit (and the if function no longer kicks in), how would moving the mouse the other way move the clip right?

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,811
    just change the if statement to something like this:
    if(currentPosition < endPosition || _xmouse < endPosition){
    .

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