Actionscript 3 :: Caching - Moving ScrollRect With CacheAsBitmap?
Aug 30, 2011
in order to increase performance of a scrollRect i must cache the vector as a bitmap, otherwise the scrollRect will be simply a less performant mask (info source).however, i can't seem to move an object/scrollRect once i've applied cacheAsBitmap. why?
package
{
//Imports
import flash.display.Screen;
import flash.display.Sprite;
[code].....
View 1 Replies
Similar Posts:
Dec 30, 2009
I have this PHP page that lists several people. When someone clicks on one of the people they are sent to another PHP page that has their video greeting in a .swf embedded into the page. This works by the php writing the path to the greeting video to the xml file that the .swf loads and plays.
Well in firefox it works perfect, but in IE when they try to click on another greeting the original greeting still plays. Its like the swf is caching the first greeting and refresh of the page does nothing to alleviate this. Is this a problem with the swf caching? or XML caching? or am I totally clueless?
[Code]...
View 1 Replies
Feb 22, 2010
Is it possible to use scrollRect without the flash.geom.Rectangle class?I know the scrollRect can be used like this:import flash.geom.Rectangle; myMC.scrollRect = new Rectangle(10,10,100,100);I need to make a flash which doesn't extends outside the stage (bacause loading it from another flash will expose anything outside the stage area). Using a mask is an option, but scrollRect seems very interesting because it would be easier and give greater performance.But I can not import the flash.geom.Rectangle class (and it seems overkill to import a class just to set x,y,width and height)How can use scrollRect without the flash.geom.Rectangle class?
View 3 Replies
Aug 11, 2009
I'm trying to move a scrollRect up and down using the mousewheel. that part i've got fine but now i wanted to add easing and am not sure on the maths..
ActionScript Code:
function handleMouseWheel(event:MouseEvent):void {
var rect:Rectangle = this.scrollRect;
var scrollSpeed:int = 10;
[code]....
View 0 Replies
Oct 19, 2009
If we have a Bitamp with more than 16777216 pixels (or one side larger than 8191 px) Flash 10 doesn't show it (Flash 9 and earlier has smaller limits even).One solution to this is to use scrollRect to limit the size displayed.OK, that works.
But Flash 10 has another problem, if we use any 3D property (rotationX, z, etc), flash transforms your MC in bitmap, so we can reach the above limit even when we are not working with bitmaps...A bigger problem is that although our MC could be really small (at least less than 16777216 pixels), when we apply a 3D transform like rotationX, the displayed MC can grows enough to reach the limit. And... we can't use scrollRect with 3D MC. But we have a trick here too, there are two ways to use scrollRect with 3D:
1. Create a 2D parent, then create the 3D displayObject inside of that parent.
2. Set cacheAsBitmap to true for the 2D parent.
3. Create a grandparent container to hold the first two items.
4. Set cacheAsBitmap to true for the grandparent container.
5. Apply scrollRect to the grandparent container.
These methods are really differents, with the second I couldn't use scrollRect to avoid reaching the bitmap limit. I think that's because in the second we apply scrollRect to the parent and 3D to the child, so nothing breakes our child from growing.With the firs method we apply scrollRect to the child, and the 3D property to the parent.
Code:
var p: Sprite = new Sprite();
var c: Sprite = new Sprite();
p.addChild(c);
[code]....
View 0 Replies
Aug 18, 2011
I have a scrolling background that is 1320 x 1000 big. I'm using a sprite as a container where my background canvas is placed inside of it. Additionally I add (via addChild) a score sprite inside of the background sprite (the one that holds the bg canvas so the score appears on top of the bg canvas).The goal is that when I add a score it shall be stuck to the background (even when the scrollrect moves; it shall have a fixed position on the background).The problem is that this doesn't work because when the score appears it moves with the scrollrect and this is not what I want. I already tried it with globalToLocal but had no success yet. Probably because I don't really understand globalToLocal (and vice versa)These are some code excerpts:
Code:
private var backgroundBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);
private var canvasBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);
[code].....
View 7 Replies
Jun 5, 2008
I have some actionscript, and it scrolls the scrollRect, but there is a catch. It doesn't completely scroll it. It lets me scroll down until it's halfway and stops. I can still scroll up to the top, but the problem is unerving. I can't find a fix for it.
[Code]...
View 2 Replies
Jan 27, 2009
There are two basic ways of panning a view in Flash. One is to move the display object (and use a mask if necessary). The other is to use scrollrect. Today I noticed a small, but annoying effect of scrollrect. Scrollrect's can't have true Numeric positions-- they are automatically snapped to the nearest pixel.
When moving at very slow speeds, the effect is noticeable. In this example you can switch between two modes of panning, sprite movement with mask and scrollrect:
http://lab.wx3.com/scrolltest/ (view source enabled).
In the default mode, the circles move smoothly.
In scrollrect mode, the circles seem to stutter because the scrollrect is snapping to the nearest pixel.found a way to make a scrollrect move smoothly at slow speeds?
View 3 Replies
Jun 19, 2009
I am having a problem with ScrollRect. I am unable to upload a file( i don't know why..i am getting upload error msgs). So i have quoted the code.
ActionScript Code: import flash.geom.Rectangle;
var container:MovieClip = container_mc;//container_mc is in timeline(its widht is 600 )
var window:Rectangle = new Rectangle(0, 0 , 400, 100);
container.scrollRect = window;
container.cacheAsBitmap = true;
[Code]...
Currently the leftmost part of movieclip is visible. I want to make right most part of movieclip to be visible at first. What should i do ?
View 2 Replies
Mar 24, 2011
I'm having a problem that involves scrollRect and getBounds. In short, getBounds is reporting an old value not accounting for scrollRect changes during that frame. Example:
ActionScript Code:
var shape:Shape = new Shape();
shape.graphics.beginFill(0);
[code].....
View 3 Replies
Oct 29, 2006
I have two pieces of code, that won't work together.First: this makes a hitTest on an mc to make it run on rollover:
Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();
[Code]...
Each work seperately, but they won't together. How do I get around this?
View 7 Replies
Jul 1, 2009
I'm having trouble using a scrollRect on an object instance on the timeline that has a motion tween. As soon as I apply the scrollRect to it, the object just stops! I've attached a simple fla that shows what I'm talking about.
Simply comment out this line in the first frame's actions to see the oval move across:
Code:
oval1.scrollRect = window;
The actual application I'm making is using a scrollRect on a custom list control, where each item in the list is a symbol in the library. It works great, except if I try to move my list around using a motion tween (the list still works, but the list doesn't move in the motion tween). As soon as I remove the code to apply the scrollRect, it works but the list fills the screen!
View 1 Replies
Aug 18, 2011
I have a scrolling background that is 1320 x 1000 big. I'm using a sprite as a container where my background canvas is placed inside of it. Additionally I add (via addChild) a score sprite inside of the background sprite (the one that holds the bg canvas so the score appears on top of the bg canvas).
The goal is that when I add a score it shall be stuck to the background (even when the scrollrect moves; it shall have a fixed position on the background).
The problem is that this doesn't work because when the score appears it moves with the scrollrect and this is not what I want. I already tried it with globalToLocal but had no success yet. Probably because I don't really understand globalToLocal (and vice versa).
These are some code excerpts:
Code:
private var backgroundBitmapData:BitmapData = new BitmapData(1320, 1000, false, 0x000000);
private var canvasBitmapData:BitmapData = new BitmapData(1320, 1000, false,
[Code].....
View 1 Replies
May 28, 2008
I'm trying to make a full browser webpage that utilizes the scrollRect type of class to pan around a movieclip that contains other movieclips and so on. The problem I run into is that when the browser window is resized that panning doesn't go with it. So panning to all the edges becomes impossible. I've tried a bunch of different stage resizing techniques but none of them give any good results. Here's the actionscript I'm currently working with:
[Code]....
View 4 Replies
Mar 11, 2009
hi guys, basically quick rundown is:
1. container1-->bitmap image with bitmapData.
2. container2-->bitmap image with bitmapdata.
3. im using the latest tweenmax
4. have correctly added a 2 seperate scrollrects to container1 and container2 that takes the width and height of the stage.
5. tweenmax is only moving the rectangles.
I get the effect i want, however, it still lags a choppy animation. Anyone know how come?
View 3 Replies
Mar 7, 2009
when cacheAsBitmap is true, do x and y suddenly become ints? im ok with them being drawn this way, but my calculations require x and y to be numbers, because else strange behaviour occurs, which is happening now.
View 6 Replies
Sep 19, 2011
Why does hitTestPoint isn't working on DisplayObjects that has cacheAsBitmap set to true?It does work, but it takes the Whole rectangle of Display object, not respecting wheather or not pixel is transparent or not (transparent pixels return true after hiTestPoint)
View 3 Replies
May 30, 2011
Is there any way to add 3D properties like .z and .rotationY without the MovieClip's cacheAsBitmap property being automatically set to true? This automatic cacheAsBitmap to true messes up the visual of my MC (which is using a lot of bitmaps and filters) as soon as I rotate it in 3D. And turning it "off" right after it doesn't seem to work.
View 2 Replies
Aug 19, 2009
Start a fresh AS2 document using its default publish settings. Draw a circle on the stage and convert it to a movieclip. Name it for example "my_mc". Apply a motion tween to it from left of the stage on frame 1 to right of the stage on frame 20. Test it and the circle moves from left to right.
Now apply this code on frame 1:
code: my_mc.cacheAsBitmap=true;
Test it again: the circle doesn't move; it freezes on its left position of frame 1.
Now change the publish settings from 'flash player 9' to 'flash player 8'. The motion tween now works again
Is this some bug anyone is aware of? Why can't I apply cacheAsBitmap AND a motion tween on a movieclip when using a AS2 document and Flash Player 9?
Just open attached file. While on its flash player 9 setting the circle doesn't move. Change the setting to flash player 8 and it moves again.
View 6 Replies
Jul 30, 2010
I'm loading child swfs in main swf, but as default all loaded swfs has cacheAsBitmap set to true, how to set it to false from main swf? this: loadedSwf.cacheAsBitmap = false; - have no effect.
View 1 Replies
Aug 6, 2011
I'm loading a MovieClip which pixels should be displayed perfectly.Every child of this MovieClip and the MovieClip itself uses only whole integers in position and size.The funny thing is that even if I use "myMovieClip.cacheAsBitmap = true" sometimes it will appear blurry.
View 1 Replies
Jan 4, 2008
CacheAsBitmap stores a raster copy of a movieclip in memory to use. If that movieclip is rotated or scaled, the performance gain is lost as it must re-cache the new movieclip. I assume this also applies to a movieclip that has a constantly repeating internal timeline, even if that movieclip isn't rotating or being scaled. However, do additional frames (that aren't being used) affect this?I have a 'player' movieclip. This movieclip consists of about ten frames, each its own animation. Idle stance, walking, jumping, all the standard stuff. THe movieclip remains stopped on frame 1 (idle stance) for most of the game. Right now the Idle stance is an animation, so to use cacheAsBitmap I need to stop the idle animation. That's fine, but does the additional content in the movieclip interfere with this? If I go from a walking animation back to the idle stance will it re-cache the idle stance for me?
The main reason I ask is that I wasn't able to notice much of a performance difference between either method. Cacheasbitmap on a player sprite with animated idle stance, and Cacheasbitmap on a player sprite with a static idle stance. Both resulted in 39 fps (set to 40) in the flash player. Which is good I suppose, but I don't know how the results will vary for someone with a slow computerThis is an important area of the game because at any given time there could be up to 12 player sprites on the screen (all with filters attached to them). So if one player is moving left/right the other 11 must be re-translated on each frame (since the stage moves too) so if all 11 players are playing their idle animations, with a glow filter, WHILE flash tries to re-cache all of them, that could lead to performance issues (although it hasn't yet for me)I want to give players the option to disable the idle animation, I just hope that it's actually working the way I intend. If cacheasbitmap fails because of any other content inside the movieclip then this would be a useless feature.
View 1 Replies
Mar 3, 2010
In the root of my swf i have 2 mc files "menu" and "mask". Mask has inside a vector gradient, while menu is a vertical scroll-able menu, then the mask makes a fading effect on top/bottom. The code:
Code:
stop();
_root.menu_mask.cacheAsBitmap = true;
_root.menu.cacheAsBitmap = true;
_root.menu.setMask (menu_mask);
Inside the menu i have, on first frame, the code for scrolling ( and some functions cause the buttons are duplicated from info on a xml file). The code:
Code:
stop();
var yPos = -23;[code].......
The Problem: If i Scroll the buttons all way up, the mask transparency parts looks like to move right (not the whole mask, just the transparency points). If i set no transparency for the mask, this problem doesn't show up.
View 1 Replies
Mar 15, 2010
I'm actually rendering quite a complex 3D scene (complex is a relative term here, doing a similar scene in d3d or opengl would be a breeze, but they're hardware accelerated so you'd expect that). I've built a 3D engine with some basic features including depth sorting, 3D tweening, and mapping between polar and cartesian coordinates. This last bit should be a give away as to what I'm doing - I'm rendering a 2d grid onto a sphere that I then unravel, spin around, squash, expand all so the Client goes ooh and aah. The trouble, is that on anything other than my workstation, rendering crawls. From discussions with other flash programmers and my own investigations, the slow down is most definitely caused by the rendering itself, and not my relatively swift matrix and sorting calculations (they take around 5-14ms tops depending on the complexity of the scene) .
So, my question is, what exactly does happen when I set cacheAsBitmap to true on a display object? I see no texture map distortion so I'm under the impression that flash automatically splits the cached bitmap into polygons for rendering, but how good is flash at doing this? I don't care about texture distortion on objects beyond a certain z value because they're far away, and try as I might I have found no way of setting the equivalent of a display objects 3d render quality. I'm certain that if I could set such a value, I'd at least double the render speed of my scene by only rendering many polys for objects near the camera. Failing this, is there a way to coerce flash into rendering a low poly object? Perhaps by making invisible any graphically complex children?
View 6 Replies
Mar 8, 2011
I'm using cacheAsBitmap to create a gradient mask. The code I set up worked great and all was well but I soon discovered problems when cacheAsBitmap was being nullified when its parent mc was loaded into another mc. I read up on it and from what I understand, since I'm using the MovieClipLoader class, this code should be included in onLoadInit in the root mc (start_mc). Basically this is what I have: start_mc loads main_mc (target) and rollMask1 and roll1 are contained within main_mc. Here's the script for onLoadInit:
[Code]...
View 50 Replies
Feb 16, 2010
is it possible to get access to Flash's internal bitmap cache of an object when CacheAsBitmap is on ?
eg, something like:
var bmd:BitmapData = someDisplayObject.getCachedBitmapData();
if (bmd != null)
trace("stoked!");
else
trace("bummer. got to bmd.Draw(someDisplayObject) ourselves.");
View 1 Replies
Aug 2, 2010
I'm a seasoned AS3 developer working on a major online project and we've run across a strange visual anomaly which is connected to the movieclip cacheAsBitmap property. When using author-time additive blends (which we use for lighting effects) in a movieclip, turning on the cacheAsBitmap property (without which performance becomes unacceptable in our very detailed art) seems to 'destroy' the additive blend. The art director says that the visual effect produced is as if the blend mode had been set to Normal, which I can confirm--some blends which are yellow turn orange, other 'spotlights' turn from transparent yellow to dark gray.
View 5 Replies
Dec 25, 2011
The cacheAsBitmap property is somewhat similar to what I had to do to get the filters to show up on iPhone GPU mode:But I played around with that property yet filters still don't show up.I even tried to put child objects (with filters) inside a parent object (no filters but cacheAsBitmap = true), no shows.
View 1 Replies
Jun 3, 2009
I have a very complex vector symbol on the Stage - background_mc. I have set background_mc.cacheAsBitmap = true.This turns background to bitmap and makes Stage repaint fast.Every frame the background light changes.I use the following code to alter the light.
(new Color(background_mc)).setTransform(light);
And here is the problem.The code works very slow.I guess because the light is applied to the contents of the background_mc.And then a new cached bitmap is resterized once again.The same code over BitmapData of the same size works much faster!Is there a way to tell Flash to apply color-transformation to the cached bitmap, instead of underlying vector symbols?
Note, that background_mc is scaled when Stage is resized.This is not so fast, but it's good, because the picture quality preserved.If I convert background_mc to BitmapData, bitmap would be scaled.
View 1 Replies
Aug 2, 2010
I have an image converted into MovieClip (background) and I have a mask MovieClip (bgMask) set to mask the image MovieClip like this:
[Code]....
In bgMask I have a few linear gradient shapes which I animate with shape tweens using keyframes. If I don't set cacheAsBitmap for both, nothing will happen since what I need is alpha masking and it will work only then. In this scenario is cacheAsBitmap working for me or agains me? (not that I have any choice). Still I could try to replace some of the shape tweens with MovieClips with solid shape in them and just move them around to uncover some part of the background, and where I want a smoother transition I would stick to the shape tweens. If the object that I've set cacheAsBitmap true to is no longer being animated moved sized and so on, would it be better to set cacheAsBitmap to it to false?
[Code]....
View 1 Replies