ActionScript 3 :: How To Redraw Shape Using Only Code

Jan 8, 2012

My question is: how do I redraw a shape using only code? Short comment on the task itself. I've an eventListener, which grabs clicks on stage and stage resizes. Both execute the same function - redrawEvents(evt:Event). The stage contains a number of blocks, which represent certain events. On each redraw these blocks are repositioned, and also lines (which represent connections between events) are drawn.

Any way to reposition all the blocks, but I got stuck on redrawing lines. I'm using a single shape to hold all the lines, because lines, unlike blocks, are not interactive. Since the whole point of the application is creating sets of interconnected events, I have to modify this shape every time a new block is created, which also calls redraw function. Here's the code I use to modify the shape

stage.addEventListener(MouseEvent.CLICK,redrawEvents);
function redrawEvents (evt:Event) {
var lines:Shape = new Shape();
lines.graphics.lineStyle(2, 0xFFFFFF, .75);
lines.graphics.clear();
for (var k:int = 0; k < connections.length; k++){
lines.graphics.moveTo(eventList[connections[k][0]].x + 50, eventList[connections[k][0]].y + 50);
lines.graphics.lineTo(eventList[connections[k][1]].x + 50, eventList[connections[k][1]].y + 50);
} addChild(lines); }

However, whenever the shape is modified, it still leaves the 'older versions' of itself on screen, and i don't want that. I tried to create and delete instances, various type conversions.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Take Vector Art To Shape Code?

Nov 6, 2009

Is there a way to take a vector graphic and translate it to ActionScript 3 shape code? I'd like to be able to create a graphic in Illustrator, and then instead of embedding or importing it into Flash, I'd like to draw the shape with AS3 shape code.

View 6 Replies

ActionScript 3.0 :: New Shape - 1046: Type Was Not Found Or Was Not A Compile-time Constant: Shape

Nov 30, 2009

ActionScript Code:
package {
import flash.display.MovieClip;
public class Base extends MovieClip {
public var baseHP:int = 50;
var newRect:Shape = new Shape();

1046: Type was not found or was not a compile-time constant: Shape. 1180: Call to a possibly undefined method Shape. What does it mean by "undefined method"? I am somewhat of a newby, so sorry if there are any stupid errors

View 1 Replies

Professional :: Adding Shape Hints Makes Shape Disappear In Between Frames

Jun 22, 2010

Whenever I add shape hints to a shape tween the shape disappears in the between frames. I am using CS5 on Vista. I using files from [URL]to practice.

View 2 Replies

ActionScript 3.0 :: Draw The Shape Of A Existing Movieclip Which Is Irregular Shape?

Oct 11, 2011

need to draw the shape of a existing movieclip which is irregular shape.

View 2 Replies

ActionScript 3.0 :: Draw The Shape Of A Existing Movieclip Which Is Irregular Shape

Oct 11, 2011

need to draw the shape of a existing movieclip which is irregular shape.

View 1 Replies

ActionScript 1/2 :: Shape Colliding Another Shape, Not The Rectangleof A Movieclip?

Jul 9, 2009

Id like to know if there is a way to do a shape hitTest.Not as the normal hitTest would do, but shape colliding another shape, not the rectangleof a movieclip.It can be in a movieclip.

View 23 Replies

Redraw Lag With Large 3D Scene

Nov 9, 2009

I am building a scene which consists of 1 main mc containing all the elements in the scene. Inside this mc some of the layers are pushed back in Z space to create a parallax effect and on the main timeline the scene mc scrolls in relation to
the mouse position (much like this ) the scene mc is 5953px by 1716px and all the mcs contained inside consist of line drawn vector illustrations imported from illustrator. My problem is that when the scene is scrolling, every so often there is a delay were the scrolling slows down. It eventually catches up with itself causing it to jerk back to its original speed. When I test the movie and turn on redraw regions I notice that flash is having trouble redrawing some of the mcs.

I have tried optimising my mcs, turning cache as bitmap on the static ones and even replacing some of the static ones with bitmap versions but none of these seem to solve the problem. I was wondering if there is a solution to this or any other steps I can take to ease up on the redraw Also I am having a problem with the mcs breaking up as the scene scrolls, is there a way I can easily apply an anti alias to them?

View 1 Replies

ActionScript 3.0 :: Redraw Is Leaving Artifacts?

Jan 16, 2012

Im pretty sure Im not going about this the right way... but anyways If you move to the left or right, the front triangle is supposed to have its points redrawn to locked positions inside the player, but for some reason it is leaving artifacts and Im sure its some redundancy in my script that I don't see...here is the script executing the redraw...

Actionscript Code:
function reDrawFront() {  var temp=frontLockright.localToGlobal(new Point(0,0));  var temp2=frontLockleft.localToGlobal(new Point(0,0)); 

[code]....

View 2 Replies

ActionScript 3.0 :: Redraw Sprite After ComboBox Changes

Apr 7, 2010

I want my sprite to redraw when the information in my comboBox is changed but I cant figure out how to do it. I've tried a variety of things with no luck so I've deleted my attempts and below is my code how I want it to work with the exception that how it is now just draws the sprite on top of the other one instead of replacing it (or resizing it??).

import fl.data.DataProvider; import fl.events.ComponentEvent;
var items:Array = [ {label:"Select your Waterway"},
{label:"Klamath at Orleans", data:klamath_orleans},
{label:"Scott at Fort Jones", data:scott_fort_jones},
{label:"Redwood Creek", data:"redwood_creek_hwy299"},
[Code] .....

View 1 Replies

ActionScript 3.0 :: Instantaneously Force A Redraw?

Dec 7, 2011

Is there a way to instantaneously force a redraw?  I am using a Timer and I want it to update the screen between frames.

View 3 Replies

Flex :: Force Redraw On Component?

Jan 10, 2011

I have an app w/ a login screen. When the user hits "enter", the state changes to "login" & a child component is triggered to load (though the child stays invisible at the moment). The child contains many functions that the user needs upon logging in (ie their screenname & settings are retrieved from a database). The following is included in 'Parent':

<local:comp id="localComp" includeIn="login" includeInLayout="false" visible="false"/>
<mx:Button label="login" click="currentState='login'"/>
<mx:Button label="logout" click="currentState='Default'"/>

My problem is when a user logs out (state changes to 'Default') & then logs back in (state changes back to 'login') the child doesn't get "triggered" again & the functions w/in the child don't reload. Is there a way to force my child to refresh?

Note: While it would be easier to just move the child's functions to the parent it is complex...I moved these functions to the child to make it easier to follow

UPDATE: I even tried adding an "exitState" to my state:

<s:State name="login" exitState="removeElement(localComp)" />

This doesn't work either, as I get an error: "RangeError: Index 0 is out of range."

UPDATE: Even though you are allowed to call a child's function from a parent, my problem is that the child needs to be "created" in order to not show errors. It makes no sense to me why the flex team would make something like removing & adding children so complicated.

View 3 Replies

ActionScript 3.0 :: Redraw Swf, Goes Blank Where It Has Been Overlapped?

Aug 16, 2009

i am doing a project to learn as3 as it's fun to do and useful for creating mockups in (interaction designer).
The project consists of a banner swf containing generated stuff and another swf which is the main project. In the banner i have mouseover textfields with an explaining text that is shown when moving the mouse over movieClips. The problem is that when a textfield overlaps the main swf (they are stacked with css, z-index), the main swf doesn't redraw the previously covered area resulting in a white patch where the textfield was shown.

One way of doing it i guess would be to on each MOUSE_OUT function, where the textfield is removed from stage by removeChild(textThing), also connect to the main swf by localConnect() and somehow force it to redraw.

View 1 Replies

ActionScript 3.0 :: Redraw Multiple Bitmaps From XML Data?

Dec 27, 2009

I've been trying to get the hang of working with bitmaps.  I can redraw them using draw(), and after some trouble managed to redraw an externally loaded file using copyPixel().  What I can't do is redraw several images loading from XML.[code]...

View 3 Replies

Flex :: Adobe - Redraw When Manually Scrolling?

May 11, 2010

I have two columns: the left one is a Canvas containing an mx:Tree and the right one is a Canvas containing a Canvas (to allow for scrolling) of some custom Sprites that go along with the tree nodes on the left. I made the right Canvas scrollable (horizontal and vertical) and I want the vertical scroll to also scroll the left Canvas so that the tree nodes line up with their representations on the right. The scrolling portion works fine and when I embed with wmode="window" there are no problems. Unfortunately, the customer requires dynamic HTML to overlap the Flash at times and when using wmode="opaque" or "transparent", there are issues. The scrolling still works, per se, but Flash does not seem to redraw either Canvas appropriately. The Canvases become out of sync and artifacts often remain on the right side.I catch a scroll event on the right column and update the scroll position on the left column like so:

public function onTimelineScroll(scrollEvent:ScrollEvent):void {
leftColumn.verticalScrollPosition = rightColumn.verticalScrollPosition;
}

[code].....

View 1 Replies

Flex :: Spark TitleWindow Bad Redraw On Dragging?

May 11, 2010

I have a problem with redrawing in flex 4. I have a spark titleWindow, and if i drag it faster, it looks like it's mask is one frame late after the component. it's easily visible with 1pixel thin border, because it becomes invisible even with slower movement.

You can try it here (what is not my page, but it's easier to show you here than uploading example):[URL]..

If you move in direction up, you see disappearing top border. in another directions it's not that sensitive as it has wide shadow, and it's not very visible on shadow. On my computer i see it on every spark TitleWindow i have found on google, although it's much less visible with less contrast skins, without borders or with shadows.

View 2 Replies

Flex :: Force Component To Redraw It's Focus?

Mar 23, 2011

Suppose I have a component and want to change it's focus color at runtime. Here's an example for you (I've excluded any buttons and such to prevent component from losing it's focus, cause in that case it changes it's color perfectly):

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()">
<mx:Script><![CDATA[
private function init():void {

[Code].....

What do I want: How to make this focus to be redrawn without magic (I've tried all the methods, starting with "validate", I've tried calling updateDisplayList() on entire application, I've tried to call styleChanged .

View 1 Replies

Flex :: Correctly Redraw UIComponent By ValidateNow()

Apr 20, 2011

I'm removing an UIComponent but parts of it last being visible. It redraws only when I move mouse around or something. I tried to do validateNow() on its parent, tried to do setTimeout(validateNow, 100) but it doesn't help. When I call it by setTimeout it seems these artifacts shown more rarely but it doesn't solve a problem in all cases. Please guide me someone to read about validateNow(), how it works and how to make these things correctly.

The code is below:

protected var bubble: SpeechBubble;
// creation
bubble = new SpeechBubble();

[Code]....

View 3 Replies

Actionscript :: Redraw Hundreds Of Particles In Flash?

May 17, 2011

I am just starting to learn flash/actionscript 3 and decided to code up a simple particle simulator.The very initial design simply involves filling the screen with a buncha particles which scatter away from the cursor if you were to click.This works, but is a bit unresponsive. I am using graphics.drawCircle() to draw the particles, and each particle is inherited from Sprite.

Listener for mouseclick event:

private function mouseClick(e:MouseEvent):void
{
trace("click");
var now:Date = new Date();
trace("Before: "+now.getTime());

[code]....

How should I make this more efficient? I plan on doing collision detection and other physics interactions later, and this is already a bit slow even without the hefty number crunching code I intend to add later.

View 2 Replies

Javascript :: Forcing Redraw Of Flash Content In IE 7?

Dec 19, 2011

I have an flash swf on a page loaded with object/embed tags.

<object width="565" height="300" >
<param name="movie" value="/swf/Sample-Elf.swf">
<param name="wmode" value="transparent">
<embed src="/swf/Sample-Elf.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" width="565" height="300"></embed>
</object>

I need to be able to start/stop or reload this swf with purely javascript as I don't have access to the source swf file to add any actionscript.I figured the easiest way to pull this off is by removing the element and replacing it forcing a redraw with would hince reload the swf movie. Though ie seams to cache the flash element and pretty much look over any updates I make to the embed/object tags and keeps right on going.So how do I force IE to redraw/update a flash element on a page?

View 1 Replies

Flash :: Force The List To Redraw In Case?

Dec 27, 2011

When the list item label is changed, the list doesn't redraw until I hover the mouse over changed item. I've tried invalidate & redraw but they didn't work:

//myList is an instance of mx.controls.List component
myList.getItemAt(0).label = 'New Label';
myList.invalidate();
myList.redraw(false);

How to force the list to redraw in this case?

View 1 Replies

ActionScript 3.0 :: Dynamic BitmapData / Redraw / Invalidation?

Jan 12, 2011

I am working on a character terminal emulator. Glyphs are 8x8, 1bit raw bitmaps There are 256 glyphs in the palette. A character buffer is a grid of single bytes, referencing the various glyphs in the palette 256 glyph palette.Essentially a character buffer is a big blocky bitmap, only instead of pixels it has glyphs.Rendering the character buffer is a rather quick, self-contained job in theory. The memory required is very low and the execution time is similar to a hardware blit.

It is redundant to have a 'back buffer', i.e. a BitmapData to store a rendering of the character buffer. it's too costly in memory and way overkill for the complexity of what is being rendered.I want to know if it is possible to feed data to the video memory similar to the way it is done with SampleDataEvents. I do not want to store a redundant BitmapData object since some of these character buffers are huge and rarely need to be rendered all at once. They only need to be 'invalidated', i.e. they only need to update small portions at a time as they are 'exposed'.

I have searched high and low and read the manual a million times. The closest thing I could find were the stage.invalidate() and RENDER events, but they don't seem to give me a rectangular area to feed data to. I also tried extending Bitmap, but could not figure out how to override it's default behaviour of reading pixels from a BitmapData.An example of what I'm doing can be found when using GTK's DrawingArea widget and it's 'expose' events, used for very fast rendering.

View 2 Replies

ActionScript 3.0 :: Redraw Invalidation With ScrollRect Vs GetBounds?

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

ActionScript 3.0 :: Redraw An Object Before Calling Another Function?

Oct 6, 2011

So I have  chess like game, where I place my piece (c[i]) on the board, the piece automatically gets pushed into a square, and the AI starts (computerplay function)
 
The problem is that the AI (computerplay function) is running before the piece get pushed into the nearest square, leaving it hanging oddly over the board for 3 seconds while the computer thinks.
 
Is there some way to force a redraw before the calling the computerplay function?
 
xxx=Math.round((c[i].x-80)/38.5);
yyy=Math.round((c[i].y-92)/35.5);
c[i].x = xxx * 38.5 + 80;

[Code].....

View 5 Replies

ActionScript 3.0 :: Redraw Components On Parameter Change?

Mar 17, 2010

I have a component I have built in AS3 that takes a parameter which is likely to change with each instance of the component on stage. ie. the parameter will be different on frame2 to what it was on frame1.

The problem I am having is that flash will not recognise the change of parameter and redraw the component unless I do something like giving it a different instance name or putting it on a new layer. I find this very puzzling as I have the exact same component in AS2 and am not required to perform these actions to get it working.

View 2 Replies

Professional :: Change The Shape Of A Shape?

Oct 19, 2010

using the shape tool you can draw basic shapesthen using the subselection tool you can re-shape them by relocating certain points

What i want to do is create a tween whereby one of the points is movedthe problem is you have to convert to a symbol first and after you have done that you cant change the shapes shape.so how do i go about using a motion tween to change the shape of a shape?

View 1 Replies

Actionscript :: Flex Forcing Smaller Redraw Regions

Jul 13, 2010

I've got a small action-script chart, that's meant to be live updating, and also be able to support more than 10000 points of data. The way it's currently set up it doesn't need to redraw the whole chart if the new line we wish to add doesn't extend that chart's boundaries. Yet it does, the redraw regions show the whole chart as being redrawn as opposed to the single line i need to add. When the chart gets a new piece of data from the javascript it does the following.(some stuff has been stripped for clarity.[code] Is there any better way to do that, that won't redraw the whole screen? Is my coding pattern wrong for this type of update?

View 1 Replies

Flex :: Capture Flash / Redraw DisplayObject Event?

Dec 20, 2010

I'm trying to capture the redraw event for some MovieClip / Sprite objects that are in a Scroll area.Ideally, should be able to capture the event when Flash Player itself redraws the objects as can be seen with "Show Redraw Regions" in FP Debug.I've tried to use the Event.RENDER to capture this, but it even fires when the object is not visible / redrawn.

View 1 Replies

ActionScript 2.0 :: Removing Redraw And Settings From Context Menu

Mar 17, 2008

I'm using Actionscript 2.0 and I want to remove the Show Redraw and Settings menu items from my context menu - has anybody managed to do this yet??

View 5 Replies

ActionScript 3.0 :: Flex Forcing App Children To Redraw On Resize?

May 19, 2010

Is there a simple way to force all the child components of a Flex app to redraw when that app is resized?

For instance, I have a HDividedBox with percentHeight and percentWidth set to 100. On the left hand side of the divided box is a data grid and on the right side is a number of text inputs. The divided box is not added to the view stack until after the user logs on.

If I resize the app before the HDividedBox is added then the box takes up the full size of the app, whatever that may be. However if i resize the app after the box appears then the box retains the same dimensions it does when it was first added.

I would have expected that on the resize of the app then all the children would redraw (the application component itself appears to).

View 1 Replies







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