Setting the stage to scroll horizontally left or right to show content when button is clicked? - actionscript-3

I want to create a flash site where I have a long horizontal movie clip split into about five sections, each about 960px wide. The effect I want to achieve is when the user clicks on the button it will scroll horizontally to the specific section of the flash project. For example, if your on the home page and you click on the contact the movieclip will tween to the right until it reached the contact section of the long movieclip. And I also want it where if the user clicks on the home it'll scroll back to the home page. I can't seem to accomplish. I tried positioning with the x property and move right so many pixels. I'm thinking about setting like some coordinates or some kinds of reference points so when the button is clicked it will go to those specific points in the stage.

what you have to do is
create a container MovieClip/Sprite add it to stage
add all five MovieClips to this container
set x positions for each child. child1 - 0, child2 - 960, child3 - 1920, child4 - 2880, child5 - 4800
move container to 0, 960, 1920, 2880, 2880 to show child MoviClips 1 to 5 as needed
If needed use a library like TweenLite for cool transition

Related

How to scroll instantly a ScrollPane in libgdx?

I would like to place the child actor at an initial position within the ScrollPane, but the scrollTo() method seems to only do a scroll animation, and doesn't allow to move the child actor instantly. Using the child actor's setPosition() has no effect too.
call updateVisualScroll() after programmatically updating the scroll position

Flash Slider Component

I just started learning flash on my own and I decided to make a cool little image gallery (somewhat of a family album). When I test the movie the first image loads in the center. Below the image are little thumbnail sized buttons which can be clicked and the image will load in the center. Since I am going to be incorporating a lot of photos I would like to use a Slider (left to right) so I can scroll back and forth through the photos and find the one I want to click on to display.
Since I have no experience with Action-script I was hoping someone could get me started with that process and maybe explain how the Slider works.
Thanks!
You can create easily your own slider, and learn something in process :) .
In slider - moving of knob, must correspond to moving of gallery where size of gallery is translated to size of slider. That is basically it. So you will need some mathematical formulas and basic elements:
gallery.width/slider.width - to determine if gallery is wider than
slider (so you would want to proceed with sliding), you can also use this proportion to determine a size of the knob. So if gallery would be smaller than slider - then you may not render slider, or make knob the size of slider, so it would be not movable. Or make knob proportional size to size of overflow of gallery - just experiment with everything I'm writing here.
You would need to use also those elements:
gallery (Display Object),
mask/container for gallery (the visible part of gallery),
slider,
knob.
Rectangle object
Gallery would be just a Display Object that contains all images as children.
Mask/container would be display object that would provide boundaries of area where part of gallery would be visible
Slider - any Sprite
Knob - any Sprite
Rectangle - would be of course Rectangle object, with width of slider.width - knob.width, and height of 0, so it would allow to drag knob along a slider without going outside of it, by using function:
knob.startDrag(false, rect); // Use it at MouseEvent.MOUSE_DOWN of knob
knob.stopDrag() // Use it at MouseEvent.MOUSE_OUT of knob
You can create rectangle with this code:
new Rectangle(0, knob.x, slider.width - knob.width, 0);
And you would need to translate moving of knob to moving of gallery which would be something like this:
// When moving knob you can use this formula:
gallery.x = knob.y / (slider.width - knob.width) * (gallery.width - mask.width); // Use it at MouseEvent.MOUSE_MOVE of knob
I think that should be it, I wrote it from the top of my head based on some library I wrote some time ago, so please tell me if you will encounter any problems, but I think that are all basics you need.
Have a look at the ScrollPane
Add your thumbnails in a container and use that as the Scrollpane's source and scrolling will be taken care of

Only see what is inside the bounds of a container in Flash AS3?

i cannot remember how i can "hide" a movieclip inside the bounds of its parent, so that i can use a scrollbar, and only see what is inside the container if i scroll down? My container is a small rectangle and contains different pictures, but we can see all the pictures even if they are outside the bounds of the parent movieclip.
Would you know how to do this? not the scroll system, just how to : only see what is inside the bounds of the container?
Thanks
That would be masking, which can be done through the timeline layers or through code.

Actionscript 3 hide overflow of a sprite

I am trying to create a sprite in Actionscript 3 using Flash Professional with fixed width and height that contains a list of TextFields that scrolls up and down. I want the highlighted textfield to be fixed focus with the text that goes out of the sprites bounds to be invisible. I am new to AS3 and tried to set the width and height of the sprite but it did not work. I would do this with CSS by having a with a fixed width and height and setting the overflow property to hidden. Thanks for any help!
Check out the ScrollPane component as you can set a fixed width and height for the content and choose to automatically show scroll bars for the pane.
Add a mask to the sprite to contrain what is visible, http://www.ilike2flash.com/2009/06/dynamic-masks-using-sprites-in.html

scaling and positioning with tweenlite

I have a movieclip with the mesurements of a rectangle. When the application is launched the movieclip is being scaled before placed on the stage as following.
menu.width = 400;
menu.scaleY = menu.scaleX;
this is a smaller size than the original.
the position of the movieclip at this moment is in the middle on the x and top of the stage on the y.
when i click iti would like to do a tween with tweenlite wich scales it to its original(bigger) width and height and position it in the center of the stage on x and y.
the problem is when i position it with tweenlite, it gets done according to its old scale and not according to its new(bigger) scale so the movieclip isnt placed in the exact center of the stage.
Anyone know how i can resolve this?
I tried to compensate by adding a bigger number on the position so it gets positioned in the right way.
But when i click it again i would like it to rescale to its beginning scale and position so it would be very messy to compensate again. Is there any easier way to do this kind of tween?
I doubt that i'm being clear to what i want but i hope i am after all.
The easy and way of tween position and scale is probably to add the menu to a container.
You would then on one hand tween the position of the container, and on the other apply the scale to the menu it self without having to recalculate the proportional position if the scale changes.
This way you can even control the registration point of the menu within the container. e.g. to always scale from the middle...
This can be done with a matrix as well if you want to avoid to stack objects, but honestly it can get really tricky whereas the container method is bullet-proof.