SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Controlling a clip based on the value of an ever-changing variable?

    This is killin' me... I'm not great at ActionScript anyway. The client wants to amend a movie that involves a scroller left to right, so that the "left" movie clip fades out when the content clip is all the way over to the left and the "right" movie clip fades out when the content clip is all the way to the right. Here's the ActionScript. The last four lines should show you what I'm trying to do.... doesn't work though!

    Code:
    onClipEvent (load) {
        center = 400;
        _root.reelPosClicked = reel._x;
        leftStop = -4801;
        rightStop = -1;
    }
    onClipEvent (enterFrame) {
        if (_ymouse>225 && _ymouse<250) {
            reelSpeed = (_xmouse-center)/10;
            _root.reelPosClicked = Math.round(_root.reelPosClicked-reelSpeed);
            if (_root.reelPosClicked<leftStop) {
                _root.reelPosClicked = leftStop;
            }
            if (_root.reelPosClicked>rightStop) {
                _root.reelPosClicked = rightStop;
            }
            reel._x = _root.reelPosClicked;
        }
    }
    onClipEvent (mouseMove) {
        if (_root.reelPosClicked=-1) {
            _root.leftScroll.gotoAndPlay(2);
        } else {
            _root.leftScroll.gotoAndPlay(11);
        }
    }
    Any help? Any obviously stupid things?

    G

  2. #2
    SitePoint Zealot webQS's Avatar
    Join Date
    Oct 2002
    Location
    Sydney : Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Greg

    You mean like an alpha fade out?

    How about when the clip's ._x gets to a certain pos it plays a fade out animation?

    Got a SWF example?

    Cheers
    James

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's exactly it... actually, I nearly got it licked. I've kept the same code (nearly). What I still haven't solved, and don't know if there's a work-around for or not, is this:

    The problem I was (and am!) having, I realised, was that because using the "enterFrame" onClipEvent was a repeated operation once a frame, my movie clips WERE in fact doing as they were supposed to. Every 24th of a second they were doing as they were supposed to, and so in effect the playhead never left the start of the action. I've racked my brains and don't know a way around this, unless there's a more suitable onClickEvent than "enterFrame". What I've done instead is dispense with the alpha fade and just have it gotoAndStop, either showing or not depending on the frame, and then it doesn't matter if Flash carries that command out every frame...

    For example:

    Code:
    onClipEvent (enterFrame) {
    	if (_root.reelPosClicked==-4801) {
    		_root.rightScroll.gotoAndStop(2);
    	} else {
    		_root.rightScroll.gotoAndStop(1);
    	}
    }
    I don't have an SWF (apart from my own) but it sounds like you've got what I'm after anyway.


  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IS this Flash 5 or Flash MX? If its MX, you can use setInterval() to check for the changes in position, and make the interval maybe like every second or however often you want to. Can be much more efficient in terms of processsor load using setInterval over onEnterFrame.

  5. #5
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll take a look at that. Still trying to avoid insisting on the Flash 6 plugin, but I am working in MX.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •