is it possible to transform a bitmap/bitmapData class

Is there a way I can transform the content of a class to a bitmap and use this image as many times as I want. In my case, I create this class

public class CreateRow_Col extends Sprite {


                    private var bgArray:Array = new Array();
                    private var myContainer:Sprite = new Sprite();
                    private var _Pat1:BitmapData = new Pattern1();




                    public function CreateRow_Col() {
                              var bgClip = new Bitmap(_Pat1);
                              var i:int = 0;
                              var j:int = 0;
                              while (bgClip.x < stage.stageWidth) {
                                        bgClip = new Bitmap(_Pat1);
                                        while (bgClip.y < stage.stageHeight) {
                                                  bgClip = new Bitmap(_Pat1);
                                                  myContainer.addChild(bgClip);
                                                  bgClip.x = bgClip.width * i;
                                                  bgClip.y = bgClip.height * j;


                                                  j++;
                                        }


                                        j = 0;
                                        i++;
                              }
                              addChildAt(myContainer,0);
                    }

and then call it from the mainClass of the FLA

                         private var bf:CreateRow_Col = new CreateRow_Col();
                    private var bf2:CreateRow_Col = new CreateRow_Col();


                    public function MainClass_Test() {
                              bf.x = 50;
                              addChild(bf);
                              bf2.x = 150;
                              bf2.y = 350;
                              addChild(bf2);
                    }

But if I want to do like 500 instances of the class that will make the CreateRow_Col calculate 500times scene and fill it 500 times? or it will not?

and even if it is not possible to make a class for bitmap and use this image as many times as you want.

Looks like you need to use the class graphics capabilities, particularly beginBitmapFill() method.

Here is the documentation of the Graphics class:

http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/display/graphics. HTML #beginBitmapFill)

But first, you class CreateRow_Col will not work. You are referring to the scene in the constructor. Stadium is available ONLY when object is placed on the display list, UNLESS you have the reference to the scene when running.

Anyway, if your need is to tiles with the same BitmapData Sprite - you don't need to jump through all these hoops. Try this code:

package
{
          import flash.display.Sprite;
          import flash.events.Event;

          public class CreateRow_Col extends Sprite
          {
                    public function CreateRow_Col()
                    {
                              addEventListener(Event.ADDED_TO_STAGE, draw);

                    }

                    private function draw(e:Event):void
                    {
                              removeEventListener(Event.ADDED_TO_STAGE, draw);
                              graphics.beginBitmapFill(new Pattern1(), null, true, true);
                              graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                              graphics.endFill();
                    }
          }
}

The use is the same as you showed in MainClass_Test.

Post edited by: Andrei1

Tags: Adobe Animate

Similar Questions

  • Is it possible to transform a clip of 15 frames per second in a clip of 30 frames per second through adobe first?

    You are not sure if it is possible, but is it possible to transform a clip of 15 frames per second in a 30 fps clip?

    Depending on what your after you might also go this route:

    Film

    1. in the project Panel, right-click (Windows) or Ctrl-click (Mac OS) the clip for which you want to change a property.

    2. Select Edit > film.

    3. Select the options you want, and then click OK

    More info here:

    http://helpx.Adobe.com/en/Premiere-Pro/using/modifying-clip-properties-interpret-footage.h tml

    Peter Garaway

    Adobe

    Premiere Pro

  • Is it possible to convert a bitmap to a Sprite?

    Hello, do someone knows if it is possible to convert a bitmap to a Sprite?

    I tried to cast on a sprite, but it does not work.


    The reason why because if understood that you can not use the addChild on a bitmap option.

    Sprite(yourbitmap).addChild(someOtherSprite);

    Is there a workaround for this or is it just not possible

    Kind regards

    Chris.

    No, you cannot convert it to a Sprite, but you can just paste it into a new Sprite, as well as anything else. Same thing really:

    var bmpHolder:Sprite = new Sprite();

    bmpHolder.addChild (yourBitmap);

    bmpHolder.addChild (someOtherSprite);

    etc...

  • Is it possible to create a bitmap 'dynamic '?

    I need to create a bitmap "on the fly" with a text on this subject.

    Depending on the situation and the State of the application, I need to generate an image with text and perhaps a few images on this subject. The problem is that I do not really want to show this picture on the screen, so the image must be built "off screen" and not to the user.

    This generated image will not contain images of resources or a saved image or something like that, so

    I'll be writing the text on a colored background, maybe do some picture on it and then save this image as a bitmap.

    So I guess what I need to know is how can I go do a bitmap which we tell just contains "Hello World" on a black background?

    Is this possible?

    Thank you.

    Take a look at the net.rim.device.api.ui.Graphics class. Special attention to the static method Graphics.create.

  • Is it possible to transform a power devices or not at a specified temperature?

    The unit lights up and warms at a given temperature. It must be turned off until it cools to a specified temperature lower, where it restarts and heat again. The unit must oscillate between these two temperatures for a period of 40 minutes.

    Yes its quite possible.  you need a way to read the temperature of the unit when the power is on and off. and some means of controlling the power of the device.  The rest is easy.

  • Is it possible to transform a .exe in a .vi again?

    I'm responsible for trying to make a .exe file (published on LabVIEW) selfpopulate an Excel file with the data, he gets from the trial. To do this, I would need to take a look at the block diagram to see what happens in the devil; However, it's an .exe file and we do not have source code?

    Is it possible to get around this other than re-engineering the entire VI?

    Thanks in advance.

    No, sorry! You need the source code to be able to view/reconstruction of the VI.

    (While I'm not 100% sure, you might be able to see the block diagram if debugging is enabled on the executable when it was built and then sign in using "operation-> Application Debug or Shared Library... »)

  • Transform the bitmap at run time (vectors) lines?

    After you draw a few lines and moveTo, lineTo, how to convert their bitmap so that they do not lag, if there are many. Thank you.

    as a movieclip will exist with this code.  use:

    var i = 0;

    onMouseDown = function () {}

    _root.createEmptyMovieClip ("mcLine" + i, i);

    {with (_root ["mcLine" + i])}

    lineStyle (6,0,100,true,"normal","none","round",1);

    }

    xPointA = _xmouse;

    yPointA = _ymouse;

    pressing = true;

    };

    onMouseUp = function () {}

    This ["mcLine" + i] .cacheAsBitmap = true;

    i ++ ;

    pressing = false;

    };

    var pressing: Boolean = false;

    onMouseMove = function () {}

    If {(urgent)

    with (_root ["mcLine" + i]) {}

    moveTo (xPointA, yPointA);

    lineTo (_xmouse, _ymouse);

    xPointA = _xmouse;

    yPointA = _ymouse;

    }

    }

    };

  • Is it possible to transform the handwritten signatures in text?

    someone help me please read these signatures makes me crazy!

    No, not out of the box there is no way to achieve what you are looking for.

  • Cannot be implicitly cast to Bitmap in class?

    Hi all

    I created a dynamic ResourceLoader class that loads all the necessary assets in an internal dictionary, store the Loader.content (which is a bitmap object) indexed by a string name. Everything works fine and dandy when I clone() the bitmapdata and cast to an object of display, but when I try to do the same thing and assign setStyle, I get this weird error:

    Type coercion failed: cannot convert flash.display::Bitmap@c479439 to class.

    How can this be? If everything is not derived from class?

    So, instead: (only the lines below)

    [Embed (source ='... / media/actionbar_def - click.png "")]
    private var defClick: Class;
    in ctor...
    setStyle ("downSkin", defClick);

    Now, I'm doing it:

    mLoader.load (new URLRequest(I'.. / media/actionbar_def-click.png')));
    After loading...
    mImages ["defClick"] = mLoader.content;
    during the construction of button...
    setStyle ("downSkin", DisplayObject (new Bitmap (Bitmap(mImages["defClick"]).bitmapData.clone ()));

    Does anyone have any suggestions on where I'm wrong?

    Thank you.

    ZenSeven

    I thought about it, even if it does not solve my problem.

    A 'class' is that actionscript is a static class - while Bitmap@c479439 is an instance of Bitmap. So it makes sense why it cannot convert!

    I love being a n00b ActionScropt!

  • How to draw text bordered on Bitmap usgin class Graphics?

    Hi guys.

    I'm drawing text on a line graph.

    Here is the example.

    The text color is black. Border is white (edge of letters).

    How to draw like this?

    Thanks in advance.

    If you are interested in a vaguely similar effect, but without all the subtle shadows, I have a suggestion. Draw the white text, several times, gap between the nominal position of a pixel or two in different directions and then draw the text in black at the nominal position. The idea is that white copies create an enlargement of each letter which becomes an overview when you draw the black letter on it. You may need to do this a letter at a time, allowing more space between the letters, rather than draw the entire chain at the same time.

  • It is possible to add a single tag 'class' to an element of Muse?

    I need to know if in the interface of Muse, that I can put a class label in the divs because I want to create a special javascript to perform a special action for this 'class '.

    Adding a graphic style or paragraph to something creates a class with the name of the style.

    I hope this helps.

    David

    http://creativemuse.co

  • Changing Bitmap color using colorTransform

    I have a bit of a problem where I have a function that takes a ColorPickerEvent. I'm a "loaded bitmap" colorTransform to a movieclip to the selected color, but for some reason any, it does not

    // colour 
    function setColourFor(e:ColorPickerEvent){
              var image:InteractivePNG = getChildByName(type) as InteractivePNG; // movieClip
              var bitmap:Bitmap = image.getChildAt(0) as Bitmap; // loaded PNG
              
                   var c:ColorTransform = bitmap.transform.colorTransform;
              bitmap.transform.colorTransform = new ColorTransform();
              c.color = e.color; // colorpickerevent
              
              
              bitmap.transform.colorTransform = c;
         }
    

    the color of the bitmap image does not seem to change.

    It works but if I had to define movieclip colorTransform (var image)

    I want to emphasize that the Bitmap contains PNG's with transparency

    Hello

    Change the last line of your service for:

    bitmap.transform.colourTransform (bitmap.bitmapData.rect, c);

    the first parameter is a Rectangle object defining the area of the bitmap image that affects the transformation

  • How to get bitmapData from an Image control

    Hello

    Can someone help me understand this. I know I can use the "embed" tag to get the MXML compiler to associate a .jpg file with a class and then create a BitmapAsset object - and exit at his 'bitmapData '.

    I am loading files from a server dynamically .jpg using the Image control. I don't think that the Image control has a property 'bitmapData '. How to get a BitmapAsset of an Image control?

    Those of you guys informed here searching to help noobs - ty much in advance.

    the Image control was a parameter called the content that you can access only if the crossdomain.xml allows...

    This parameter is a Bitmap and contains the Bitmap bitmapData class...

  • Blend two bitmaps in a new BitmapData, using a blend shader

    Hello

    I have:

    Two images of the same size as bitmap BitmapData.

    I want to:

    A largest BitmapData, with the two images mixed in a slope like that...

    1st row: [BitmapData 1]

    2nd row: [BitmapData BitmapData 2 1 mixed up on the top of the page, alpha 0.1]

    Row 3: [1 BitmapData with BitmapData 2 mixed up on 0.2, alpha]

    Row 4: [1 BitmapData with BitmapData 2 mixed on 0.3, alpha]

    ....

    Line n: [BitmapData [2]

    ------------------------------------

    I can easily implement this using the standard alpha blending. However, I would use my own algorithm of mix, and do it with actionscript is too slow. Therefore, I would like to implement the merge as a Pixel Bender shader function. I came here to make a function that works with the standard alpha blending and no shader custom involved:

    protected function createGradientLookupTable( bitmapAtBlend0:BitmapData, bitmapAtBlend1:BitmapData, steps:uint ):BitmapData {
        var gradient:BitmapData = new BitmapData( 256, bitmapAtBlend0.height * steps );
        var translationMatrix:Matrix = new Matrix();
        var alphaTransform:ColorTransform = new ColorTransform();

        for( var row:int = 0; row < steps; row++ ) {
            gradient.draw(bitmapAtBlend0, translationMatrix);
            alphaTransform.alphaMultiplier = row / ( steps - 1 );
            gradient.draw(bitmapAtBlend1, translationMatrix, alphaTransform );
            translationMatrix.translate( 0, bitmapAtBlend0.height );
        }

        return gradient;
    }

    This method works. At first, I did a fusion of shader to Pixel Bender, just to check if I can load into my Flash Builder project and operate standard alpha. This filter works in Pixel Bender 2.5:

    <languageVersion : 1.0;>
    kernel BlendHCL
    <   namespace : "com.yadayada";
        vendor : "Yada Yada";
        version : 1;
        description : "Blends colors using hue chroma luma";
    >
    {
        input image4 src1;
        input image4 src2;
        output pixel4 dst;

        parameter float alpha;

        void
        evaluatePixel()
        {
            float4 pixelBottom = sampleNearest(src1,outCoord());
            float4 pixelTop = sampleNearest(src2,outCoord());

            dst = pixelBottom + ( pixelTop - pixelBottom ) * alpha;

        }
    }

    Don't mind the description etc., currently it's supposed to only must accept a parameter alpha and mix using the standard alpha blending. Just to see I can make it work. Here is my Actionscript code is modified to use the custom mixer, this code does NOT work:

    protected function createGradientLookupTable( bitmapAtBlend0:BitmapData, bitmapAtBlend1:BitmapData, steps:uint ):BitmapData {
        var gradient:BitmapData = new BitmapData( 256, bitmapAtBlend0.height * steps );
        var translationMatrix:Matrix = new Matrix();
        var bitmap1:Bitmap = new Bitmap( bitmapAtBlend1 );
        var blendShader:Shader = new Shader( blendShaderCode );

        for( var row:int = 0; row < steps; row++ ) {
            gradient.draw(bitmapAtBlend0, translationMatrix);
            blendShader.data.alpha.value = [ row / ( steps - 1 ) ];
            bitmap1.blendShader = blendShader;
            try {
    //            gradient.draw( bitmap1, translationMatrix ); // doesn't work
                gradient.draw( bitmap1, translationMatrix, null, BlendMode.SHADER ); // doesn't work either
            }
            catch( e:Error ) {
                trace( "Error happened! " + e.message ); // No error messages reported
            }
            translationMatrix.translate( 0, bitmapAtBlend0.height );
        }

        return gradient;
    }

    This code change does not report the errors, it is just as if the alpha is always 1.0. The second image completely replaces the first. This is the expected result if the shader blend is not implemented at all. All the example code that I find using a blend shader, mixes just the colors directly on the screen, not in a new Bitmap or BitmapData object. Can anyone help?

    PS: Debugging in Flash Builder 4.7 and inspect the variables indicate that I have an object valid shader (blendShader).

    It seems to me I couldn't do it as I wanted. Instead, I created a shader that could create the gradient while only once and actually an object instance ShaderJob in Flash to do the job. Here is the code of the shader which results from:

    
    
    kernel BlendHCL
    <   namespace : "com.yadayada";
        vendor : "Yada Yada";
        version : 1;
        description : "Blends colors using hue chroma luma";
    >
    {
    
        input image4 src1;
        input image4 src2;
        output pixel4 dst;
    
        parameter float imageHeight
        <
            minValue:     1.0;
            maxValue:    64.0;
            defaultValue: 2.0;
            description: "The height of the images that will be blended in the gradient result";
        >;
    
        parameter float steps
        <
            minValue:      2.0;
            maxValue:   1024.0;
            defaultValue: 64.0;
            description: "The number of shades in the gradient";
        >;
    
        void
        evaluatePixel()
        {
    
            float2 sampleCoord = outCoord();
    
            sampleCoord.y = mod( sampleCoord.y, imageHeight );
    
            float4 pixelBottom = sampleNearest(src1,sampleCoord);
            float4 pixelTop = sampleNearest(src2,sampleCoord);
    
            float alpha = floor( outCoord().y / imageHeight ) / ( steps - 1.0 );
    
            dst = pixelBottom + ( pixelTop - pixelBottom ) * alpha;
    
        }
    }
    
    

    The following Actionscript code:

              public function createGradientLookupTable(bitmapAtBlend0:BitmapData, bitmapAtBlend1:BitmapData, steps:uint):BitmapData {
                   var shader:Shader = new Shader( blendShaderCode );
    
                   shader.data.imageHeight.value = [ Number( bitmapAtBlend0.height ) ];
                   shader.data.steps.value = [ Number( steps ) ];
    
                   shader.data.src1.input = bitmapAtBlend0;
                   shader.data.src2.input = bitmapAtBlend1;
    
                   var result:BitmapData = new BitmapData( 256, bitmapAtBlend0.height * steps );
    
                   var shaderJob:ShaderJob = new ShaderJob(shader, result);
    
                   shaderJob.start( true );
    
                   return result;
    
              }
    
    
    

    It worked. The shader still conducting a standard alpha blending, but now I go to do the actual shader of coding.

  • Is it possible to implement a 4-bit image?

    Hello!

    I have some files exotic image, with one 16-bit channel. Currently I am able to display them in flex by translating this 4 channel 8 in a bitmapData and using a shader. But the problem is that it takes twice the memory, that should be (16 bit to 32 bit...).

    I'm wondering is - it possible to somehow extend the BitmapImage class, and override the important methods to somehow solve this problem?

    Thx for the help!

    Hello

    I think documentation is clear:

    A type of BitmapData object is stored as a buffer of 32-bit integers.   Each 32-bit integer determines the properties of a single pixel of the bitmap.

    I checked on the Flash Player JIRA and some people have the same problem:

    https://bugs.Adobe.com/jira/browse/FP-441

    Sign in / register and vote in favour. Let Thibault Imbert ( Flash Player Product Manager) know what your needs are by posting a comment.

    And if as many people as possible to vote for this issue in JIRA, which would give him a big boost.

    Kind regards
    Karl.

Maybe you are looking for

  • The music won't add to my library of Apple's music

    Im trying to add songs to my library but when I search a song before and add it, it does not appear in my library even though it says it has added and whenever I press the cloud icon to download it, it keeps all loading and never actually starts to d

  • Disk HARD drive deleted in the Finder and now appears

    My macbook pro has two hard drives, SSD 120 gb and 500 GB HARD drive. The HARD disk is a data disc and has been accidentally deleted from the Finder. I can't locate this drive anywhere in the computer.  It is a new drive and was only recently added t

  • I forgot the lock screen 6 code numbers on an iPhone5

    I forgot my screen lock code.  I can't login to icloud information but when I connect to itunes and follow the process in recovery mode it gives me only the ability to update and restore to the factory setting.  Then it ends, your device is not eligi

  • Switch time delay between 3 and back!

    Hello I'm trying to figure out how can I switch between three cases in a case structure for a while between each switch. For example: I have three cases in a structure of case (case) {0,1,2} where zero is the default case. What I want to do is to sta

  • No icons & don't right click, XP.

    I have no icons on my desktop, when I right click, nothing happens.  I have a taskbar, but when I go to start, then programs, it is empty.  I tried the system restore, but I does not work.  My 'C' drive is also empty, but under properties shows 3/4 f