ActionScript 3.0 :: Dynamically Drawn Shapes As Masks?
Apr 2, 2011
Is it possible to use a dynamically drawn line as a mask? (graphics.lineTo...) . Is there a way to cast this as a movieClip? I tried adding it to the movieClip, but that did not work.
View 4 Replies
Similar Posts:
Sep 15, 2009
I was just conducting a little experiment, basically trying to come up with a stage resizing handler that would position everything on the stage with its x and y proportionate to its original position. That's when I discovered a very interesting thing.
Shapes that you draw using flash's drawing tools are treated completely differently than dynamically drawn shapes. Basically shapes you draw on the stage in the authoring tool would seem to have no x and y of their own, and also no matter how many different shapes you draw, to the compiler it's all one "child" object because it's all just one big shape.
To illustrate this difference, I created two separate files, but they both (seemingly) do essentially the same thing. In the first file, I drew a red circle shape dynamically with code, and set its x and y with code:
ActionScript Code:
var circle:Shape = new Shape();
var g:Graphics = circle.graphics;
g.beginFill(0xFF0000);
[code]...
In a second file, I manually drew a similar red circle shape, made it 100 pixels wide and tall, and positioned it at 100, 100 using the properties panel. This time, I took away the code that creates the circle dynamically and just kept the for loop:
ActionScript Code:
for(var i:int = 0; i < this.numChildren; i++) {
var item:DisplayObject = this.getChildAt(i) as DisplayObject;
trace(item); //[object Shape]
trace(item.x); //0
trace(item.y); //0
}
In this second example, no matter how many and what kinds of shapes you draw, there will only ever be one display child and the x and y is always 0,0.
I for one kind of wish there were more of a one-to-one correspondence between the Flash IDE and the code window. Like, if we can create Shapes and name them dynamically, why can't we create Shapes and name them at authoring time? Or why isn't this now the role of the good ol' Graphics symbol? It's kind of like Flash and Actionscript have outgrown the authoring environment.
This would seem to have the effect of further widening the gap between design and development. Just thought I'd throw all this out there and see what kind of comments I get.
View 2 Replies
Jan 22, 2010
How can i easily break the shape into two pieces so that I can change them into movie clips?I tried using the selection tool combined with shift key to create selections but the selection tool only does squares so it's very frustrating to select a portion of my drawing precisely using it, i've given up
View 1 Replies
Nov 1, 2010
How do you resize shapes drawn in actionscript?
I need to create a skewed rectangle and on rollover, have the right edge move outwards.. making the skewed rectangle wider.. while keeping the proportions.[code]...
View 1 Replies
Mar 14, 2012
I have made a movieClip (mcMask) which I can use to mask another movieClip containing a bg image (mcImage). I have given the image movieClip an instance name(bg_mc) and I have given the mask movieClip a class of "Mask" in the "linkage" field. Now, I want to create multiple "Mask" movieClips using AS3 and use these to mask the image movieClip (bg_mc).The problem comes when I want to call the instance names of the "Mask" movieClips and set them to be the .mask value of the image movieClip.Because they are created from a class dynamically they don't have instance names. Is there a way to easily give them all instance names and then call them to use as masks? Or is there another way of calling them without assigning instance names?
Code:
//creates Var to create new "Mask" movieClips
var timer:Timer = new Timer(100, 999999);
[code].....
View 5 Replies
Oct 23, 2005
I have been looking for a preloader such as the one at [URL]. The preloader there is just the effect I've been looking for for a long time. I know it's done with scripting, but I could never make it quite right. I even posted here a few times, and found a tutorial, but it used a drag bar to control it, not bytesLoaded. Any tutorials that you could lead me to that focus on making it a preloader
View 14 Replies
Dec 7, 2010
I seached everywhere and try fo find drawing board code that saves after drawing but it seems it's only applicable in AS3, perhaps anyone have any tutorial link or have
View 2 Replies
Jul 17, 2011
I made a rounded rectangle in as3 and would like to expand it on click. This is the code I use:
var lesBg:Sprite = new Sprite();
with (lesBg.graphics) {
lineStyle(3, 0x61b157);[code].....
When I click on it I would like it to expand to twice its size. I'm doing this with TweenLite but when I expand it I get ugly pixelated images and the borders expand too.
Tweenlite.to(lesBg, 1,{width: 380});
Is it possible to expand the image so it stays clean and the borders stay intact?
View 2 Replies
Jul 7, 2010
I am trying to dynamically draw a circle and fill it up with some color. Drawing a circle is pretty easy job for me, but fill it up with some color seems not happening today.
PHP Code:
Circle function starts
function fnDrawArc(mc,x,y,r,angle){
mc.beginFill(0xFF0000); // this is not working....
mc.moveTo(x+r,y);
for(i=1;i<=angle;i++){
[Code] .....
View 1 Replies
Mar 14, 2012
I have a Group on my View, and i'm trying to fill it with some collor and add an mouse event on it, all dynamicaly.the problem is, when i add the mouse event, the group simply turns invisible again. It still exists on the view and responds normally to the mouse event, but i cant see it.here's an code example:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" creationComplete="onCreationComplete()" >[code]......
without the mouse event, the group is visible, but it vanishes when i try to add it. i've tried with other events, like the ENTER_FRAME Event and it works normaly, but all the mouse events that i tried turn the Group invisible.i've actually solved my problem using the opaqueBackground property, the Group don't vanish when i add the event this whay. But now i'm curious about the reason of this behavior.
View 1 Replies
Feb 23, 2005
I want to make a dynamically (using Drawing API) drawn ellipse rotate around its axis. It involves a lot of trigonometry which I'm not very good in .
View 7 Replies
May 14, 2005
I had to create dynamic with AS some rectangular on stage using moveTO and lineTo. I had a button and when I press it should add a new rectangle on stage but it doesn't. Because the array that I am storing the MovieClip created are overriding I guess
var i:Number =0;
button_name.onRelease = function() {
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename,this.getNextHighestDepth);
[Code] .....
View 1 Replies
Feb 23, 2005
I want to make a dynamically (using Drawing API) drawn ellipse rotate around its axis. It involves a lot of trigonometry which I'm not very good in .
View 7 Replies
Mar 31, 2012
i want to be able to create multiple shapes and store them perhaps in an array to be able to dynamically move them and change them.is there a way to have a shape object and store it an array?so that i can do something like shapeArray[0].x =100 current code
for(var i=0; i<10; i++){
var sprite:Sprite=new Sprite();
sprite.graphics.lineStyle(1)
[code]...
View 1 Replies
Jul 1, 2011
I'm trying to write a little flex app that has a paint/canvas type feature to draw an image, which I then want to post to a rails server side. I'm following the post here, but can't get as far as he did due to the following error: NoMethodError (undefined method `rewind' for #):I googled that and found this which says the problem is due to an empty filename, but I thought I had that from the example. However, I altered the example to simplify the post by reducing the form parameters, but I could have easily messed something up since I really don't know what I'm doing with this multipart form content. I was hoping to at least log the request params, but unfortunately I can't, since it's failing before being routed and due to my inexperience with rails. I'll ask that in a separate question and hopefully be able to edit this question with the request params.
View 1 Replies
Feb 17, 2009
I have a question about shapes (i mean the flash.display.Shape class). Is it possible to import Shapes directly from the library as Shapes and not as Sprites/MovieClips? Shapes are supposed to be faster than MovieClips/Sprites, right? So why is it only possible to import MCs/Sprites from the library? I understand that generally shapes could be created solely by actionscript, but in my case the shape comprises of many points and is curved - so it's quite infeasible.
Is there maybe some sort of plugin to generate code that would draw the desired shape from a drawn shape in CS4? And a last one: Are there any benchmarks out there for performance comparison between sprites/mcs/shapes? How much performance do i loose by using a sprite instead of a shape?
View 2 Replies
Sep 24, 2009
I'm trying to display a shape using a mask in a way that it unhides the shape from left to center and in the same time from right to center.
--shape--
---><---
Is there a way to create a mask layer that animates two masks or to create two masks above one layer?
View 6 Replies
Mar 16, 2009
I was wondering whether it was possible to include multiple masks to just one layer?I have a huge deadline in for thurs and it would be a huuge help if it is possible.
View 1 Replies
Mar 18, 2011
I can SEE the maskObject unless I set its alpha to 0 and then it doesn't let clicks through to objectToBeMasked
And every single tutorial that I've seen fails to mention this and how to solve it, as if it should be obvious.
How do I mask objects through AS3 so that the masks act like masks act like the ones added in the IDE?
View 3 Replies
Jan 9, 2009
So I have a MovieClip, A, and inside of it is a layer that has shapes on it for a mask, this layer does have some keyframe animation (the masks move). Then I have MovieClips on other layers that are masked by the masking layer. When the movie loads, I load in an external jpeg and draw it onto a bitmap object, and then use that bitmap object and attach it to the moviecilps that are masked. This works fine, until the animation hits the part where the masks actually animated, then it reverts back to whatever i had in it before i attached the bitmaps. Is this a bug? or am i missing something? the only way i can get it to work is to run a function every single frame that the mask changes to reattach the bitmap. but that seems quite unefficient to have to do
View 0 Replies
Jul 2, 2008
I have two seperate MCs which I want to have the same mask effect on it Ie a gap in the middle, the mask is spinning round as stated they are separate, the blue thing gets moved whist the white one doesn't
View 4 Replies
Jan 9, 2009
So I have a MovieClip, A, and inside of it is a layer that has shapes on it for a mask, this layer does have some keyframe animation (the masks move). Then I have MovieClips on other layers that are masked by the masking layerWhen the movie loads, I load in an external jpeg and draw it onto a bitmap object, and then use that bitmap object and attach it to the moviecilps that are masked. This works fine, until the animation hits the part where the masks actually animated, then it reverts back to whatever i had in it before i attached the bitmaps. Is this a bug? or am i missing something? the only way i can get it to work is to run a function every single frame that the mask changes to reattach the bitmap. but that seems quite unefficient to have to do
View 2 Replies
Oct 4, 2011
I'm creating a starry sky for a header and there are mountains in the image which obviously I want the randomly generated stars to appear behind it.I've tried setMask() but I don't see it doing anything. The generated stars still appear on top of everything regardless of layer order and such.
View 2 Replies
Mar 19, 2004
I have a client who is IN LOVE with this site: http:[url]...I was just getting ready to start tweening and wondered if there's a way to script masks to do the same thing easily...NOT on mouse drag, but on the click of the button. I found a nice tutorial which will make a similar thing happen when you drag the mouse. But when I tried to target x and y the whole thing fell apart.
View 3 Replies
Apr 2, 2005
I have this problem that has been makin me crazy. I want to make an erasor for the drawing api basically. Since I wasn't able to accomplish it, i looked everywhere!!! no luck So far I have been able to "erase" with shapes. For instance, I can drag a circle out and see the masked item underneath. The very next shape I drag out cancels the mask from the previous shape as if you can only have 1 mask per maskee. Also, I cant get a line drawing to become a mask.
//creating the shape
_level3.drawingPlane.createEmptyMovieClip("layer"+ _level3.layer+"_"+i, _level3.layer);
// dynamically setting the mask_level3.water.setMask(_level3.drawingplane["layer"+_level3.layer+"_"+i]);
View 3 Replies
Jan 23, 2005
I've been having this issue for a day or two now and it's really bothering me. Sometimes the drawing api draws to the mask perfectly fine other times it doesn't work at all.
[Code]...
View 5 Replies
Mar 27, 2009
I'm trying to make flash add two maks in one movie clip,like this (pseudo-code)
PHP Code:
MovieClip.mask = mask1
MovieClip.mask = mask2
Print (MovieClip)
but it only shows me the last mask.
View 12 Replies
Oct 17, 2009
I'm trying to modify the alpha layer of a bitmapData by taking a source iamge and masking out areas that don't have the correct channel. ATM I'm using copyChannel to achieve the effect, but I'd liek more than 3 channels (use alpha kills the other channels it seems). 255, 0, 255 should be able to act as another mask.
This is what I'm doing now...
Code:
bitmap.bitmapData.copyChannel(tempMask, new Rectangle(0, 0, tempMask.width, tempMask.height), new Point(0, 0), BitmapDataChannel.RED, BitmapDataChannel.ALPHA);
So the red parts of the image mask out the source image. All I want is to be able to mask out things basic on multiple channels (the lesser of the 2).
1) How does copyChannel work? Can I just test each pixel manually and achieve relatively similar speeds? and 2) if the Flash inline functions are infact faster, is there a function that can do what I want, or would it be better to use a shader?
Code:
var tempBitmapData:BitmapData = new BitmapData(tempMask.width, tempMask.height);
var matrix:Array = [];
matrix = matrix.concat([0, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, 0, 0, 0, 0]); // green
[Code].....
View 1 Replies
Oct 5, 2010
I have an animation I've created of a rotating Earth. I want to turn it into a movie clip, so I can easily use it in other files. The problem is, I can't make it into a movie clip because there are some layers that are masks and they are locked.
View 3 Replies
Feb 3, 2011
I'm trying to make flash add two maks in one movie clip,like this (pseudo-code)
PHP Code:
MovieClip.mask = mask1
MovieClip.mask = mask2
Print (MovieClip)
but it only shows me the last mask. I believe this is not possible?
View 1 Replies