Controlling Scrolling With _x Position And A Button
Hi Everyone,
I have a horizontally LONG MC that I only want to display 300 px at a time on the main stage, however I have buttons on either end of it that control whether it should scroll left or right.
Someoned hinted yesterday that using AS to control the _x position would do it, but im not sure how to call that or use it properly? Is anyone able to post an example of how my left and right buttons would look?
Another thing to consider is that if the end of the MC has been reached, I want it to stop.. not loop.
Thanks!
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-11-2004, 11:54 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Controlling Stage Scrolling With Mouse Position
I am trying to create a stage that moves around based on the x and y location of my mouse with easing to stop the screen from going past the boundaries. Any thoughts or advice?
here is an example
http://www.chromazone-imaging.co.uk/flashindex.html
thanks
-P
Controlling Movieclip's ._x Position Using A Button
Hi,
I've delved back into flash after a couple of years and am tearing my hair out just trying to achieve basic things in actionscript.
I'm currently trying to get a button to control the ._x position of a movieclip. I've had some success (please see attached file), but rather than moving continuously, the movieclip only moves once when the mouse rolls over the button.
Can anyone help, please?
http://www.fortescueonline.co.uk/move.fla
Controlling Scrolling When Mouse Over A Button
Hi Everyone,
I've never done this in Flash and I can't quite seem to find a tutorial thats as specific as what I'm looking for, but I have a navigation of names that I want to horizontal scroll ONLY when the mouse is over a button (left or right arrows).
I've attached a picture to show you what I mean...
Further to this, I was hoping to add an effect similar to the mac osx dock where when you rollover one of the names (which are also buttons) in the scrolling navigation, it becomes bigger so you can really tell that's the name you're over.
Any help is appreciated - Thanks!
Controlling MC Position
This is perobably a very simple action, but I'm trying to make an interface similar to the barney's style but much more simple.
--- I just want to know how to make another movie clip move along the x axis by pressing a button ---
There's probably a turtorial on this somewhere but I can't find it - so I'm asking you guys. Thanks.
Controlling Mc Position Using 'this'
I have added an extra line in the code (in bold) below which controls the y position the problem is that if you alternate between the mc's the 'aboutus' eventually moves off the stage. How can I prevent this from happening. In addition this code is for one mc any ideas on streamlining the code to encompass another 6 mc's.
var aboutus_rot=aboutus._rotation
// when you rollOver
aboutus.onRollOver = function()
{
// create an onEnter
this.onEnterFrame = function()
{if(this._rotation<10+aboutus_rot){
this._rotation += 2; // rotate the mc
this._y -=4
this._xscale += 0.2; // increase its size
this._yscale = this._xscale; // increase its size
}
};
};
// when you rolOut
aboutus.onRollOut = function()
{
this.onEnterFrame = function()
{
// if it has reached original size
if (this._xscale <= 100) {
this._rotation = aboutus_rot; // reset rotation
this._yscale = this._xscale = 100; // reset size
delete this.onEnterFrame; // delete the method
// while it doesn't reach original size
} else {
this._rotation -= 2; // rotate the mc
this._y +=4
this._xscale -= 0.2; // decrease size
this._yscale = this._xscale; // decrease size
}
};
};
ADV: Controlling The Screen Position
i need to know the actionscript property that controls the screen position... if its _root._x then i dont understand how it works.. please explain
Controlling Movieclip Position
Hi,
I'm looking to create a navigation system that operates by 'scrolling' a movieclip.
For example, if I have a movieclip that is three times the width of my workspace and is broken into three section (pages 1, 2, and 3). On the click of a button I want the movieclip to be positioned with, say page 3 centred. And, if another button were clicked, page 1 to be centred - scrolling straight past page 2 as necessary.
This site achieves what I'm looking to do, but on a vertical plane: http://www.loungecom.com/
If someone could just give me a shove in the right direction I'd appreciate it.
Cheers
Controlling Mc.'s Position On Screen.
Hi all, I have a mc w/ an invisible button attached to my main stage called mc.return. Attached to the mc.return is the following script:
ActionScript:--------------------------------------------------------------------------------on (release) {
mc.blkqueen._x = 275.3;
mc.blkqueen._y = 461;
}
--------------------------------------------------------------------------------
The mc.blkqueen has startDrag and stopDrag actions attached to it (which works fine). It has also been instanciated as mc.blkqueen.
Seems logical to me that pressing mc.return should place mc.blkqueen at 275x461 - but nothing happens when I test it.
Hoping someone would shed some light on this quandry for me.
Much thanks!!!!
Controlling MCs Using Mouse Position
First off, bear in mind that my explanations tend to make things more complicated than they really are, and that my .SWF example will easily explain my dilemma.
In my Flash file, the user is supposed to be able to control a movie clip simply by rolling over it. Here is a simplified example: if the mouses x-position is 26, then the movieclip should go to and stop on frame 26. If the mouses x-position is 23, then the movie should go to and stop on frame 23. And so on and so forth.
I'm guessing this is somewhat simple to script, yet I don't really know where to begin. I know what is going to be required, likely script that frequently checks the users x-position and then targets the mc and tell it to go to a specific frame. I'm guessing the MC would have to use the onClipEvent (enterFrame)
Yet another problem I have is, how would I equal x-value with frame number? In the example I gave above, an x-value of 1 is equal to 1 frame. Yet, my movie will be different. The dimensions of the movieclip is 315 pixels. There are 150 frames in the movieclip. Therefore, each rollover area should be 2.
This may be really confusing, but I've included a perfect visual example of what I'm aiming for. The problem with the example I made, however, is that it uses 30 movie clips that go to a specific frame when the user moves their mouse over it. This might suffice for a small film, but for a 150 frame film, one can see the difficulties in this.
Anyways, like I said, I tend to overcomplicate explanations, so here is the .SWF that pretty much explains it all. It's around 50kb.
I really could use any help possible!
Controlling Mouse Position
Hi,
i would like to know how to control my mouse position. more specificall with the arrows on my keyboard. Not how to find the position and not how to attach a movie clip to it or hide it.
so i have a menu with 6 buttons. i want to navigate throught it with the arrow keys on my keyboard.
I made a movie clip that moves from one button the the next and back again with the left and right arrow keys. This works fine. i now want to make the mouse go to where the movie clip is each time i press the left or right arrow key.
Here is the code i have so far for the movie clip moving to where the buttons are.
//moving the movie clip
on (keyPress "<Left>") {
this._x-=80;
}
on (keyPress "<Right>") {
this._x+=80;
}
//so doesnt go off screen
onClipEvent (enterFrame) {
if (_x<0) {
_x = 435;
}
if (_x>435) {
_x = 35;
}
}
so basically i want the mouse to go to where the movie clip is. but i could be going about this totally wrong so any suggestion please. Anyway that i can control the mouse position.
Thanks
Controlling Mc.'s Position On Screen.
Hi all, I have a mc w/ an invisible button attached to my main stage called mc.return. Attached to the mc.return is the following script:
ActionScript Code:
on (release) {mc.blkqueen._x = 275.3; mc.blkqueen._y = 461;}
The mc.blkqueen has startDrag and stopDrag actions attached to it (which works fine). It has also been instanciated as mc.blkqueen.
Seems logical to me that pressing mc.return should place mc.blkqueen at 275x461 - but nothing happens when I test it.
Hoping someone would shed some light on this quandry for me.
Much thanks!!!!
Controlling A Buttons Position With AS
hi
im making a movie with buttons in it that need to move around. the only way i can do it at the moment is by putting the buttons in a movie clip and then controlling the position of the mc. can i achieve the same effect without needing the mc?
Controlling Frames In MC With Y Or X Position From Other MC?
Hi,
It's official I cant code if my life depended on it, not sure why but the simplest codes are killing that used to work before .
I'm trying to make it so, when my MC instance "dragger" is dragged down every pixel, the other MC with instance "knife" with an animation inside will go forward 1 frame (per pixel dragger moves). When dragger is released, it should snap back to original position as well as knife snapping back into 1st frame.
Basically I'm trying to learn a flip-book type of effect.
Even my drag codes arent working, I'm trying to set boundaries for _x and _y values of dragger as well but no luck here. Any help is appreciated, at least with this dragging bit lol! Thanks.
Controlling Movieclip Position
Hey, I'm building a gallery for my new site and scroll the thumbnails inside a movieclip controlled by up/down buttons. I've got the scrolligg to work fine but now I need it to stop when it reaches a certain point.
Here's an example of what I'm working on. As you'll see, if you keep hovering on the up or down buttons the thumbnails keep moving and disappear.
I'm using the following code:
Code:
gallery_up_btn.onRollOver = function() {
gallery.onEnterFrame = function() {
this._y -= 4;
};
};
gallery_up_btn.onRollOut = function() {
delete gallery.onEnterFrame;
};
gallery_down_btn.onRollOver = function() {
gallery.onEnterFrame = function() {
this._y += 4;
};
};
gallery_down_btn.onRollOut = function() {
delete gallery.onEnterFrame;
};
Any ideas?
Al
Controlling Mc.'s Position On Screen.
Hi all, I have a mc w/ an invisible button attached to my main stage called mc.return. Attached to the mc.return is the following script:
ActionScript Code:
on (release) {mc.blkqueen._x = 275.3; mc.blkqueen._y = 461;}
The mc.blkqueen has startDrag and stopDrag actions attached to it (which works fine). It has also been instanciated as mc.blkqueen.
Seems logical to me that pressing mc.return should place mc.blkqueen at 275x461 - but nothing happens when I test it.
Hoping someone would shed some light on this quandry for me.
Much thanks!!!!
Controlling A Buttons Position With AS
hi
im making a movie with buttons in it that need to move around. the only way i can do it at the moment is by putting the buttons in a movie clip and then controlling the position of the mc. can i achieve the same effect without needing the mc?
Controlling Mc With Cursor Position
I am trying to control a MC with the cursor position.
It works half the time but i think i need some sort of listener.
_root.onEnterFrame = function() {
if((this._ymouse <= 140 ))mastopmc.gotoAndPlay(60);
}
_root.onEnterFrame = function() {
if((this._ymouse >= 141 ))mastopmc.gotoAndPlay(1);
}
[F8] Control Position Of Playhead In Movieclip By Position Of A Button
I am fairly new to actionscripting and just need a little help.
I have a bar which has a slideable block on it. When this block is dragged, to the left/right i want it to control the playhead inside another movieclip.
For example, when the block is to the far left, the playhead (of my movieclip) will be at the first frame. When the block is dragged to the right it will play the movieclip at the speed that the block is being moved and when it is at the far right it will be on the last frame of the movieclip. And when the block is dragged to the left it will play the movie backwards at the same speed etc...
It is just like the scrubber bars that are in media players, but instead of playing an actual video, i want to play the movieclip which is of an animation.
How would I do this?
Thanks
Controlling The Y Position Of A Movie Clip
Hi, I'm very new to actionScript and haven't a clue where to start here. Any help will be much appreciated. Here is where I have got to so far.
The client wants a vertical text scroller, however he doesn't want it anti-aliased and he wants it behind a mask. As far as I am aware this rules out using static and dynamic text and so I have imported a gif. If you think I have gone wrong already then please let me know.
I don't need a scroller just the up and down buttons. I thought this would be quite easy but all the tutorials I have found either use dynamic text or include a scroller all making it more complicated than I need.
I am using Flash 5 and the final movie should look something like this :
http://www.kookimedia.com/textscroll.htm
Any ideas?
Thanks
Mouse Position Controlling Playback Of Mc
from somebody who is a beginer of actionscript, does anyone know the script for:
there is a mc "animation" which is around 20 frames long and
is the full length of the movie (700pixels)
and i want it to play when i have my mouse on the right hand
side of the screen and reverse when on the left side and halt when in the mouse
is in the middle of
the screen.
ive tried searching for tutorials everywhere and i can only find them on when a
mc follows your mouse and doesnt actually play.
if anyone could help it would be great cheers
Controlling Playhead Using Mouse Position
I'm trying to figure out how to control a movieclip's playhead in the timeline to where it is relative to the x position of the user's mouse. I'm not wanting to move a movieclip's _x and _y position, but rather advance or rewind the frames in that movieclip's keyframed animation.
I have done some seaching on this in various forums and have come across various tutorials on how to advance and "rewind" the playhead in a movie, but most of these involved buttons which carry out the actions rather than actions based on the _x value of the mouse.
It would also be helpful if in figuring this out, the script was written to where the animation progresses or reverses relative to the speed of the user's mouse as well.
I hope I've worded this clearly. If anyone knows how to do this or has come across some other tutorials on this issue, please let me know!
Thanks in advance.
p
Controlling Position Of MC With Mouse Postition
Hi, I got this script which works with the mouse position, yet my object is not centered on the canvas, I was wondering how can I improve the script. It reads as follow:
test.onEnterFrame = function() {
this._y = -_root._ymouse/10;
this._x = -_root._xmouse/10;
test.onEnterFrame = function() {
this.:yPos100
this.:xPos100
};
thanks
iam2001
Controlling Volume With Mouse Position
Hi,
I did just post this in Flash mx forum but it might be better sutied in here..
Is there any way of making the volume of a piece of music increase, the closer the mouse gets to a certain spot on the stage (or perhaps a movie clip..)?
thanks for any help
Marc.
Help With Controlling Movieclip Via Mouse Position...
Sorry.. noob question probably.. but I've tried to think of how to go about this several ways and am hitting walls... what I want to do is: I have a movie clip that is set at 1/10 scale. What I want to do is when the mouse is down (pressed) on the movie clip, I want to enlarge or shrink its scale by moving the mouse up or down, basically when _ymouse changes. The scale change should be to some ratio of mouse movement. The hard part for me, is trying to figure out how to determine how much the mouse has moved up or down, and then how to use that difference to change the scale of the movieclip. Any help would be greatly appreciated.
Thanks
Slider Controlling Position Of Clip
HI,
I have a project to do which involves having a slider control the position of another movie clip. So what I need it to do is that while the slider moves left, the object moves right and vice versa. Now both the slider and object have a set length, meaning that for example the slider length is 200 px and the objects is 350px. So the slider can only move from 0 to 200px and the object can only move from 0 to 350px, but the object is masked so you only see 200px of it.
So what I need it to do is when the slider is all the way at the right(200px mark), the object has moved to the left so that the right end is visible in the masked section. The same for the left side. The problem I am having is that since the slider length and the objects length is not the same, I dont know what the proper math would be to make it move smooth. Like if the slider moves 5px, how much should the object move? If both the slider and object were the same length then I would just write code that if the slider moves 5px, then the object should also move 5 px. But since the are not the same length I am having trouble figuring it out.
I have attached a test file I made just to show anyone willing to help me exactly what I mean if my explanation happens to be a little confusing. The file is just a timeline animation of what I need it to do with code.
Controlling A Mc Playback With The Position Of A Mouse
from somebody who is a beginer of actionscript, does anyone know the script for:
there is a mc "animation" which is around 20 frames long and
is the full length of the movie (700pixels)
and i want it to play when i have my mouse on the right hand
side of the screen and reverse when on the left side and halt when in the mouse
is in the middle of
the screen.
ive tried searching for tutorials everywhere and i can only find them on when a
mc follows your mouse and doesnt actually play.
if anyone could help it would be great cheers
Bit Of Help Needed With Controlling A Scrollers Position
lo everyone,
I have a scroller inside a flash 5 project i'm doing for a client it has inertia, it has a list of text items in it which users can scroll, but I would really like to be able to move the scroller down the list click a text move away from that page and when the user comes back to the list scroller, to be able to pass a variable to the script of the scroller on returning to force it to scroll down to the text item clicked previously or to show the next one to click, so that they don't have to scroll back down, or not be able to see the link they clicked.
I have been playing with different parts of the script but cannot work out which bit to use to recieve the variable and in turn make in move into position.
a link to see the scroller: fla file link
a link to see the scroller swf: swf file link
script:
on the main scroller mc is this script:
onClipEvent (load) {
diff_y = setbounds._height-scroller._height;
bounds = setbounds.getBounds(this);
top = bounds.yMin+(scroller._height/2+2);
bottom = bounds.yMax-(scroller._height/2);
function updateScrollbar() {
content.Ypos = -(((scroller._y-top)/diff_y)*(content._height+35-setbounds._height));//add 30 to height create margin
}
}
onClipEvent (mouseDown) {
if (scroller.hitTest(_root._xmouse, _root._ymouse)) {
startDrag("scroller", false, scroller._x, top, scroller._x, bottom);
scrolling = true;
}
}
onClipEvent (mouseUp) {
stopDrag();
scrolling = false;
}
onClipEvent (enterFrame) {
if (scrolling) {
updateScrollbar();
done = false;
} else if (!done) {
done = true;
}
}
and the content clip which is inside the above clip has the text items in that scrolls and has this little bit of script on it:
onClipEvent (enterFrame) {
Ysquare = this._y;
Ydiff = Ypos-Ysquare;
Ymove = Ydiff/3; //modify easing out speed here
this._y = Ysquare+Ymove;
}
Can you guys have a muchas at this tell me where i need to stick the code so the scrollers poisition or contents Y gets set depending on a variable pass to it, I have managed to move the content MC but then the scroller you grab with the mouse doesn;t get updated and end up being all over the place.
AaaaaaRrrrrrrrrrrrrrrrrrrrg was on this till 3am last night...any help would be much appreciated.
Thankyou thankyou
Controlling A Movieclip With Mouse Position?
I want to have a movie clip where the position of the mouse dictates what frame of the movieclip is playing. ie As you mouseover the clip to the right the movieclip will be moving forwards and vice versa.
I think it's relatively simple but my head hurts!
thanks
Controlling A Movie Via Mouse Position
I want to be able to advance a movie according to mouse position. The code I have only tracks the EXACT frame and follows the mouse.
::::::::::::::::::::::::::::::::::
var point = new Object();
rectangle_mc.onMouseMove = function()
{
point.x = _xmouse;
if( this.hitTest( _root._xmouse, _root._ymouse ) )
{
_parent.globalToLocal( point );
var mainX = ( point.x - this._x );
var targetFrame = Math.floor( ( mainX / this._width ) * 100 );
this.gotoAndStop( targetFrame );
}
};
:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::
My question is this:
" how do I get the movie to ease in to where it needs to be?"
examples
www.agencynet.com
http://www.schech.net/de/start.html (its in the SLIDE section)
Controlling Position Of Thumbnails Using Variables
Hi the code is attached for reference.
This action script controls a photo gallery
I need to modify the dimensions of the movie clip. I was able to change the position of where the main image clips and also where the thumbnails appear at the starting point, however when the scroll pane starts to move to left and right I cannot control it's position any longer. I need to show the thumbnails about 500 from the left of the flash and make sure it will stay this way. Right now, when I mouse over the scroll pane the thumbnails start moving to the left all the way to about 4 pixels from the left of the movie.
Can someone help. I am providing links for the difference between movie clips. Any help is super appreciated.
Before changing movie dimensions
After changing movie dimensions
Attach Code
/*
---------------------------------------------------------
Classe Controlador
---------------------------------------------------------
Controla tudo o que ocorre no slide show...
---------------------------------------------------------
*/
class SlideShow {
// atributos
var nPics:Number;
var nThumbs:Number;
var picsLoaded:Number;
var thumbsLoaded:Number;
var picAtual:Number;
var thumbAtual:Number;
var dirImg:String;
var dirThumbs:String;
var modoShow:Boolean;
var razaoPorc:Number;
var scrollLimite:Number;
var base:MovieClip;
var clipAtual:MovieClip;
var showPlaying:Boolean;
var movendoThumbs:Boolean;
var vel_thumbs:Number;
// métodos
function SlideShow(clip:MovieClip) {
nPics = 17;
dirImg = "body/images/fullsize/";
dirThumbs = "body/images/thumbnails/";
vel_thumbs = 10
nThumbs = 0;
picsLoaded = 0;
thumbsLoaded = 0;
razaoPorc = 100 / nPics;
base = clip;
modoShow = true;
showPlaying = false;
trace("INICIAR")
}
function iniciar() : Void {
var a, b : Number;
var txt, txtFoto : String;
var objThumb : Object;
ocultarTudo();
base.listaThumbs.thumb1.ativo = false;
base.listaThumbs.thumb1.numero = 1;
base.foto1.numero = 1;
base.foto1.pronto = false;
// cria os espaços para cada foto e thumbnail
for(a = 2; a <= nPics; a++) {
b = a - 1;
txt = "thumb" + a;
txtFoto = "foto" + a;
base.listaThumbs.thumb1.duplicateMovieClip(txt, b);
base.foto1.duplicateMovieClip(txtFoto, b);
base.listaThumbs[txt].ativo = false;
base.listaThumbs[txt].numero = a;
base[txtFoto].numero = a;
base[txtFoto].pronto = false;
}
base.loadingPics._visible =
base.loadingThumbs._visible = true;
// ajuste de profundidades
base.fade.swapDepths(nPics);
base.btPlay.swapDepths(nPics + 1);
base.loadingPics.swapDepths(nPics + 2);
base.loadingOnePic.swapDepths(nPics + 3);
picAtual =
thumbAtual = 1;
clipAtual = base.foto1;
base.infoSlides.slideTotal.text = nPics;
carregarFoto(1);
carregarThumbs();
}
function ocultarTudo() : Void {
var a : Number;
base.btNext._visible =
base.btPrevious._visible =
base.btPlay._visible =
base.infoSlides._visible =
base.loadingPics._visible =
base.loadingThumbs._visible =
base.listaThumbs._visible =
base.loadingOnePic._visible = false;
for(a = 1; a <= nPics; a++) {
base["foto" + a]._visible = false;
}
}
function carregarThumbs() : Void {
var a : Number;
for(a = 1; a <= nPics; a++) {
base.listaThumbs["thumb" + a].img.loadMovie(dirThumbs + a + ".jpg");
}
}
function avisarThumbCarregado(clip:MovieClip) : Void {
thumbsLoaded++;
base.loadingThumbs.barra._xscale = thumbsLoaded * razaoPorc;
base.loadingThumbs.barra._alpha = 100;
if(thumbsLoaded >= nPics) {
base.loadingThumbs.barra._visible = false;
posicionarThumbs();
}
}
function posicionarThumbs() : Void {
var anterior, atual : MovieClip;
var a : Number;
anterior = base.listaThumbs.thumb1;
ajustarBordaThumb(anterior);
anterior.img._alpha = 100;
for(a = 2; a <= nPics; a++) {
atual = base.listaThumbs["thumb" + a];
atual._x = anterior._x + anterior._width;
atual.img._alpha = 100;
ajustarBordaThumb(atual);
anterior = atual;
}
base.listaThumbs._visible = true;
base.loadingThumbs._visible = false;
scrollLimite = (base.listaThumbs._width > 600) ? 600 - base.listaThumbs._width : 4;
base.listaThumbs.ret = this;
base.listaThumbs.onEnterFrame = function () {
if(_root._ymouse > 435 && _root._ymouse < 600) {
var vel = _root._xmouse * 10 / 400 - 10
if(_root._xmouse < 300) {
trace(vel*-1/2)
trace("XMOUSE:"+_root._xmouse)
this.ret.moverThumbsDir(vel*-1/2);
} else if(_root._xmouse > 300) {
trace(vel)
trace("XMOUSE:"+_root._xmouse)
this.ret.moverThumbsEsq(vel);
}
this.ret.movendoThumbs = true;
} else {
this.ret.movendoThumbs = false;
}
}
}
function ajustarBordaThumb(clip:MovieClip) : Void {
var x, y : Number;
clip.borda._visible = false;
// desenha a borda
x = clip.img._width + 4;
y = clip.img._height + 4;
clip.borda.lineStyle(0, 0xFFFFFF, 100);
clip.borda.lineTo(x, 0);
clip.borda.moveTo(x, 0);
clip.borda.lineTo(x, y);
clip.borda.moveTo(x, y);
clip.borda.lineTo(-1, y);
clip.borda.moveTo(-1, y);
clip.borda.lineTo(-1, -1);
// ajusta a área de link
clip.link._width = clip.img._width;
clip.link._height = clip.img._height;
}
function moverThumbsEsq(passo) : Void {
if(base.listaThumbs._x > scrollLimite) {
base.listaThumbs._x -= passo;
}
}
function moverThumbsDir(passo) : Void {
if(base.listaThumbs._x < 4) {
base.listaThumbs._x += passo;
}
}
function selecionarFoto(num:Number) : Void {
clipAtual._visible = false;
picAtual = num;
clipAtual = base["foto" + picAtual];
exibirFotoAtual();
atualizarInfo();
atualizarBotoes();
}
function atualizarAtivoThumb() : Void {
var a : Number;
var txt : String;
// desativando o thumb anteriormente selecionado
txt = "thumb" + thumbAtual;
base.listaThumbs[txt].img._alpha = 100;
base.listaThumbs[txt].borda._visible = false;
base.listaThumbs[txt].ativo = false;
base.listaThumbs[txt].link._visible = true;
// ativando o thumb selecionado
txt = "thumb" + picAtual;
base.listaThumbs[txt].img._alpha = 100;
base.listaThumbs[txt].borda._visible = true;
base.listaThumbs[txt].ativo = true;
base.listaThumbs[txt].link._visible = false;
thumbAtual = picAtual;
// reposicionando os thumbs para que o ativo fique visÃvel
if(!movendoThumbs) {
centralizarThumbAtivo();
}
}
function centralizarThumbAtivo() : Void {
var pos : Number;
var thumb : MovieClip;
thumb = base.listaThumbs["thumb" + thumbAtual];
pos = base.listaThumbs._x + thumb._x + thumb._width;
if(pos < 0 || pos > 600) {
base.listaThumbs._x = Math.max(Math.min(0, base.listaThumbs._x + 350 - pos), scrollLimite);
}
}
function carregarFoto(indice:Number) : Void {
base["foto" + indice].img.loadMovie(dirImg + indice + ".jpg");
}
function contarFotoCarregada(indice:Number) : Void {
var txt : String;
var prox : Number;
txt = "foto" + indice;
picsLoaded++;
base[txt].pronto = true;
base[txt]._visible = false;
atualizarLoadingFotos();
centralizarFoto(indice);
prox = proximaFotoNaoCarregada(indice);
//trace("indice = " + indice + " prox = " + prox);
if(picsLoaded < nPics) {
carregarFoto(prox);
}
if(modoShow && !showPlaying && prox > 0) {// se está no modo slide show e as 4 próximas fotos já estão no cache, dá o play
if(prox - picAtual > 3) {
continuarShow();
}
} else if(indice == picAtual && !modoShow) {// se não está no modo slide show e está carregando a foto que se deseja visualizar, exibe imediatamente
exibirFotoAtual();
}
}
function proximaFotoNaoCarregada(indice:Number) : Number {
var a, cont : Number;
a = indice;
for(cont = 0; cont < nPics; cont++) {
if(!base["foto" + a].pronto) {
return a;
}
a = (a == nPics) ? 1 : a + 1;
}
return 0;
}
function atualizarLoadingFotos() : Void {
base.loadingPics.barra._xscale = picsLoaded * razaoPorc;
base.loadingPics.barra._alpha = 100;
base.loadingPics.nPic.text = picsLoaded + " / " + nPics;
}
function centralizarFoto(num:Number) : Void {
var clip : MovieClip;
clip = base["foto" + num];
clip._x = 300 - (clip._width / 2);
clip._y = 230 - (clip._height / 2);
}
function continuarShow() : Void {
modoShow = true;
showPlaying = true;
fadeinFotoAtual();
atualizarInfo();
atualizarBotoes();
}
function atualizarInfo() : Void {
base.infoSlides.slideAtual.text = picAtual;
base.infoSlides._visible = true;
if(base.listaThumbs._visible) {
atualizarAtivoThumb();
}
}
function atualizarBotoes() : Void {
base.btPrevious._visible = (picAtual > 1);
base.btNext._visible = (picAtual < 110);
}
function proximaFoto() : Void {
clipAtual._visible = false;
picAtual = (picAtual == nPics) ? 1 : picAtual + 1;
clipAtual = base["foto" + picAtual];
exibirFotoAtual();
atualizarInfo();
atualizarBotoes();
}
function fotoAnterior() : Void {
clipAtual._visible = false;
if(picAtual > 1) {
picAtual--;
}
clipAtual = base["foto" + picAtual];
exibirFotoAtual();
atualizarInfo();
atualizarBotoes();
}
function exibirFotoAtual() : Void {
if(modoShow) {
if(clipAtual.pronto) {
fadeinFotoAtual();
} else {
base.fade.gotoAndPlay(1);
showPlaying = false;
base.loadingPics._visible = true;
base.btPlay._visible = false;
carregarFoto(picAtual);
}
} else {
if(clipAtual.pronto) {
base.fade.gotoAndStop("parado");
clipAtual._visible = true;
base.loadingOnePic._visible = false;
base.btPlay._visible = true;
} else {
base.loadingOnePic._visible = true;
base.btPlay._visible = false;
carregarFoto(picAtual);
}
}
}
function fadeinFotoAtual() : Void {
base.fade.gotoAndPlay("fadeIN");
clipAtual._visible = true;
base.loadingPics._visible = false;
base.btPlay._visible = true;
}
function alternarModo() : Void {
if(modoShow) {
modoShow = false;
showPlaying = false;
base.btPlay.texto.text = "PLAY SLIDE SHOW";
exibirFotoAtual();
} else {
modoShow = true;
showPlaying = false;
base.btPlay.texto.text = "PAUSE SLIDE SHOW";
proximaFoto();
}
}
}
Controlling A Movie Clip's Position With Buttons
Hi All,
Some time ago I saw someone put up a post which included a link to a tutorial/example on Flash Kit, about scrolling a movie clip across the screen to a specified area from pressing a chosen button.
Does anyone know where I can find this or knows how to do it..
thanks heaps..
chaps
Controlling Sound Volume Via Movieclip Position
Hi all,
I'm working on a site (using FlashMX) where the user can scoll horizontally through a very wide environment that acts as a city. The interaction works basically like a QTVR movie, ie the users mouse position is tracked and the graphics scroll to & fro across the stage accordingly. The scrolling works well, no probs there.
The graphics consist of a city made up of different buildings side-by-side. I want each building to have its own sound clip that will play when the building appears on screen. The sound's volume should modulate such that it fades in from 0 as the building scrolls onto the stage, is at max volume when the building is centred on stage, and will fade down to 0 as it leaves the stage.
Sounds simple, yeah? I'm having some probs with the implementation though, please take a look..
It seems like there should be an easy way to accomplish what I'm after, but this is turning into a real quagmire. A different solution that accomplishes my goal would be just fine, I'm not tied to this code if there's a better way.
I have an empty MovieClip on the stage that acts as an engine clip to drive the sound process. Here is the script attached to the engine clip:
PHP Code:
onClipEvent (enterFrame) {
//call functions to play building-based sounds
//check if the right building is loaded into the holder clip & make sure its sound is not already playing
if (_root.loadedArray[4] == "building5" && _root.buildingPlaying != true) {
trace("interval set for building5 (news)");
//make sure this only happens once
_root.buildingPlaying = true;
//set an interval to modulate volume
//parameters are: building name, sound linkage name, _x offset, parent clip path
_root.playIt = setInterval(_root.mainContent.followSound, 100, "building6", "news.aif", 750, _root.mainContent.holder4);
}
//these call the same function & should work for other buildings
if (_root.loadedArray[3] == "building2" && _root.buildingPlaying != true) {
trace("interval set for building2 (arena)");
_root.buildingPlaying = true;
_root.playIt = setInterval(_root.mainContent.followSound, 100, "building2", "news.aif", 500, _root.mainContent.holder3);
}
if (_root.loadedArray[4] == "building1" && _root.buildingPlaying != true) {
trace("interval set for building1 (hotel)");
_root.buildingPlaying = true;
_root.playIt = setInterval(_root.mainContent.followSound, 100, "building2", "hotel.aif", 200, _root.mainContent.holder4);
}
if (_root.loadedArray[3] == "building6" && _root.buildingPlaying != true) {
trace("interval set for building6 (coffee shop)");
_root.buildingPlaying = true;
_root.playIt = setInterval(_root.mainContent.followSound, 100, "building2", "CoffeeShop.aif", 250, _root.mainContent.holder3);
}
}
And here is the followSound() function that is called in the interval:
PHP Code:
//function to play building-based sounds
function followSound(whichBuilding, whichSound, offSet, myPath) {
//offset is how far into the movieclip the building is
//trace("followSound called, x = "+myPath._x);
//make sure to only create the sound once
if (doneOnce != true) {
//create new sound object
mySound = new Sound(soundLoader);
//attach the sound from the library
mySound.attachSound(whichSound);
trace("sound created!!");
//now the sound has been created, set a var so it's not created again
doneOnce = true;
//when the building comes into view, start playing the sound
if (myPath._x<460-offSet) {
mySound.start(0, 1000);
}
}
//set volume based on where the buliding is on screen
//left/right edge = 0, middle = 100
//stage is 760px wide, thus midpoint is 380
myVol = Math.floor(100-(Math.abs(myPath._x/380*100)));
if (myVol < 0) {
myVol = 0;
} else if (myVol >100) {
myVol = 100;
}
mySound.setVolume(myVol);
trace("volume set to "+myVol);
if (myPath._x-offSet>458 || myPath._x+offSet<-298) {
//the building has left the stage
mySound.stop();
delete mySound();
//reset vars so sound can be recreated when we come to another building
doneOnce = false;
trace("mySound stopped!");
_root.buildingPlaying = false;
//kill the interval
clearInterval(_root.playIt);
}
trace("");
}
Now this kind of works, but not really. One problem I'm currently having is that the sounds don't play until I've scrolled past the building & then come back to it. The function fires, but no sound is heard. The sounds are preloaded much earlier in the movie, so that is not an issue.
Thanks in advance for any help!
kris m
edit: 'as' vB tags were not showing up, so I switched 'em to 'php' tags (OSX & Safari)
Mouse Position Controlling Other Movie Clips
Yamaha Design
Click the link and let the pop-up appear. Click the skip button and get into any of the sections. Eventually you'll get to product photographs where rolling your mouse over either on the left or right side of the photo you get a 'Next' and 'Prev' flyout button.
I'd like to do the same thing except the pop-up button would require a click.
Anyone know where I can find some source code / tutorial on how to do this?
Thanx!
Controlling The Browser Scroll (page Position)
hi i have a really long swf (1500px) embedded i a html page
is there anyway i can make the browserscroll jump to the top from a action indside flash (button or frame action does'nt matter) i getting really anoying to always have to scroll to the top ?
Controlling Movie Clip With Mouse Position
Hi everyone. I've got what I think is a relatively simple problem to solve but I'm new to AS3 (I've just finished a Lynda.com tutorial) so I'm a bit shaky on exactly how to do what I'm looking for....
Basically I have a movieclip that's playing a sound and i want to control the volume of the sound as well as the alpha of the clip with mouse position. If the you approach the clip with the mouse, from any direction, it should fade away and the noise should get louder.
I found this tutorial http://www.kirupa.com/developer/flashcs3 /detecting_direction_mouse_movement.htm
and I understand how it works but trying to figure out how to turn the information the script gathers (x and y coordinates) and turn it into a function that does what I am looking for. I'm pretty sure I have to add an event listener but I'm not really sure how to do so or where to add it. Any help on this would be fantastic.
also- here is the script used in the above tutorial.
Code:
var prevX:int = 0;
var prevY:int = 0;
var curX:int = 0;
var curY:int = 0;
var dirX:String = "";
var dirY:String = "";
function Start()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, CheckDirection);
}
Start();
function CheckDirection(e:MouseEvent)
{
var xDirection:String = GetHorizontalDirection();
var yDirection:String = GetVerticalDirection();
xText.text = xDirection;
yText.text = yDirection;
e.updateAfterEvent();
}
function GetHorizontalDirection():String
{
prevX = curX;
curX = stage.mouseX;
if (prevX > curX) {
dirX = "left";
} else if (prevX < curX) {
dirX = "right";
} else {
dirX = "none";
}
return dirX;
}
function GetVerticalDirection():String
{
prevY = curY;
curY = stage.mouseY;
if (prevY > curY) {
dirY = "up";
} else if (prevY < curY) {
dirY = "down";
} else {
dirY = "none";
}
return dirY;
}
Controlling Movie Clip Like Sclae , Rotate, Position
Hi all
I have started a project for a t-shirt store with a similar features spreashirt.com
can any one tell me how he is controlling the designs and text rotation and scaling inside the target area
its very urgent please give me some help
regards
druva
Locating A Clip's Position & Controlling Multiple Movie Clips
I'm using Flash MX and attaching a Movie Clip (Directions_mc) into my main time line. There is also another movie clip existing on my timeline (ntr). Later I want to stop the play of both movie clips from a button within an attached Movie (swf) file. This stop action needs to be able to occur at any point in my movie.
My code to attach the movie is:
DirText = new Object ();
DirText._x = 430;
DirText._y = 250;
attachMovie("Directions_mc", "Directions", 1, DirText);
I've also tried to specify a level at the beginning of the attachMovie
portion of the code as follows:
DirText = new Object ();
DirText._x = 430;
DirText._y = 250;
_level5.attachMovie("Directions_mc", "Directions", 1, DirText);
My code on my button is:
on (release) {
_level0.ntr.stop(); //this code stops an instance of another movie clip on my main movie timeline
_level0.Directions. stop();
}
If I specify a level in the attachMovie command, my movie clip does not display. It displays fine without it.
My button stops one movie clip (ntr) but will not stop my attacheMovie clip from playing at all.
I've also traced my clip that wont stop using the following command:
trace (typeof(_level0.Directions)); //
The trace results are "undefined".
It looks like I have no idea where this clip is living.
Anyone have any suggestions?
Scrolling An MC To A Fixed Position
I am desperately trying to achieve an effect which can be found on this site:
http://www.fme.fujitsu.com/employmen...ine/index.html
What I want to achieve is this:
Click on a relevant section on the nav and the 'content' MC will scroll to the corresponding position.
So in effect you end up with a very wide MC that is divided into sections.
I know it must be something like:
on (release) {
setProperty (_root.scroller, _x, "50");
}
but this will just move the MC to that position, not scroll it. Does anyone know of a code that will scroll the movie clip to a specified position?
Many thanks
Simon
EMERGENCY - Scrolling An MC To A Specified Position
I have a very wide MC (4000px) and a stage of about 500px.
I am going to divide the MC into sections to display various areas of the site.
What I want to do is create a script that can be attached to a button that will scroll the MC to a specified position. ie
on (release) {
setProperty ("_root.scroller", _x, "300");
}
This will obviously move scroller MC to 300 px but can anyone point me in the direction of how to scroll the movie to 300px!
Have a look at this for more of an idea
http://www.fme.fujitsu.com/employmen...ine/index.html
Cheers
Simon
[ _x Position Scrolling With Easing ]
Alright. I've seen this a million times but can't figure out how to do it, nor can I find a good sample .FLA to help me out. I have multiple pages of content in a clip. It's all masked and layed out and ready for horizontal motion/sliding/scrolling but I'd like to see it ease in and out of its motion without using tweening options. So to put it simply:
• I have a clip.
• Its scrolling is controlled by buttons on the main stage.
• I want it to move horizontally without tweening.
• I want it to rely on _x positioning if possible.
• I'd like to have it ease in and out of its horizontal sliding.
Any suggestions, samples, etc.?
Thanks in advance!
Umnbrella
Help. Scrolling By Mouse Position
How do I allow a user to scroll through a list, or, for example, a horizontal row of pictures, simply by repositioning the mouse left or right (from the center)?
Thanks in advance.
Scrolling MC -- Parameters For Y Position
I have a movieClip of a client list which has dual functionality.
You can view the .swf at:
www.thestudioa.com
click on "clients" to see the problem with the scrolling :O)
First, on rollover of images in the content area, the client list scrolls the client name to the top of the list using the following "slider" code in the movieClip:
Code:
onClipEvent (enterFrame) {
if (slider == 0) {
finalY = -132;
currentY = getProperty("", _y);
diffY = (finalY-currentY)/3;
setProperty ("", _y, (currentY+diffY));
The button rollover code is:
Code:
on (rollOver) {
clientlist.slider = 0;
Okay -- that part works fine.
The problem is that I also need the client list to scroll using up and down arrows. I need to use the same slider code so that the transition is smooth from the navigation scrolling to the content scrolling. Currently, I am using the following code for the up and down arrows:
up arrow targets slider 16
down arrow targets slider 17
and rollout / release targets slider 18
Code:
} else if (slider == 16) {
finalY = _y+5;
currentY = getProperty("", _y);
diffY = (finalY-currentY)/1;
setProperty ("", _y, (currentY+diffY));
} else if (slider == 17) {
finalY = _y-5;
currentY = getProperty("", _y);
diffY = (finalY-currentY)/1;
setProperty ("", _y, (currentY+diffY));
} else if (slider == 18) {
currentY = getProperty("", _y);
}
How do I set the maximum top and bottom y positions?
Using this code, the user can scroll up and down forever -- leaving crazy white space.
You can view the .swf at:
www.thestudioa.com
click on "clients" to see the problem.
Any help is so appreciated.
Thanks,
Danielle
[Edited by dkdg on 06-20-2002 at 06:17 PM]
Scrolling By Mouse Position
Let's say I have a horizontal image that I want the user to be able to scroll through based on the mouse position.
For example, if the mouse is on the left part of the menu, the mene will scroll left (and vice versa). Many sites have menus like this, including the Macromedia site, so I presume it's fairly basic.
Can anyone tell me how to do this, or at least point me in the right direction? I gather it has something to do with the mouse x/y position on the screen.
Thanks in advance.
Controlling A Scrolling MC
I have a scrolling timeline mc that I'm trying to use a button to find the frame the movie's on
and scroll it backward or forwards stoping at a target frame. (I know I can just have "Tell target jump me to a specific frame, but I want the effect of scrolling and back & forth)What I'd like to do is have the MC play until it reaches the target frame, then stop there.
this is my code - it's not working help!
cf= current frame
tf= target frame
the movie clip I'm trying to control is called "/history"
-----------------------------------------------------
On (Release)
Set Variable: "cf" = GetProperty ("/history", _currentframe)
Set Variable: "tf" = 40
If (cf < tf)
Begin Tell Target ("/history")
Go to and Play (2)
End Tell Target
Else If (cf = tf)
Begin Tell Target ("/history")
Stop
End Tell Target
End If
End On
-------------------------------------------------
Scrolling Clips, Using Mouse Position
Hi,
ok, check out, www.f1play.com
What im triying to do, is make a menu like the nav on the right of the site where it scrolls up and down as you move the mouse up and down. Does anybody have an example of this tha i could check out?
Thanks
Chris
Scrolling Background On Mouse Position Help
using flash 8.
ok now this works, but is limited.
everything moves back and fourth according to which way the mouse is moving, but for some reason it won't go further than say 1350px! why?
help me.
this.onEnterFrame = function() {
difference = _xmouse-_root.bg.menu_mc.arrow_mc._x;
_root.bg.menu_mc.arrow_mc._x = _root.bg.menu_mc.arrow_mc._x+(difference/2);
_root.bg.menu_mc._x = -_root.bg.menu_mc.arrow_mc._x;
};
|