ActionScript 3.0 :: Drawing Class That Is Passed An Image API Optimization

May 12, 2011

I'm building a drawing class that is passed an image, and it will run an ENTER_FRAME drawing lines of varying thicknesses and gradients to look as if it is being hand painted. All works well and is doing just what I'd hoped. My problem is after a while, it starts to hammer the CPU. I can understand why it could be taxing, but I thought the drawing API was meant to be rapid? Is there a way I can optimize the process? I am only using 1 enterframe, and it seems to get progressively worse the more lines are laid down. Does the Flash Player not render them as Bitmap after they are drawn? I'm just trying to work out why the more lines are drawn the heavier the swf runs.

View 7 Replies


Similar Posts:


ActionScript 3.0 :: Drawing In Bitmap Optimization?

Feb 11, 2010

today i started some particle generator class that will move particles over the stage via drawing in a Bitmap. Everything works well with low amount of particles, lets say 1000, but for my surprise when i added 10 000 particles the frame rate dropped drastically. And i am saying that since i made the same particle generator using MovieClips instead of drawing in Bitmap, the performance test i run on both classes showed that the Bitmap class with 10K particles on my PC works in around 10-12 FPS, and the MovieClip variation in around 20-21 FPS with the same amount of particles. The particles are identical and both classes are using linked list system to move the particles. So the only logical conclusion is that something is not right with the drawing function.

Code:
private function drawParticles(e:Event):void{
// clearing the _pZone Bitmap of the previous data
_pZone.bitmapData.fillRect(_pZone.bitmapData.rect,0);
_pZone.bitmapData.draw(_blankMc);

[code]...

View 1 Replies

Flex :: Where In Framework Graphics Object Passed Around To Achieve Drawing

Oct 23, 2009

I'm trying to understand how the Flex framework draws objects (Button, Label, Image, etc.). The Button class seems to draw itself by addChild()ing its ProgrammaticSkin. However, where in the framework is the Graphics object being passed around in the hierarchy to achieve the drawing. I want to get to the level of 2D API.

View 1 Replies

ActionScript 3.0 :: Class Variables Passed Into Class With Labels?

Apr 28, 2010

What is the correct syntax to initiate a function in a class similar to constructing an associative array? I have a function that's custom variables is ballooning out and I'd like to label them in the call for sanity sake.

currently:
myClass.myClassFunction("hello world",999,0xff0000);
desired:
myClass.myClassFunction(myText:"hello world",myNumber:999,myColor:0xff0000);

and the class itself for reference:

class com.myClass {
public var myText:String;
public var myNumber:Number;

[code]....

View 6 Replies

ActionScript 3.0 :: Pencil Tool - Drawing Above A Image But The Drawing Is Below The Picture

Nov 9, 2010

i've tried to simulate a pencil tool, for drawing above a imagem, but the drawing is below the picture. How fix it?

[Code]....

View 3 Replies

Actionscript 3 :: Anonymous Class Passed As Variable To Function?

Jun 20, 2011

In c++ if I have a function that takes a class I have defined elsewhere as a parameter like so:void moveto(CPoint2D point) { ... }I can invoke it and pass along data to it like this:moveto(CPoint2D(0,0));basically creating the object and invoking it's constructor to be passed to the functionIs there an equivalent to this in AS3?if I have a function like this:function initialize(min:Point, max:Point): void { ... }how do I do something along the lines of :initialize(Point(0,0), Point(10,10))This throws an error im assuming because it thinks I want to cast something to a point and the notation I found earlier to do something similar only seemed to work if using the basic Object class.

View 1 Replies

ActionScript 3.0 :: Flash - Class Constructor Event Occurs Before Variables Are Passed In?

Jun 17, 2010

I'm having a little trouble with my move to as3, (surprise surprise huh?) Basically when I create a movieclip, I wan't to pass some values into it, like so:

Code:
var menu=new Menu();
menu.x=50;

[code].....

View 2 Replies

ActionScript 3.0 :: Variable Storing Whether The Player Is Selected To Be Passed Back To The Actual Grid Class

Feb 16, 2009

I'm trying to make a game that is turn-based and allows players to first be selected, then click on a grid square to move there. However, I can't get a way for a variable storing whether the player is selected to be passed back to the actual grid class. I want the grid class to have an event listener that when the grid is clicked on, it will move the player there only if the player is selected. But whenever I try to declare a global variable either inside the grid class or even a document class or even access properties of the character class I'm trying to move I get errors.

View 5 Replies

ActionScript 2.0 :: Tween Class If Moved Mc Passed Point Start Another Tween

Jun 21, 2006

Now I am using the Tween Class to move some boxes in my movie, now I can move the first mc and then another mc after the first tween has finished with onMotionFinished but I was hoping someone could help with how do I start the second tween when the first mc has passed a certain _x coordinate. ie starting the second mc moving while the first tween is still moving.

View 1 Replies

ActionScript 3.0 :: Convert A Drawing From SWF To Image/PDF?

Jan 20, 2009

in AS 3.0. The requirement is, user needs todraw something and take a screenshot or in the PDF format fromflash swf by clicking a Save button[Save button will be in the sameflash file]. Is it possible in AS 3.0 with out any plug-ins?

View 6 Replies

ActionScript 3.0 :: Masking An Image With Drawing Api?

Jun 3, 2010

I would like to reveal an image by drawing over it with the mouse. The drawing part is not a problem but I don't succeede with masking the image with the drawing. Here is my code:

Code:
var myImage:theImage = new theImage(); //linked image from the library
var canvas_mc:MovieClip = new MovieClip();

[code].....

View 3 Replies

ActionScript 3.0 :: Drawing A Simple Shape In Class?

Oct 13, 2009

This is my first meeting with the Shapes; which don't seem cooperating, at all. Following is the Class code:

Code:
package
{

[code]......

View 2 Replies

ActionScript 3.0 :: Export The Image That Drawing In The Application?

Mar 10, 2009

how can i do export the image that drawing in the application (swf file) ontime . i 'm design the flash application that you are drawing , switching the brush style and font and .. but i don't know how can i save the image that draw in .

View 1 Replies

Make A Logo Or Image Appeares Like Some One Is Drawing?

Jul 13, 2009

I want to know how can I make a logo or image appeares like some one is drawing it. I am not sure that I have to break the image to multie peices then put them in a different time line or use Masking. Please help me with this.Here is a sample of a logo What I want to do is when the flash starts I want the drawing start with the bottom of the "P" and work its way around all the way ending in "G"

View 3 Replies

Actionscript 3 :: Embed Image Instead Of Drawing Graphics?

Mar 25, 2010

I've got a custom AS3 scrollbar that I need to modify. The scroll thumb (the draggable part of a scrollbar) is currently just done by drawing a rectangle. But I need it to look more like a real scrollbar. Not sure how to modify the below code to import/use a scroll thumb image:

scrollThumb = new Sprite();
scrollThumb.graphics.lineStyle();
scrollThumb.graphics.beginFill(0x0066ff);

[code].....

View 2 Replies

Flash :: Drawing Over An Loaded Image With Mouse?

Feb 16, 2011

I tried this way, but it doesn't draw on the image. Only if I tries to draw on right border (outside the image) it working.

private var oldX:Number, oldY:Number;
private var mode:String = "modeBrush";
private function onMouseDown(e:MouseEvent):void {

[code]......

View 1 Replies

ActionScript :: Drawing An Image In The Center Of A Shape?

Oct 20, 2011

I'm trying to draw an image in actionscript, I set it as a BitmapFill within a rectangle. The problem is that if I move the rectangle away from the origin(0,0), in my case I start drawing the rectangle at (20,35), the bitmap background doesn't follow along. The background is always drawn at (0,0) and then repeated, so I don't get a centered image but rather 2 halved images. Here's what my code looks like:

public class PageTileRenderer extends VBox
{
private var sp:Shape;

[Code]....

how to move the background fill origin. Or is there another solution to draw the image centered.

View 2 Replies

ActionScript 2.0 :: Drawing Lines Ontop Of An Image?

Oct 21, 2004

I have an empty MC. I want to draw lines that show on top of an image, but everything I try draws the lines below my image.This code is ran from the main timeline.This is my code so far.

Code:
_root.attachMovie("Audiogram_Chart","Show_Audiogram",100000); //this is my MC that will hold the graphics
_root.Show_Audiogram.attachMovie("Audiogram_Chart_Pic","Audiogram_Chart_Pic1",0); //this is a graphic with linkage
_root.Show_Audiogram._x=200;
_root.Show_Audiogram._y=200;

[code].....

View 1 Replies

ActionScript 3.0 :: Drawing Image In Its Original Size?

Sep 24, 2010

I started with a simple code to draw image. But i didn't get the expected results. What i got is:1) Image gets rendered but it gets scaled to high resolution and images gets distorted.So i wanted to draw image in its original size. If image size is 300*400 then i want to get it drawn in its original size.I google searched and try to find on how to achieve it. But no success.i want to know how to achieve this two things:1) drawing image in its original size, i don't want it to get scaled .2) how to set the size of display screen ? when i ran the code, the display screen(flash) cover whole browser page area ? I want to set the screen size to 450*300I am using Flash Builder 4 for making actionscript project. Here is the code :

Code:
package
{

[code].....

View 1 Replies

ActionScript 3.0 :: Drawing Application - External Class For Img Drag

Jun 14, 2011

I have this: [URL]. And would like to be able to stop drawing when dragging the added picture. The thing is, the drawing App is inside the fla. The Drag and Drop is an external class. What I think myself is I probably have to change the entire drawing code to an external class also, but then I'd still not know how to have those 2 classes communicate with each other.

Fla file:
PHP Code:
Draw API Marius Posthumus
import com.adobe.images.JPGEncoder;
Importsimport flash.display.Shape;
import flash.events.MouseEvent;
import flash.display.BitmapData;
[Code] .....

View 10 Replies

ActionScript 3.0 :: Saving Flash Drawing As Png Image To Database?

Sep 5, 2010

i've seen a few good examples to save out a png of the current flash display area from a webbrowser from a flash, such as:[URL]what they normally do is stream the image data through a png encoder to a web server somewhere and then decode the image data back to current webbrowser and then trigger the web browser SAVE function, by prompting user to select a path and file name to save, like a download.however, the difference is when you click that save button, you can save your png image directly to a certain location with a fixed file name, such as on your local computer:

View 5 Replies

Actionscript 3 :: Flash Upload Image To Drawing Canvas

Jul 18, 2011

im trying to create a online business card editor to learn flash again, one of the functionality im trying to achieve is being able to upload an image (jpg,png etc) and place said image onto a drawing canvas and then being able to scale the image and rotate the image and move the image around. can some one direct me to a decent tutorial for this kind of functionality.

View 1 Replies

ActionScript 3.0 :: Convert A Drawing From SWF To Image/PDF Without Any Serverside Program

Jan 29, 2009

I need a help in AS 3.0. The requirement is, user needs to draw something and take a screenshot or in the PDF format from flash swf by clicking a Save button[Save button will be in the same flash file]. Is it possible in AS 3.0 without any other server-side program?

This is very urgent. Please let me know whether this is possible or not.

View 9 Replies

ActionScript 3.0 :: Save Generated Drawing As Image File?

Jan 7, 2010

my saving part, where user select the necessary equipments & draw the connections. user are also able to generate the cable connection list in datagrid component.

I understand that flash doesnt provide saving to image technically, have seen some websites on the teaching & i tried to apply on my flash.

I have this error: 1061: Call to a possibly undefined method save through a reference with static type flash.net:FileReference. at source: fileRef.save(ba,"EMC"+i+".jpg");

I want to save the file locally inside harddisk, without any server script.

View 8 Replies

ActionScript 3.0 :: Get Custom Image And Which Should Be Dragabble Into Drawing Area?

Jun 10, 2011

Want to get custom image and which should be dragabble into drawing area...Below is the sample design which exactly i am looking for.

How to get custome image which i have rounded in red mark aslo i t should have input and output ports for ex:For TwoWaySplit.EU.OTHERS it contains IN as inputport and for Outputports:OTHERS and EU.same in the case with TwoWaySplit.US.OTHERS it contains IN as inputport and for Outputports:OTHERS and US and for main component it contains one input port and three output ports as shown in the diagram.Along with that node it should also display those ports and also when we move the node those ports should also move.

View 1 Replies

ActionScript 3.0 :: Moving A Shape Made By Graphic Class Drawing?

Oct 7, 2011

I drew a line (stepVoltage) in a fla using the graphics class. Once drawn, I want to move it to the right in an update function, but am having trouble. I tride just moving the line with statements like stepVoltage.x = newX; stepVoltage.y = newY; but this didnt work. Then I tried to delete the previous line and draw a new one with a clear () function (see below) but this blocked the next drawn line from showing up.

The code:

var stepVoltage:Shape = new Shape ();
stepVoltage.graphics.lineStyle(2,0x000000);
addChild (stepVoltage);

[Code]....

View 1 Replies

ActionScript 3.0 :: Apply Alpha To BitmapFill When Drawing Image To Stage?

Dec 4, 2009

I got this code from [URL]; it writes an image to stage as a way of tile it.

holidaytile is an instance of a Gif Image.
 
But I want to change the Alpha so that my top layer shows through it, and I can't seem to figure out how to do that.
 
import flash.display.BitmapData;var tile:BitmapData = BitmapData.loadBitmap("holidaytile");this.beginBitmapFill(tile);

[Code]....

View 3 Replies

ActionScript 3.0 :: Make Earser To Erase Only The Drawing Part Not The Background Image

Aug 13, 2009

how to make eraser tool my problem is i have two sprite one have backgroun image and other one have drawing by pen ,brush. 
 
now i want to make earser to erase only the drawing part not the background image .

View 6 Replies

ActionScript 3.0 :: Drawing Movie Clip To Bitmap Data - Image Looks Different Depending On Size?

Jul 13, 2010

I've written a class that iterates through all the frames of a movie clip and draws each one to a different bitmap. When I'm done, I should be able to iterate through the bitmaps and play them like a flipbook animation.If I draw all the clips to the same size bitmapdata, then everything looks great. But this is wasteful because now a lot of the bitmapdata's are bigger than they need to be (takes up more memory), and also causes problems because the hit tests don't look right.

So next I try to crop all the bitmapdata to be the smallest possible sizes. However, when I do this, there are subtle differences in the way the images look - the edges might look slightly darker in one frame than in another. When I line up all the images and play them back to back, it no longer looks the same way it originally did.I have no idea why the images look different, and have no idea how to work around this problem, I have tried many different approaches. I have tried using BitmapData.draw(), BitmapData:copyPixels(), and manually using BitmapData:SetPixel(), and all end up with the same result

View 5 Replies

ActionScript 3.0 :: Flash Image Won't Load From Class Referenced By The Main Class

Jul 25, 2011

why my image won't load when I have it's class referenced from the document class rather that being in the document class?

This produces no errors and the second class traces the note, but it doesn't load the image.

// ----- Main Class
package {
import flash.display.Sprite;

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved