Color Tweening using Drawing API
Hi, I have a function that draws a shape. The color value can
be passed in as a parameter. I have called this function quite a
few times. All of the objects start off the same color.
I want to know how to randomly make each one switch color
immediately (like a light bulb, on, off)), over a set period of
time
Anyone any ideas?
Thanks
When you say bezier curves I presume you mean quadratic
bezier curves that the native drawing API uses? Or are you
converting spline data or cubic beziers to native drawing api
parameters from the .net data in flash as well? Some of these
calculations can take time for large data sets if done with an
emphasis on highly accurate approximations in flash.
Here are a bunch of questions I could think of:
How are you receiving the drawing data? are they coming in
via xml, for example? (Are you sure its the drawing activity that
is slow and not the parsing of data). Are they coming in as 5000
points or incrementally over time?
Are you clearing and redrawing from the start of drawing
sequence each time (it seems not, but just wanted to check)?
Are you drawing to a single Sprite's graphics context or are
you creating layered Sprites to hold subsequent portions of the
rendered drawing?
when you say 'rotating the cursor' along the path...are you
animating anything as well? How are you checking the point
intersection - bounds based? or against a rendered shape?
The last thing I can think of is: are you using some of the
advanced lineStyle settings? some of these settings can slow things
down substantially with large and complex drawings, whereas other
settings are much faster. Also even specifying the default settings
can be slower than not specifying them. But again, this is usually
only noticeable for very long drawing paths.
Your post doesn't have enough information to advise directly,
but perhaps if you answer those questions it might provide us some
clues.
Similar Messages
-
Select area through Drawing API
Hi,
I am working on Custom Kitchen Project and want to know if
some one take a picture and import into the flash project then I
just want to know how user can create or draw a random shape to
select certain area, by using Drawing API
Example is below Just wana know how he did the selection
part?
http://www.century21.com/search/map.jsp?wheresync=City,%20State%20or%20Zip
Thanks in advance.
Freddywhat's the problem? your like displays a basic use of the
drawing api. -
font color=red Create/Modify forms and triggers through C++ using OPEN API
<font color=red>
Dear brothers/sisters<font color=darkblue>
<br><br>
Please help us to find the linking problem.
<br>
We have to add PRE-FORM trigger to many FMBies. We have thousants of FMBies. So opening one by one is difficult. For this we are using OPEN API and BORLAND C++. We have coppied all header files from D:\orant\FORMS60\API.
But there is a link error. Here is the snippet.
<br>
<font color=red>
<br>#include <stdio.h>
<br>#include <stdlib.h>
<br>#include <malloc.h>
<br>#include <d2fctx.h> /* Forms API context */
<br>#include <d2ffmd.h> /* Form module header file */
<br>int main (int argc, char *argv[])
<br>{
<br>d2fctxa ctx_attr;
<br>d2fctx *ctx;
<br>d2ffmd *form;
<br>text *form_name;
<br>/* Check arguments */
<br>if ( argc != 2 )
<br>{
<br>fprintf(stderr, "USAGE: %s <filename>\n", argv[0]);
<br>exit(1);
<br>}
<br>/* Create Forms API context */
<br>ctx_attr.mask_d2fctxa = (ub4)0;
<br>if ( d2fctxcr_Create(&ctx, &ctx_attr) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error creating Forms API context\n");
<br>exit(1);
<br>}
<br>/* Load the form module into memory */
<br>if ( d2ffmdld_Load(ctx, &form, argv[1], FALSE) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Failed to load form module: %s\n", argv[1]);
<br>exit(1);
<br>}
<br>/* Get the name of the form module */
<br>if ( d2ffmdg_name(ctx, form, &form_name) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error getting the name of the form module\n");
<br>}
<br>else
<br>{
<br>/* Print the name of the form, then free it */
<br>printf ("The name of the form is %s\n", form_name);
<br>free(form_name);
<br>}
<br>/* Destroy the in-memory form */
<br>if ( d2ffmdde_Destroy(ctx, form) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error destroying form module\n");
<br>}
<br>/* Close the API and destroy context */
<br>d2fctxde_Destroy(ctx);
<br>return 0;
<br>}
<br>
<font color=darkblue>
<br>
The compilation is success. But there is a link error. Please help us to find the problem.
<br><br>
Here is the error Message.
<br>
<font color=red>
<br>Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
<br>FIRST.CPP:
<br>Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
<br>Error: Unresolved external '_d2fctxcr_Create' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2ffmdld_Load' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2ffmdgt_GetTextProp' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2fctxde_Destroy' referenced from D:\API\FIRST.OBJ
<br><br>
<font color=darkblue size=4>Could you please help us.......<br><font color=red>
Dear brothers/sisters<font color=darkblue>
<br><br>
Please help us to find the linking problem.
<br>
We have to add PRE-FORM trigger to many FMBies. We have thousants of FMBies. So opening one by one is difficult. For this we are using OPEN API and BORLAND C++. We have coppied all header files from D:\orant\FORMS60\API.
But there is a link error. Here is the snippet.
<br>
<font color=red>
<br>#include <stdio.h>
<br>#include <stdlib.h>
<br>#include <malloc.h>
<br>#include <d2fctx.h> /* Forms API context */
<br>#include <d2ffmd.h> /* Form module header file */
<br>int main (int argc, char *argv[])
<br>{
<br>d2fctxa ctx_attr;
<br>d2fctx *ctx;
<br>d2ffmd *form;
<br>text *form_name;
<br>/* Check arguments */
<br>if ( argc != 2 )
<br>{
<br>fprintf(stderr, "USAGE: %s <filename>\n", argv[0]);
<br>exit(1);
<br>}
<br>/* Create Forms API context */
<br>ctx_attr.mask_d2fctxa = (ub4)0;
<br>if ( d2fctxcr_Create(&ctx, &ctx_attr) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error creating Forms API context\n");
<br>exit(1);
<br>}
<br>/* Load the form module into memory */
<br>if ( d2ffmdld_Load(ctx, &form, argv[1], FALSE) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Failed to load form module: %s\n", argv[1]);
<br>exit(1);
<br>}
<br>/* Get the name of the form module */
<br>if ( d2ffmdg_name(ctx, form, &form_name) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error getting the name of the form module\n");
<br>}
<br>else
<br>{
<br>/* Print the name of the form, then free it */
<br>printf ("The name of the form is %s\n", form_name);
<br>free(form_name);
<br>}
<br>/* Destroy the in-memory form */
<br>if ( d2ffmdde_Destroy(ctx, form) != D2FS_SUCCESS )
<br>{
<br>fprintf(stderr, "Error destroying form module\n");
<br>}
<br>/* Close the API and destroy context */
<br>d2fctxde_Destroy(ctx);
<br>return 0;
<br>}
<br>
<font color=darkblue>
<br>
The compilation is success. But there is a link error. Please help us to find the problem.
<br><br>
Here is the error Message.
<br>
<font color=red>
<br>Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
<br>FIRST.CPP:
<br>Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
<br>Error: Unresolved external '_d2fctxcr_Create' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2ffmdld_Load' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2ffmdgt_GetTextProp' referenced from D:\API\FIRST.OBJ
<br>Error: Unresolved external '_d2fctxde_Destroy' referenced from D:\API\FIRST.OBJ
<br><br>
<font color=darkblue size=4>Could you please help us.......<br> -
Drawing an image in excel sheet using HSSF API
Hi All,
Can any one please help me.
I am facing an issue with excel sheet while drawing image using HSSF API.
I am doing autofit for all the cells i have added. But the image is stretching along with the expanded cells.
I want the autofit option to work but the image should not stretch. Image should be the same size as is but the cells must expand.
Thanks in advanceHi Santosh
You can export the report to PDF
Else you can manually copy the logo\image to excel sheet.
Hope it will help.
Regards
Kultar -
FP9 vs. FP10 Drawing API
Hey all,
I created a program that uses the drawing API to draw a
graph of some river level data downloaded from the web. Basically,
it will download a TAB delimited file, parse it, and draw a graph
of the past 7 days using solid rectangles. The graph draws on by
setting some timeouts and tweening the rectangles on so they slide
up from the bottom. When it runs well, it appears as if the graph
is flowing on from left to right. There are a few different graphs
that the user can choose from, and each time, the program reaches
out to the web so it can grab the most recent river level data.
When I first programmed it, I was using Flash Player 9 and it was
working well. Now that I am publishing with Flash Player 10, after
a few graphs are drawn, the drawing starts to slow down so that the
flowing on is very rough, and after they have looked at maybe 7
graphs, it almost comes to a stop. The graph still appears, but it
seems to hang as it starts to draw, and then appears all of a
sudden. So, the program is not updating as the graph draws on, but
it happens in the correct amount of time. There are a few different
methods being used here, with the timeouts and tweens, but since it
seems to degrade over time, I feel like it must be something with
the drawing API. I am removing the old graphs completely, as far as
I know, and only one is drawing at a time. The thing that is
puzzling is that it works very well with FP9, but not with FP10. I
was hoping someone had some thoughts as to differences between the
two that would manifest themselves in a way I am describing. Of
course I realize that I could just publish with FP9, but there are
a few reasons I want 10 to be used that 9 will not help with.
Thanks...
- Bthanx,
that was useful, your solution worked fine...
I still have a little problem:
I tried different actions to be performed as the tween ends:
1. remove the object (parent.removeChild)
2. set it as invisible and put it on an array for later async remove
4. add it as a child of another sprite
I then put on the stage 10 instances of M1 and let them all tween,
everytime one of those instance ends its tween (and performs one of the final action
described above) there's a little delay that freezes for a little time all the other tweening instances....
I thought that the removeChild was the delaying part but I saw that also setting visible=false
brings the same delay...
I was then wondering if there's a smart way to handle this and let everything run smooth...
thanks -
Drawing API animate??
Hi guys, i have only recently started with Drawing API, and
im getting the hang of it. But i was wondering if it's possible to
tween the lineTo method??
for example, im rounded rectangle at runtime, but i dont want
it to just " appear " , say i wanted it to " draw it's self "
like tween the outline first, then fade in the fill.
is that possible? if so, what code would i use to animate the
drawing process?
Thanx guys.Sketchsta,
> Hey David, i only just saw your post after i replyed..
uum,
> could you give be the basis of how to use the
setInterval ?
The setInterval() function can be run in more than one way.
The basic
way is to provide it two parameters: a) another function to
run, and b) a
time interval at which to run this other function. That's
really all there
need be to it.
> cuz i only used it once, but i didnt know how to stop
it, it
> kept going forever, till my com was struggling.. then i
found
> clear() ... now my comp has no problem, but i still cant
> stop the line.. anyway, off the point...
That's not off the point. ;) Sounds like that's exactly what
you need
to figure out now. The clearInterval() function stops a
particular
setInterval() loop. How does it know which loop to stop? The
answer is,
you provide clearInterval() with a number. This works a bit
like those
lines at the deli section where you "take a number" and they
eventually call
it.
setInterval() provides a return value, just like many (but
not all)
functions. The getTimer() function, for example, returns a
number that
represents how many milliseconds have passed since the Flash
movie began.
The isNaN() function returns a Boolean (true or false) value
that tells
whether a given value is "not a number." Well, setInterval()
returns a
value that indicates the number of its latest usage. The
first time you use
setInterval(), it sets up a scenario whereby it repeatedly
calls the
function you pass it at the time interval you pass it. This
is the first
such scenario, and so the number it returns is 1. The next
time you use
setInterval(), it sets up a second scenario -- calling some
other function
you provide, or the same one -- and this time it returns 2.
The third time,
3, and so on.
Conveniently, you don't have to keep track of this. You can
store the
return value of setInterval() in a variable and use the
variable as a
parameter to clearInterval().
> could you give me an example of how to set it up?
var id:Number = setInterval(drawingFunctionHere, 30);
In the above line, an arbitrarily named variable id (which
will be a
number) is set to the return value of setInterval(), which in
this case
calls an arbitrarily named function, drawingFunctionHere
every 30
milliseconds. Whenever you see fit (such as when your drawing
is finished,
and only you'll know that), you can call clearInterval() and
pass in that id
variable.
clearInterval(id);
That stops the repeated call to drawingFunctionHere(). Of
course, the
first time around, you could use clearInterval(1) -- but
again, there's just
no reason to keep track of the interval numbers yourself. You
can re-use
that id variable as often as you need.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design." -
Low level disk access using win API libraries
Hello All,
One of my project requires "low level access to the drives (usually pen Drive)' for analysis. I think this is possible using WIN API functions, i tried to read using kernal32.dll but i am unable to complete the task effectively, since i dont have sufficient exposure to text oriented languages. Basically i need to read the memory as it is stored, just like stream of bytes. Could any one guide me how do i proceed inorder to get rid of this.
thank you.Unfortunately no. You cannot mix both high and low level on the same screen. You'll probably have to draw it out yourself and capture user input, unless you're willing to use textboxes.
Or.. i suppose you can try using customItems for all your "coloring" instead? -
How to add a polygon to mapviewer using Javascript API
Hi,
I am using JavaScript API for the MapViewer.
Using redlining tool, my application allows user to draw polygon onto the map.
I would like to have union, difference and intersect tools. I know the back end logic can be done using using JTS or SDO_Union, SDO_difference, and SDO_intersection. but how do i display the result polygon on the map? Note that I am not going to store the polygon in the database.
Thanks for any ideas.Hi,
If I understand well you are using Oracle Maps. User do some redlining, then you somehow makes FOI polygons. Then you get the coordinates of the polygons and send them to the back-end where you can use spatial functions and get the coordinates of the new polygon.
You can store those coordinates in i.e. hidden input field on page (if you use JSF it is very simple) and then use JavaScript to parse them and Oracle Maps API to create new FOI polygon and add it to mapviewer object. One disadvantage of this concept is that reloading of page (submit) is necessary.
Branislav -
Flattened circles in drawing api
Hi Guys
When I use the drawing api to create circles, sometimes they
appear flattened, as if the edges had been sliced off. Below is the
code. Can anyone tell me how to fix this?
// extends UIComponent
public function CircleThing ()
super();
mouseChildren = false;
buttonMode = true;
//resetCircle();
base = new Sprite();
baseOver = new Sprite();
label = new TextField()
label.autoSize = TextFieldAutoSize.LEFT;
label.multiline = true;
label.wordWrap = true;
label.width = 108;
label.x = -52;
addChild(base);
addChild(baseOver);
addChild(label);
addEventListeners();
//label.border = true;
//label.borderColor = 0xff0000;
//addChild(label);
//resetCircle();
//addListeners();
// This function creates the blue circle
public function drawCircle(_name:String=null):void
trace ('NavCircle drawCircle');
var myFilters:Array = [new
DropShadowFilter(5,135,0x000000,0.15,5,5)];
//base.name = _name;
base.graphics.clear();
base.graphics.beginFill(_color, .9);
base.graphics.drawCircle(0, 0, defaultDiameter/2);
base.graphics.endFill();
base.filters = myFilters;
// added djg draw overCircle
baseOver.graphics.clear();
baseOver.graphics.beginFill(_overColor, 1);
baseOver.graphics.drawCircle(0, 0, defaultDiameter/2);
baseOver.graphics.endFill();
baseOver.visible = false;
}I'm not sure about tutorials, but read up on the
flash.display.Graphics class. Your Canvas has a graphics property
and that's where you draw. Here's how to draw a red circle 50
pixels in diameter:
graphics.clear();
graphics.beginFill( 0xff0000 );
graphics.drawCircle( 100, 100, 25 );
graphics.endFill();
You should do most of your drawing in the updateDisplayList
function - just override it (in a Script block if using
MXML). -
Graphics using graphic API are drawn below the loaded content created using Flash authoring tool
Here is my problem.
I am developing a Analog Dial component. Here , I am
extending UIComponent and loading a swf file generated using Flash
CS3 authoring tool ( the swf basically has the circle and needle)
and adding the loaded content as child of Dial class.
Next I use Graphics API to draw the major and minor ticks on
the dial.
As mentioned in the curveTo method of flash.display.Graphics
class documentation (
http://livedocs.adobe.com/flex/201/langref/index.html),
if you are using graphics api and also loading content created
using the flash authoring environment the vector graphics will be
drawn underneath the loaded content.
Well , Is there any way to make the graphics appear on top of
the loaded contents?It appears that this may be accomplished more easily if I do something similar to the StrobeMediaPlayback implementation. Looking at the StrobeMediaPlayback source code it looks like Adobe has done something a little different than their ControlBarPlugin, placing the controlbar and root media element inside separate MediaContainers and then adding those containers to the display list. Is this recommended over using the frameworks ParallelElements? If so, is communication between the control bar and root media element still a matter of just updating the target reference via metadata?
-
Dots are appearing on characters after created PDF through *.dwg file using AutoVue API
Hi,
I created PDF's through *.dwg file using AutoVue API 20.2.2. I observed in more zoom of PDF, every character or line has dots. At the same time on second page of PDF drawing lines are thicker that first page of PDF.
Please kindly help on this, how to remove dots and drawing lines are published same as on first page.
Thanks,
SivaAs with any format that does not support zoomable line thickness, the output is dpi dependent
Imagine the DPI impact on a PDF is similar to the DPI on an image, except you can zoom into the lines, they look smooth (it is vector) but the position for the specific points is not as accurate as it should
So it all boils down to how are you generating the PDF? -
How to best optimise Shapes produced by Drawing API?
I'm building an iPad app that allows a user to draw shapes using the finger. Simple logic:
holder = new Sprite();
addChild(holder);
// then based on touch events
holder.graphics.moveTo( e.stageX, e.stageY );
holder.graphics.lineTo( e.stageX, e.stageY );
// etc
What I see is that the SWF on the desktop runs at constistent 25fps. When run on the iPad it slows down significantly once you start drawing, usually as slow as 4fps.
I tried adding
var matrix:Matrix = new Matrix();
holder.cacheAsBitmapMatrix = matrix;
holder.cacheAsBitmap = true;
but that seems to have no effect. Am I looking in the right place? Are there better ways to optimise this?
Thanks
StefanI spent a bit of time fighting with this one as well. It seems that no matter what I do through Flash's drawing API I just can't seem to get good quality from my objects.
From what I can tell the only way to achieve quality is to create the shape in Photoshop first and have it inside of Flash as a bitmap. I also set cacheAsBitmap and applied a cacheAsBitmapMatrix to the containing MovieClip, although I'm not sure if it made a difference since it apparently already applies this for Bitmap objects...I think.
Anyways try that and you'll see substantially better quality.
It would be nice in future release to see vectors utilize the iPhone's vector capabilities. -
Drawing API within attachMovie instances
Hi I am trying to get curveTo to work within attachMovie
created instances where the _x coordinate of each movie lines up
with the _x coord plus width of the previous. Each movie is a
square of differing dimensions.. All works fine apart from the
curveTo which whatever i try does not come out as expected (all
curves should look like the first one but scaled according to the
dimensions of its containing square). I must be misunderstanding
the relative coord settings or something but i have tried every
combination. Can any one help? I'm at the tearing my hair out
stage.
SWF can be viewed at:
http://www.widecombefair.com/draw/spiral3.html
and the fla file at
http://www.widecombefair.com/draw/spiral3.fla
also see code below
Many thanks in advanceHi Rothrock
I will have a go without using attachMovie. Will it make a
difference?
I appreciate I could draw the squares and draw the curves
straight onto the stage, but I arrived here from component classes
where I had a square class and a curve class and used
createclassobject to get them on stage (I also had a 3rd class for
the square border). If I can get this basic approach to work then I
will have something from which to build.
With luck stwingy's answer will fit the bill but I really
want to understand how the empty movieclip and its parent are
related in terms of the drawing api. I can't fathom the ligic.
Many thanks for your help so far. -
I am creating a car driving game in Flash 8. Im using the Drawing API to make the car leave tracks as it moves using the following method:
lines = {}
_root.createEmptyMovieClip("pen", 10)
pen.lineStyle(10, 000000, 6)
pen.moveTo(this.car._x, this.car._y)
_root.onEnterFrame = function(){
pen.lineTo(this.car._x, this.car._y)
segments += 1
name = "line"+segments
lines[name] = [this.car._x, this.car._y]
A requirement of the game although is that the tracks fade after 2 - 3 car lengths and I was not sure if this was possible using the method I have already implemented.
Any help would be much appriciated!to adjust the rate of fade, change the 2nd parameter in the setInterval() function and the 2nd parameter in setTimeout. in fact, if you want a rapid fadeout, remove the setTimeout and just call startfadeF(pen):
lines = {};
var dep:Number = 0;
this.car.prevX = this.car._x;
this.car.prevY = this.car._y;
_root.onEnterFrame = function() {
var pen:MovieClip = _root.createEmptyMovieClip("pen"+dep,10+dep++);
pen.lineStyle(10,000000,6);
pen.moveTo(this.car.prevX,this.car.prevY);
pen.lineTo(this.car._x,this.car._y);
this.car.prevX = this.car._x;
this.car.prevY = this.car._y;
setTimeout(startfadeF,2000,pen);
segments += 1;
name = "line"+segments;
lines[name] = [this.car._x, this.car._y];
function startfadeF(pen:MovieClip){
pen.fadeI = setInterval(fadeF,50,pen);
function fadeF(pen:MovieClip){
pen._alpha -= 3
if(pen._alpha <= 0){
clearInterval(pen.fadeI);
pen.removeMovieClip()
updateAfterEvent(); -
Drawing API - Remain on component
I'm trying to build a component which uses the drawing api to
draw half circles radiating up from the bottom. I draw the circle
with the center point on the bottom of the component. The drawing
api is happy to draw the circle with the bottom half of the circle
below the component being drawn on. How can I avoid drawing outside
the component which the graphic property is being used?atta707 is correct with that information. If you don't want
to worry about drawing within the boundaries you can add a clipping
mask to the component.
var clipper:Sprite = new Sprite();
clipper.graphics.clear();
clipper.graphics.beginFill(0);
clipper.graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
clipper.graphics.endFill();
Now assign this to the mask property of the component and add
it as a child of the component:
mask = clipper;
addChild(clipper); // I don't remember off the top of my head
if this step is necessary
Put this code in your component's override of
updateDisplayList(). You can create the clipper in the component's
override of createChildren() if you don't want to create it in
updateDisplayList().
Maybe you are looking for
-
Reg. the creation of new data type in ECC 6.0
Hi All, I have a requirement wherein I need to create a new data type INT with length as 4. Is there any way that we can add create a new data type. Thanks in advance, Durga.
-
Regarding error in XI File to IDoc scenario
Hi, when i was doing file 2 idoc scenario i got this error "Unable to convert sender service to an ALE logical system". please resolve my issue as early as possible.
-
Monitoring Cisco UCS Manager via HP System Information Manager 7.1 (SIM)
I am working with a customer to configure HP System Information Manager 7.1 (SIM) to monitor their Cisco UCS Manager. The customer is looking to monitor the following: - CPU Utilization on manager, blades, servers, etc... - Memory utilization - Netwo
-
Missing messages: Selection completed
Hi We are extracting data from R/3 to BW using custom extractor which is used function module. Data is coming to BW and we could see same number of records as R/3 in PSA .The problem is in the detail tab of RSMO under extraction missing messages Mi
-
Hi all I'm very new to Aperture, but not so new to editing digital photographs. Previously I used Photoshop entirely and had my own kind of manual workflow. But that was very slow going taking months to edit a small amount of photo's and distributing