How to scroll instantly a ScrollPane in libgdx? - 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

Related

How to make transparent div that will catch all clicks

I have web application that design is based on divs.
I need in that application block possibility of clicking on some javascript object.
So I thinking about adding transparent div that will be positioned with z-index on level/layer where I need and will capture all clicks without passing to lower z-index objects?
How this can be done?
Use absolute positioning in that covering div. Either don't set any background or set it as rgba(r,g,b,0)
I don't think this is a good design.
I don't know if you know that, but you can add a click listener to the body element itself. Every click will bubble up to body. It's called event delegation. I believe this solves your problem.

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.

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

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

HTML5 drag and drop to move a div anywhere on the screen?

The title is pretty self explanatory.
All the demos I've found consist in dropping a div to a certain location. E.G a trashcan. I need to make a draggable div that can be dropped anywhere on the screen.
Is it possible to do this with HTML5? if not how should I do it?
It's quite straightforward really:
In the dragstart event calculate the offset between where the user clicked on the draggable element and the top left corner
Make sure the dragover event is applied to the entire document so the element can be dropped anywhere
In the drop event, use the offset you calculated with the clientX and clientY of the drop to work out where to position the element
Here's one I prepared earlier. For bonus points you can update the top and left position of the element in the dragover event, this is useful if the bit you're allowing to be dragged isn't the whole element that needs to be moved.

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.