ActionScript 3.0 :: Bitmap Creation "after" Display Object Internal?
Aug 11, 2009I have an MC being duplicated to 2 bitmaps but they are created before the MC performs its internal script. How to change that order? see sample .fla
View 2 RepliesI have an MC being duplicated to 2 bitmaps but they are created before the MC performs its internal script. How to change that order? see sample .fla
View 2 RepliesI have an MC being duplicated to 2 bitmaps but they are created before the MC performs its internal script. How to change that order? See sample .fla.
View 2 RepliesI am trying to load an sprite into a bitmap, but cannot get the sprite to fill the bitmap. Here is the results I am getting: [URL]
here is the applicable part of the code I am using that gets these results:
function(){return A.apply(null,[this].concat($A(arguments)))}addChild(container); //add sprite to see true sizebd = new BitmapData(container.width,container.height,false,0xff0000); //colored for effectb = new Bitmap(bd);bd.draw(container);addChild(b); // add bitmap to compare to sprite
i want to use bitmap copy on a image that i loaded
[Code]...
Error : flash.display:BitmapData to an unrelated type flash.displayisplayObject. is there a work around that will remedy this?
1. I've read that when Bitmap Caching an object, if the objects you are caching are bitmaps that all point to the same bitmapData object, than only one instance is cached and used by the GPU. However, if the bitmap contains a scale, does this hold true, or is a new bitmap cached for each object because of the new scale? I'm pretty sure its the second one, just checking.
2. When using cacheAsBitmapMatrix, I've seen examples setting the matrix to identity, and setting it to the concatenated matrix of the bitmap object. Can someone explain the difference between the two approaches? I would assume setting it to identity doesn't scale it up or down when caching is as stated in the documentation:
"The matrix transformation you apply to the cacheAsBitmapMatrix property is applied to the display object as it isrendered into the bitmap cache. Thus, if the transform contains a 2x scale, the bitmap rendering is twice the size of thevector rendering. The renderer applies the inverse transformation to the cached bitmap so that the final display looks the same."
But if this bitmap is nested in a sprite that moves throughout the scene, will the bitmap still move with it? Or will I need to update the matrix's x/y everytime I update the sprite's x/y. If this problem exists, does using the concatenated matrix get around it.
3. Finally, I have seen some sites state that more gpu memory is used when cacheAsBitmapMatrix (such as an additional copy of the texture being pushed into the gpu), but I was under the impression that this would just rotate and scale the texture in memory using openGL matrices. Why would more gpu memory be used when cacheAsBitmapMatrix is set?
My understanding is that when designing for mobile, if the graphic isn't too large, and the object doesn't contain nested animating objects, the best approach is to cacheAsBitmap and cacheAsBitmapMatrix on the object to ensure it won't be pushed to the gpu each frame, but feel free to correct me if I'm wrong. Adobe states "Always set the cacheAsBitmapMatrix property whenever you set cacheAsBitmap to true in content created for mobile devices."
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.");
is there anyway to access the internal bitmap representation of a movieclip that has its cacheasbitmap property set to true?It would be nice if I could create vector artwork that scaled to the size of the browser and then obtain a bitmap representation of it so that I could then manipulate it on a per pixel basis for some cool visual fx.
View 1 RepliesWe create Objects in flex by declaring type Object. for example
var objSampleObject:Object = new Object();
and we create properties directly with dot operator without creating any class
[Code].....
My question is in above process is there any class is created internally by flex?
I know the topic of "duplicating" movieclips is a hot issue with the new virtual machine. Luckily, I understand the implications. I only am [currently] interested in duplicating a Bitmap. See, I load an image from an URL using 'flash.display.Loader.load', which is a non-blocking operation in Flash Player.However,I may use multiple copies of the loaded image (which is reported to be a Bitmap, naturally) in the display list at the same time.Hence, I naturally do not want to load the image from an URL every time, because I don't want to wait for a non-blocking call to complete. Nor do I need to - I mean one copy is already loaded, so it should be possible to just "duplicate" it, right?
My idea is to do use the bitmapData property of a Bitmap and pass it to the constructor of a new Bitmap object. I have not tried the following in action, but I want to hear whether any of you did and if the following would not work, what would:
Code:
var original_bitmap: Bitmap;
var copy_of_original_bitmap: Bitmap = new Bitmap(original_bitmap.bitmapData);
LiveDocs mention that the BitmapData being passed to a Bitmap constructor is "being referenced", which to me might suggest it cannot be used twice? There is also the BitmapData::clone() method, which I am not sure is applicable here or not.I know this is a lot of talk instead of just trying this out, but I test so much Flash Player code daily just to see "what works" (which should be documented instead by Adobe),
I have a class which work with data and I want to do something after its constructorfunction is finished.If a class is a MovieClip, I can do this:
Code:
public function constructor() {
addEventListener(Event.ADDED_TO_STAGE,init);
[code].....
I have a .fla set up right now that places ball randomly around the screen. However I would like to be able to set the coordinates of the range for the objects(particles) placement to the boundaries of a shape. I am starting with a circle for the moment, but I can't figure out how to set the range of object placement to that of an MC. I was planning on somehow calculating this out but I am stumped. Is there a better way for me to draw a shape, and somehow use a mask in as3 to define where the particles can no be placed?
View 21 RepliesI'm in the early stages of writing a rather complex app that grabs data from a database (via PHP bridge) and builds out content from it.This app is going to be a very visual timeline of sorts, with different entries of many types (images, audio, video, text, etc). Each entry type has some common properties (ID, location, date, etc), and some unique (imageURL for images, audioURL for audio, etc).When creating these objects dynamically, should I:
A) First read the data from the database, assign that data to a new object that contains *just* the data, and then pass that data object to the constructor of the visual representation of that object when instantiating the specific object of that type? Or,
B) Skip the creation of a data object, and instead pass the data property by property to the specific object class.
For instance (very roughly),
A)Code:
// receive queries data here
var newImageData:ImageData = new ImageData(imageURL, headlineText, captionText); // put data into data object
var newImageEntry:ImageEntry = newImageEntry(newImageData); // create new visual object, passing data object
B)Code:
// received queried data here
var newImageEntry:ImageEntry = new ImageEntry(imageURL, headlineText, captionText); // create new visual object directly
I won't be creating the visual representation of the object immediately, so I feel like I have no choice but to map the data to a data object first....but is there another way? Should I try to merge the two, so that an ImageEntry object can be created as the data is received, but then a separate call to that object would be required to actually create the visual representation of it when needed?In the past -- which apps quite a bit simpler -- I've simply mapped all the data during the XML parsing to dynamic objects that act only as containers for the data, which is then passed to a different object to create the visual representation of it...
I'm having problems with my usual eval methods of creating objects to read off dynamic values programmatically using concatenation. I've found the set command doesn't seem to work with objects that are dynamic....
Code:
function createobject(item){
//create it and store something in it
set ("_root.item"+item.stored, "data storage test for item "+item);
}function checkobjects(){
for (i=1;i<5;i++){
checkit=eval("_root.item"+i);
trace("_root.item"+i+".stored="+checkit);
[Code] .....
Running this produces the output of...
Code:
_root.item1.stored=undefined
_root.item2.stored=undefined
_root.item3.stored=undefined
_root.item4.stored=undefined
How to do this - basically I'm trying to load data, then use that to create dynamic objects and values within it, then I'm trying to work with those values by again using loops to read off the dynamic values during runtime. Obviously if these were "fixed" variables, then it would be easy, problem is that its impossible to use the new Object() command with dynamic names!
Previously I've used this:
Code:
checkit=eval("_root.item"+i+".stored);
trace("value is "+checkit);
Is it my imagination, or was this stuff a lot easier to do in AS1?
Is there another way to work with movieclip classes than attaching them from the library?For instance say that I have a textbox class that extends the movieclip class. Puts it on the scene and then I'm free to work with it from the class as I want.But inside this class I check if I need a scrollbar. If I do, then start a "sub-class" and create a scrollbar. I can have a movieclip in the library and attach it and have a new class on it. But what I want to do is write something like this
var clipScroll = createEmptyMovieClip("scrollBar", 3)
clipScroll = new com.texts.text_items.ScrollBar
the problem is if I do like this the class that I start is just an object. I can't trace where it is, I cant create a movieclip inside it and trace where that is.
If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased.With 45 rotation, the size becomes about 143x143 (from 100x100).Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't.At the moment I am doing this:
var currentRotation = object.rotation;
object.rotation = 0;
var normalizedWidth = object.width;
[code].....
I would like to be able to access all the components of say a Flash image gallery on someone else's site. I want to be able to find the images, image coordinates, action script code, audio files, video, etc. I do not want to manipulate these elements, I just want to view them and their related information.
View 2 Repliesdoes cached a bitmatp improve speed of vector object or bitmap object?
View 1 RepliesI'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData;
public var contrail:Bitmap;
private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
I am trying to paste a bitmap (any bitmap) onto the stage. I just get the box outline on the stage. I have imported several basic bitmaps into the library. I tried dragging and copying and pasting but I always just get the outline. I don't know if it means it can't be pasted or there is a setting to display it. If I copy the same bitmap and paste into word for instance I do see the image.
View 3 RepliesI would like to display an Image using a Bitmap as source. I've looked at many websites and most suggest something akin to this but somehow it still doesn't work....img1 works fine... But img2 doesn't load for some reason.
private function onComplete(event:Event):void{
bytes = event.target.data;
img1.source = _bytes; /*this last bit works*/[code]....
i just wanna know how I display a bitmap that I exported for action scriptinially i tried this
var myBitmap:NameOfTheClass = new NameOfTheClass(40, 40);
addChild(myBitmap);
i got a error saying that is not possible to implicitly convert a BitmapData to a displayObject (or samething like that) so a changed the base class of the exported bitmap to flash.display.Sprite, but didn't work, the same error was generated.
Is there any way to test if a display object has been added to the display list?
View 9 Repliescan I resize a display object (container) without its contents (children) are resized?
For example, in the following code when I resize the green square, red is also resized. I wanted to resize only the green.
ActionScript Code:
import flash.display.Sprite;
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xff0000);
[Code].....
In Photoshop there is a tool that lets you adjust the levels of an image. I'd like to be able to do the same thing. I've seen examples online that show the levels but they are for each individual color channel (red, green, blue or alpha or CMYK) but not a combined view like in Photoshop Input Levels (see below).Also, as a bonus is there a way to find the best shadow and highlight input level settings, basically the settings the Auto level button determines?Update:I think I'm closer but I'm not sure. Here is the method I pieced together. The first image is my results and the second is Photoshop results both analyzing the Google logo:Update 2:Ok I think I got it. The code is below. It's mostly working all the time, mostly. Additional credits:Photoshops results:
Levels method:
/**
* Get a histogram of the grayscale levels
[code].....
What's a simple way to detect if a display object is currently on the display list?
View 1 RepliesWhat are the maximum dimensions of a bitmap allowed to be loaded and displayed in Flash?
View 1 RepliesI imported a image file to my library and exported it for Actionscript. Which it created a new class that extends the bitmapdata class. Do I create an instance of that data and pass it to a sprite and add the sprite to the stage so I can display the image when I compile the file into a swf? Ive tried that and get an error saying that I need two arguments. I guess im just not sure what to do with the bitmapdata class.
View 1 RepliesIf you draw a movieclip (with a 3d rotation on it) to bitmap, eventlisteners will always dispatch rollout and rollover for that movieclip (on mouse over). A solution could be to set the matrix3d = null ,draw, and then apply the original matrix3d, but I can't do this in my project 'cause all clips is a 3d object to a parent 3d object that gets drawn to a bitmap every frame.
To see the bug, copy this example code into the first frame on the stage (CS4 flashplayer 10).
var bmp:BitmapData = new BitmapData(100, 100); //setup a dummy bitmap
var bmpContainer:MovieClip = new MovieClip;
bmpContainer.addChild(new Bitmap(bmp));
var box:MovieClip = new MovieClip;
addChild(box);
[Code] .....
Can you make one Bitmap Object (I'm using an external jpg) or something similar, and then display it many times simultaneously without creating a separate object each time?
Also, would they be easily removed or hidden?
I've got a little checkmark jpg graphic loaded here, but I'm not sure how to go about using it in many places at once.. I can only display it in the one place at any one time...
I'm thinking there might be a way to load the picture once, then use its bitmapData elsewhere in new display objects somehow, without needing to reload the image over and over?
It's my understanding that a display object cannot be in the display list more that once.So if I add something to the stage shouldn't a second addition of the same object replace the first? for instance:
[code]...
there should now only be one "myDisplayObject" on the stage.