IDE :: Graphics Class - How To Get The Current Shape

Dec 9, 2009

My application has a lot of dynamically loaded shapes... Now i am working on an interface to change the color properties of each Sprite. The first idea was a simple colorTransform. But afaik this only allows for transforming the existing colors. I also want to be able to define a NEW fill, i.e. GradientType.LINEAR / RADIAL.

SOLUTION 1: There may be an undocumented method to retrieve a graphics current points. With that i could loop through this Array with lineTo and redraw the current shape with the new solid / gradient fill.

SOLUTION 2: Create a newSprite with the chosen GradientType, size it by currentSprite.getBounds(); and then use newSprite.mask = currentSprite; to fake my desired fill... However, i am afraid of the impact this creates on the application as there may be more than 200 of these Shapes displayed on stage... overlapping each other.

View 6 Replies


Similar Posts:


Actionscript 3 :: How Does Graphics Class Work Without Needing To Extend Sprite / Shape

Nov 21, 2010

So I'm playing with a project where I want my class to be able to use the functionality of the Graphics class without needing to extend Sprite/Shape. My goal aside, I guess I'm confused as to how it works at all? It's methods don't seem to return anything, and since it's added as a child property of the Sprite/Shape classes , I can't seem to figure out what it's actually doing? It's also one of those classes that can't be instantiated.

At this point, I'm just plain curious. EDIT: I should provide more clear distinction of what I'm looking for as answer. I have read the documentation, but the documentation doesn't account for what AS3 is actually doing. I'm looking for educated guesses about the programatic relationship between Graphics and the the classes that use it.

View 1 Replies

ActionScript 3.0 :: Create A Shape Tween Of Two Graphics?

Nov 10, 2010

I have two bitmap graphics (bmp1, bmp2) already created with the BitmapData class using the contents of an object (label1):

var myBitmapData1:BitmapData = new BitmapData(150, 150);
myBitmapData1.draw(label1, matrix, null, null, null, true);
var bmp1:Bitmap = new Bitmap(myBitmapData1);

[code].....

View 5 Replies

ActionScript 3.0 :: Determine Current Pen Position In Graphics Object?

Jan 3, 2010

Is there a way to determine the current position of the pen in a graphics display object. Something similar to what is discussed in this thread but for AS3?

View 4 Replies

Actionscript 3 :: Flash : Read Data From Shape/graphics Object?

Dec 2, 2009

I am wondering if it is possible to get the data that is stored in a shape/graphics object in flash using actionscript 3?

In my project I would like to be able to draw a shape and then read all the points in that shape into my script. The reason for that is that I need go generate lines from those points that I later can use to check if my characters velocity intersects with any of them.

View 3 Replies

Actionscript 3 :: Call A Method From A Different Class In Current Class

Nov 4, 2010

I have a class, my document class, called SilkRoadTweeter. as I also have a class called User.as In my User class I need to call a method called nonce() I have tried this, trace(SilkRoadTweeter(root).nonce()); But I get the error, TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 4 Replies

ActionScript 3.0 :: Gettting Graphics Class Library?

Feb 10, 2010

have some good graphics libraries they can recommend for AS3? Need glass, textures, effects. The more the better.Using Astral but it is limited to 6 skinnable components. Looking more for something for "Advanced Primitives".CodeCanyon has some available, but remember I program for charity. No funds available.

Example: Tooltips that allow you to add a dashed-underline effect to the text. This would be an object that I can add to the project from the library, or reference an .AS file. It would automatically give the button an assortment of special appearance options (like a dashed-underline), and the hovering tooltip.

View 1 Replies

Actionscript 3.0 :: Add Graphics To Stage Using AddChild Inside Class

Feb 6, 2009

I'm have trouble attaching graphics to the stage from a class. I can do it on the timeline but the code doesn't work in a package.[code]this doesn't seem to work even if I import the picture in the package.[code]

View 1 Replies

ActionScript 3.0 :: Flash - Resuse A MovieClip (Class + Graphics?

May 21, 2010

I'm still in the process of completely moving from AS2 to AS3 and I felt confident how to do this in AS2 but AS3 is much slower to work with. I'm generally ok with all the syntax changes but I'd continued to put all the code into my FLA and not multiple classes. The primary reason for this has been because I still need to visually design how parts work and use that repeatedly in different pages and sections (and for web projects the big files are all images and data which I load externally anyway). Yet as projects get bigger and we have multiple team members we need to break it all up.

So I'm taking a simple use case of a button. I want to reuse one button style with a number of different states and functions contained within it. It has some methods I can use to pass it a new title or set properties like whether it is Active or Inactive, Selectable or Visitable and all of those properties define different responses when events occur. All that code lives in a class, but that's linked to graphics within a movieClip that are designed through the Authoring tool (visually not code). Thus I have a final button.swfHow then do I reuse that Button across other pages (in different FLAs) that are designed in the Authoring tool and where I can update the button without updating all of the finally composed SWFs of those pages. Using a shared library asset slightly makes sense but that still requires recompiling the project each time and does that bring through it's linked classes too?

It doesn't seem right to need to load in the button.swf repeatedly, shouldn't I be able to load it in once and then it's available to the whole application to just initiate it as I want it, eg. button1:myButton=new MyButton() , and set it's properties each time.Also I can envisage that since I'm doing this in AS3 I'll get errors because I want to instantiate something that a parent SWF is loading in. Then the issue I struggle to understand how to deal for AS3 is how to tell the buttons to target a _root function with individual parameters that I set in it upon creation

View 1 Replies

Actionscript 3 :: Positioning Flash Graphic Drawn With Graphics Class?

Mar 3, 2010

I'm using Flash CS3 to build a simple drawing application. When the user clicks a button, they select a particular movieclip. After clicking elsewhere on the stage, the clip is instantiated and added to the stage at the position of the cursor. I've also added the option of being able to click on the added clip and drag it around on the screen. And this all works fine.

The problem is that I also want to be able to dynamically draw and add objects to the stage via the Graphics class. Whenever I add objects in this manner, their x and y coordinates are always 0,0 no matter where I place them on the stage. This makes positioning these graphics very very problematic. I created a modified positioning function specifically for these dynamically drawn graphics and while it does "work", it feels less responsive than the positioning for movieclip objects. I'm still trying to optimize this function, but it seems to me that the ideal solution is for the graphics to have non-zero coordinates when placed in the middle of the stage like movieclip objects. Is there some "workaround" to achieve this?

View 3 Replies

ActionScript 3.0 :: Override A Shape Class?

Jul 4, 2011

I want to pass extra arguments to Shape class.

I think this can be done if I override a native Shape class.

how can I override ? Or How can I add a property to a shape?

View 7 Replies

Actionscript 3 :: Draw A Rectangle Using The Graphics Class, But Move The Registration Point?

May 18, 2011

I have the following code to create a Sprite with a rectangle in it:

container = new Sprite();
container.graphics.beginFill(0x00CCFF, .5);
container.graphics.lineStyle(1, 0x00CCFF);[code].......

The only thing is, I'd like the registration point to be in the middle (not the top left corner). Is there a way to set up the registration point in the middle of the rectangle, but still have the position of the rectangle be correct?

i.e. not moved over so that the top left corner of the rectangle is in the "middle" of where I want the rectangle to be...

View 1 Replies

ActionScript 3.0 :: Using The Shape Class To Create A Star?

Feb 7, 2010

Does anyone have an example of using code and the shape class to create a star shape?

View 1 Replies

ActionScript 3.0 :: [CS4] Instance Of A Shape Defined In A Class

Oct 14, 2009

I am trying to create a circle instance of FirstCircle class (by Milan Toth):

ActionScript Code:
package
{
import flash.display.Sprite;

[Code].....

I supposed the constructor would do all the work then. When testing the movie I get no error but no circle was displayed, trace statement put in the class constructor displayed the message ok. When I put the class code directly to the ACTION FRAME, it works fine.

what should I do to get the circle visible in the fla using the FirstCircle class?

View 6 Replies

ActionScript 3.0 :: Shape Not Appearing From Within A Class Method?

Nov 23, 2010

Im checkin out actionscript for basically first time kind of. Im now looking into creating shapes with actionscript at the same time learning the way actionscript handles oop.

So, here is my problem. Its easy to make a shape, but from within a method of a class, the shape will not appear on the stage. I try the same code snippet in my fla file, and it works fine. Here is the code im using:

The package file:

Code:
package com.adobe.shapelib {
import flash.display.DisplayObject;
import flash.display.Graphics;

[Code]....

why the shape is not appearing? As mentioned if i take the contents of the function named "circle" into my fla file directly, it appears as normal...

View 4 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 :: Get Current Class+method Name?

Jan 11, 2011

I wondered if there is a simple way I have have a snippet which traces the name of a method when called. I found className which is half-way there, but not something for the method... a 1-line trace(...) is what I'm after so I avoid typing the method name and leaving myself open to mistakes.This is for testing the order things happen, when I don't want to step through in the debugger.

View 2 Replies

ActionScript 2.0 :: Attach Graphics Instead Of MC Cause A Graphics File Size Is Relatively Small Than That Of A Graphic?

Apr 9, 2005

I was wondering about MC and hey can help to lag a game out. I set up an advanced class system so i don't have to use MC to simulate walls, all i use isthe x,y,width and height. Well anyway since i don't need MC anymore I was wondering if there is a way to attach Graphics instead of MC cause a Graphics file size is relatively small than that of a graphic, I think. If anyone could tell me thats true and show me a way to attach graphics that would be nice. I haven't tried it yet but maybe if I exported the graphic from the library imihgt be able to call its name, but it doesn't have an instance name so im stuck.

View 2 Replies

Actionscript 3 :: Get The Current Class Name From A Static Method?

Mar 29, 2011

i have to read the current class name inside a static method. For non-static method it's easy i just call getQualifiedClassName(this) but inside a static method this is off course invalid.

View 2 Replies

ActionScript 3.0 :: Where Is The Current Custom Class Initiated From?

Oct 16, 2009

A Custom Class can be initiated from an FLA or from another Custom Class. Is there a way to find at run-time, where is the current class initiated from?We can't use parent class before it has been added with addChild(thisClass), neither we can use root class to identify its originator. I believe, there should be a way to find it.

View 3 Replies

ActionScript 3.0 :: 1119: Access Of Possibly Undefined Property Graphics Through A Reference With Static Type Flash.display:Graphics.

Oct 8, 2009

i am trying to receive in my function as a parameter either a shape or a sprite and then access their graphics property, but this gives me an error:

Code:
public static function makeRect( obj:DisplayObject, ...
var g:Graphics;
if(obj is Sprite){

[code]...

//1119: Access of possibly undefined property graphics through a reference with static type flash.display:Graphics.

View 1 Replies

Actionscript 3 :: Flex To Create A Trapezoid Shape With The Class Of Matrix?

Jul 18, 2011

I want to use Image Reflection in trapezoid shape. That why i ask how to create trapezoid shape with the class of matrix

View 1 Replies

ActionScript 3.0 :: Crop Image But With Use Of Rectangle Class Or In Rectangular Shape

Apr 17, 2009

I am having some problems regarding image crop.I am able to crop an image but with the use of rectangle class or in rectangular shape.But i would like to crop in circular shape(for example go to URL...).

View 8 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 :: Detecting The Current Scene In A Document Class

Aug 23, 2011

I just want to know if there is a way to this.

View 3 Replies

ActionScript 3.0 :: Making Interface - Add 'Screens' To My Current Class

Sep 3, 2011

I think I understand how to make a interface but the problem is im unsure as to how to add it to my existing code! To make a interface (as far as i know) You can create classes such as mainScreen, intructions and so on. Ok i get that, make the classes then add ther buttons from the library i these classes. But i followed a tutorial bu Emmanuel Feronto, and adapted that to the needs of my game.

So im unsure as how to add these 'Screens' to my current class, the I currently only have 1 class, Main which currently has 300 lines of code, and i dont know how to break it up into smaller classes. Thats the problem i think, The main is quite large, normally i have heard people keep this clear... But then say i made a bland main, and added the screens into that then how do i make the main that makes the game play on the play button?

View 14 Replies

ActionScript 3.0 :: Eclare A Variable Type That Is The Same Name As The Current Class?

Feb 3, 2009

How do you declare a variable type that is the same name as the current class in a different package? Is it possible?I'm importing the class and using getDefinitionByName for the instantiation. However, without declaring a variable of that time, the class is not being imported.

[code]...

View 2 Replies

ActionScript 2.0 :: TWEEN CLASS Method To Work When The Movie Clip Is A Shape

Feb 5, 2007

I downloaded an Mc Tween Class from [URl] so I can use the ColorTransformTo method. However, the method only works when my movieclip is an image; and I need the method to work when the movie clip is a shape...

View 1 Replies

Flash :: AS3 - Print Current Class In Trace Statement For Debugging?

Mar 3, 2010

Is there a statement in AS3 that will return current class and/or scope? I'd like to use that in trace statements so that I know the exact location of a trace.

View 2 Replies

ActionScript 2.0 :: Disable Current And Enable Other Buttons Using Class File

Jun 24, 2010

I have a simple class file for buttons. on Rollover the movieclip plays frame no 2 and on Rollout it plays frame no 11. This is working fine. Now I want to disable the current button on click/release and enable others. I don't know how to get the other buttons because the this keyword always refer to the current button that is rolled over of clicked.

ActionScript Code:
class ButtonClass extends MovieClip {
var buttonName:String;
public function ButtonClass() {
this.onRollOver = over;
this.onRollOut = out;
[Code] .....

View 0 Replies







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