Creating shapes with blend modes in actionscript 3

Ok I'm having a lot of trouble with ActionScript 3. I'm supposed to make five buttons that when clicked show a different blend mode using 2 or more shapes. Each of these blend modes also has to have a text box explaining what the blend mode does.  The assignment requires only one layer which is the actions layer. Everything has to be made using script only, which is why I'm having so many problems.
Can someone please help me with this and simplify it has much as possible. I need to have some sort of answer sometime tomorrow. I thank anyone who helps.
I have this code so far.
import flash.text.TextField;
import flash.text.TextFormat;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.display.Shape;
//create button instances
var btn:darkBtn = new darkBtn;
var btn2:invertBtn = new invertBtn;
var btn3:overBtn = new overBtn;
var btn4:screenBtn = new screenBtn;
var btn5:subBtn = new subBtn;
//add our interface objects to the main display list
addChild(btn);
addChild(btn2);
addChild(btn3);
addChild(btn4);
addChild(btn5);
//button positions
btn.x = 12;
btn.y = 395;
btn2.x = 131;
btn2.y = 395;
btn3.x = 250;
btn3.y = 395;
btn4.x = 367;
btn4.y = 395;
btn5.x = 485;
btn5.y = 395;
//create a new font
var mainFont = new GeorgiaRegular();
//create a new text format object
var mainFormat:TextFormat = new TextFormat();
mainFormat.size = 18;
mainFormat.leading = 4.5;
mainFormat.font = mainFont.fontName;
mainFormat.kerning = true;
//create text field copy
var mainTxt:TextField = new TextField;
mainTxt.x = 307;
mainTxt.y = 182;
mainTxt.width = 221;
mainTxt.height = 333;
mainTxt.multiline = true;
mainTxt.wordWrap = true;
mainTxt.defaultTextFormat = mainFormat;
mainTxt.autoSize = TextFieldAutoSize.LEFT;
mainTxt.embedFonts = true;
//create a URLLoader object
var textLoad:URLLoader = new URLLoader;
//create a new URLRequest
var darkReq:URLRequest = new URLRequest ("text/dark.txt");
var invertReq:URLRequest = new URLRequest ("text/invert.txt");
var overReq:URLRequest = new URLRequest ("text/over.txt");
var screenReq:URLRequest = new URLRequest ("text/screen.txt");
var subReq:URLRequest = new URLRequest ("text/sub.txt");
//test to see that the external file has completely loaded
//once it has executed the function that will add the loaded content
//to our dynamic text field
textLoad.addEventListener(Event.COMPLETE, textComplete);
//function to execute once the external data is loaded;
//adds the external file data (the actual text) to our text field
function textComplete(event:Event):void
    mainTxt.text = event.target.data;
//create a new shape object
var sq:Shape = new Shape();
//use the lineStyle method of the graphics object to
//set the line thickness and color
sq.graphics.lineStyle(2, 0x000000);
//use the beginFill method to fill the shape
//with the specified color
sq.graphics.beginFill(0xFF86600);
//use the drawRect method to draw a rectangle
sq.graphics.drawRect(175, 100, 100, 100);
//use the endFill method to end the fill of the shape
sq.graphics.endFill();
//add our shaped to the display list
addChild(sq);
//create a new shape object
var circ:Shape = new Shape();
//use the lineStyle method of the graphics object to
//set the line thickness adn color
circ.graphics.lineStyle(2, 0x000000);
//use the beginFill method to fill the shape
//with the specified color
circ.graphics.beginFill(0xFF9900);
//use the drawCircle method to draw a circle
    circ.graphics.drawCircle(150, 150, 85);
//use the endFill method to end the fill of the shape
circ.graphics.endFill();
//add our shape to the display list
addChild(circ);
//apply a blend mode to the circle
circ.blendMode = BlendMode.MULTIPLY;
//create a display object container
var contentContainer:Sprite = new Sprite;
addChild(contentContainer);
contentContainer.x = 10;
contentContainer.y = 24;
contentContainer.width = 1000;
contentContainer.height = 725;
//set initial page
contentContainer.addChild(mainTxt);
textLoad.load(darkReq);

blendModes can only be applied to DisplayObjects (Sprites, MovieClips, Bitmaps etc)
For an example how to get it working:
DisplayObject - Adobe ActionScript® 3 (AS3 ) API Reference

Similar Messages

  • Layered image with blending mode won't display properly in Indesign CS3

    Hello,
    I'm having trouble placing a layered psd and/or tiff with blending modes into my indesign cs3 document. Basically I have a flattened image with a shadow on a white background. I've had to doctor the image a bit in photoshop and I've used the multiply blending mode to remove the white background. (I'm trying to get around having to clip the image and having to recreate the shadow). Anyone know how I can drop my layered image into indesign and have it keep the blending modes I've applied in photoshop?
    Any help would be much appreciated.

    I'll try and do my best to describe what it is I'm doing.
    I've started out with a “flat” image of a product on a white background with a shadow on it. I need to make the background transparent and so that all I’m left with is the product with the shadow on a transparent background.I want to be able to place this image over another image in indesign and have the background remain transparent.
    On the first layer I have a clipped out version of the product with no background (All by itself with no background or shadow). On the second layer I have the original “flat” image with the shadow and white background. On this layer I’ve used the multiply blending mode to remove the white background.
    Now that I have the product on one layer by itself and the product and shadow on layer two with the multiply blending mode I have an image of the product with a shadow with no background. When I place this into indesign, my image shows up with the white background as if the multiply blending mode isn’t applied.
    I’ve tried this on other images. It doesn’t appear that it lets you bring an image over with that blending mode. It's like I'd have to bring over a clipped image and then place that on top of my original image with a blending mode placed on it "in" Indesign.
    Hope that make sense?

  • Problems with blending modes

    Hi,
    I have a layer with a solid color (212º,93,78) on top of which I have another layer with a solid color (205º,100,74).  Call this second layer the blend layer. I then choose for it a blending mode of Color, and the resulting color in the top layer is (205º,100, 74). If instead I choose the luminosity blending mode, the resulting color in the top layer is (212º,93,78).
    ---all these are HSB coordinates.
    According to the documentation. color and luminosity blending modes should behave differently:
    Color
    Creates a result color with the luminance of the base color and the hue and saturation of the blend color. This preserves the gray levels in the image and is useful for coloring monochrome images and for tinting color images.
                              ------ the luminance of the base color is 78 (at least the brightness anyway - I know of no method to get the luminance)
    Luminosity
    Creates a result color with the hue and saturation of the base color and the luminance of the blend color. This mode creates the inverse effect of Color mode.
                   -------  in this case everything is equal, which seems to me is not right.
    Some light?
    Juan Dent

    Generally speaking, Photoshop works fine with Windows 8 but the display drivers aren't all up to the task yet, and Photoshop uses the GPU for a lot of stuff.
    What video card do you have?
    You might find you can go into Edit - Preferences - Performance in Photoshop and disable the usage of GPU (the setting is called [  ] Use Graphics Processor in Photoshop CS6, and [  ] Enable OpenGL Drawing in earlier versions).  It's also possible that you might find things to work better if you leve the GPU enabled but change the advanced mode for it to a lower setting, such as Basic.
    In a general answer to your question, yes, I imagine there will be updates through Windows Update and from Adobe that will correct the problems.  You may be able to accelerate the fix by visiting the web site of the maker of your video card and downloading their recent driver release (though I caution against this with ATI drivers right now - their latest aren't really too good).
    -Noel

  • Aliased text on PDF export with blending modes

    So I've had this issue with a pdf, I tried to export it CMYK, RVB, interactive pdf, regular pdf, with tons of different other options, the text was still very aliased.
    I decided to take it back from scratch, openned a new document with the same size, and copied/pasted element after element from the old one to the new one, exporting as pdf between each copy/paste. The first exports went really well, the render was great… until I pasted a vector element that was applied with a blending mode (overlay).
    When I switched it to normal, the pdf export was smooth again. Tried every blending mode, everyone makes the text jaggy. Switch back, it's ok. So I'm 100% sure that this comes from blending modes, as opposed to what I could have read on other forums.
    This is a request, please, InDesign team, take care of this problem, this is quite annoying in many cases.
    Thank you for your attention!
    Twitted here as well : https://twitter.com/grinderlabs/status/448381486627311616

    To minmize the possibility of rasterizing or outlining text when transparency is flattened, keep the text above any transparent objects. Blending modes, along with most effects, use transparency.
    You can also minimize the risk by exporting the PDF with live transparency, which is supported in Acrobat 5 or higher compatibility.

  • Create shape with round and square corners

    Hi all
    I haven't used illustrator for a while so I'm really stuck on soemthing that should be simple.
    I want to create a shape that has round corners on the bottom and square cormers at the top.
    I have created two shapes, one with round corners and one with square one.
    I was hoping to put them together then use the pathfinder to unite them but this then make the round corner square.
    Is it possible to unite shapes with different corners.

    myttmt,
    Or create a rounded rectangle that is one corner radius too high, press C (Scissors Tool) and cut at the top of the straight sides (first right then left), press V to switch to the Selection Tool and delete the selected top cut, then select the remaining part and Ctrl/Cmd+J to join.
    The bottom rounded rectangle thread lives. Or is it the tanker cross section thread?

  • Issue with blend mode colour dodge?

    So I'm not all that new to photoshop, I'd probably put myself in the intermediate category, but for some reason I haven't been able to figure this issue out, and I would love some help. I was doing a tutorial, and it mentioned we needed to change the blend mode of our photo to color dodge. I found color dodge fine, but for some reason when I tried to apply it, nothing happened. The tutorial mentioned grouping the layers, which I did, still no change.
    So I found another tutorial that broke the process down, but I've still been unable to apply color dodge to what I'm working on. When I did apply colour dodge, I got this:
    I have no idea what to do about the red circle. I'm sure this is a totally ridiculous error, but I'd love some help!
    Here's what I'm attempting to change, with no success:
    Here's the picture I would ultimately like to apply colour dodge to:
    Again, I'm sure this is really simple, but I haven't found an easy answer, so any help would be appreciated!
    Thanks!

    What you expect to happen after applying Color Dodge? With Blue Fill layer on top and white pixels beneath, applying Color Dodge will produce what you see on your screen. Same will happen if you move layer with white pixels on top of layer with blue fill color. There is some mistake in tutorial.

  • Fireworks PNG - FXG - FC. It Works! With Blend modes!=)

    but it has some isues...
    1) blend modes problem: if you put on object some COLOR BURN IT READS IT AS  blendMode="-1"  and you get picture of blanc screen and library of empty groups and so on. the point is it does not work... (so if you had any powers to edit the code you might solve the problen)
    2) if it has any style on the object it turns it into a bit map...
    3) no round corners transport
    but ewerething else is great... with help of fb then it can be turned into a sweet candy
    >sory for my EN_

    0) Once like this?
    FW is not open source and is not free for use so
    1)Who will be paying me for such stuff ?
    2)How much(or will be giving me what)?

  • How to Fill Rectangle using LinearGradientBrush with Blend mode and Linear Color in c#?

    I don't know how the rectangle Fill using LinearGradient Brush can anybody explain please ,
    Regards,
    Thank U.

    Hi,
    the links below can assist you:>
    https://msdn.microsoft.com/en-us/library/0sdy66e6(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/aa970904(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/ms754083(v=vs.110).aspx
    https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.lineargradientbrush(v=vs.110).aspx
    http://www.codeproject.com/Articles/11615/Gradient-Maker-Application
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • Can I make custom blend modes with Pixel Bender 3d?

    So it seems PixelBender does not work in GPU mode, which is essential in iOS.
    I want to create a custom blend mode for adobe air in iOS and was wondering if it is possible with Pixel Bender 3d.

    for the mesh, hexagon is actually better than photoshop. Since it can create the actual mesh. Though, you can import the mesh into photoshop so you can see it while you paint the texture.
    The 3d creation portion of photoshop is still a bit limiting. (But my experience stops with CS5. I have not tried CS6 yet, so impovement could have been made)
    The issue I have with hexagon is the amount of bugs in it. I prefer a more robust and more expensive alternative. But thats me
    A free alternative is Blender. But I find the UI a bit outdated and hard to grasp. But again, thats me.
    Generate your UV maps as you normally would then load them into photoshop and get painting. You may like other texture generating apps to go along with photoshop. Genetica is great for making tileable textures.

  • Is there a way to get the result of using multiple blending modes in one object?

    Hello,
    I wonder if there's a way to merge multiple objects with blending modes to one object. Here is the example:
    On the left rhere are three objects with the same appearence but different blending modes(color dodge, normal, overlay), on the right they are overlapped, which are still three object. I'm looking for the way to have the same result as the right overlapped one, but as one object. Having the same multiple objects only for the result of color blending mode uses too much memory for my computer.
    Thank you for your help in advance.

    create one object: then in your appearance panel, duplicate the fill twice. Select the top fill and expand the sub menu, click on opacity, choose blending mode. repeat.
    G

  • Is there a way to quickly preview blend modes, similar to the shift+ and shift- like AfterAffects?

    This would seem to be a no brainer but nobody seems to know the answer.... I have a hard time believing I have to endure the sea-saw process of clicking on a given blend mode each time I want to preview an affect.

    The next issue you will find with Blend Modes is "Opacity Droppings"
    Anyone that uses Blend Modes...naturally uses Opacity as part of the setting. ie. the degree of blend.
    (The two work hand in hand.)
    Problem is.. as soon as you do  this... an automatic opacity keyframe is created.
    This is guaranteed to drive you nuts!
    It does not work this way in AEFX .  where it is more logically and practically implemented with a normal way of setting a keyframe manually.

  • Question about blend modes

    I have a video clip of a guy in front of a white screen (originally it was a green screen but I replaced the background with a white wall). I want to add a graphic behind him and I am not sure which blend mode to use. The graphic is also based on a white background. Would it be easier if I just had an alpha channel? Can you even export a video clip out of FCP with an alpha channel?

    But if you're keying in FCP, why not create the Motion project with the proper aspect ratio, or adjust it once you bring it into FCP?
    You're not gonna get there with blend modes...
    Patrick

  • "applying" a blend mode

    Hi.
    I was curious what rules PS follows exactly when it comes to merging of layers with blend modes other than "normal".
    Can anybody direct me somewhere, where I can find information about that? I searched the web extensively, but couldn't find anything. Adobe Livedocs is mute about that, too.
    For example:
    - blend layer 2 (hard ligth)
    - blend layer 1 (vivid light)
    - Background layer (normal)
    --> now if you blend layer1+2, you alter the visible (flattened) on-screen-image.
    Another example:
    I had a layer with a landscape + a medium-blue sky without stars. On another layer I had white stars on a (nearly) black backdrop. So I used the "lighten" mode to fill the medium-blue sky with stars.
    Later on, I did some trick to remove the black backdrop and only have the pixels of the white stars on my layer. (And NO, I didn't do any "blend if" or "color range" or something therelike, I only used the blending modes!). Unfortunately I can't remember how I did it exactly, but I think I merged the layer with another empty layer (I know it sounds weird), possibly putting both layers into a group first and merging the group.
    Fact is, that after the merging (of my stars layer and "???"), I got a layer with mode "normal" and pixels that had RGB and transparency values in such a way that they produced the same final (blended) picture as - beforehand - the pixels of the white-stars-on-black-backdrop did in "lighten mode". So if I went back and forth in the history (before and after merging), there was no visible difference in the flat-on-screen-image.
    I would be so thankful, if anybody - by chance - knows what I had been doing :)
    (I tried merging the layer with, respectively, an empty, a black-filled, a white-filled and a 50%grey-filled layer, but I couldn't reproduce it).

    Thanks for helping. I'm sorry to repeat myself, but there are obviously other ways to achieve this, that's not my problem. The stars, etc... this was just an example.
    "Blending a layer with an underlying transparency ..."-> First of all, I said "merging", and then "...does nothing" is not true. Try this for example: open the blending options of the "stars-layer" (or any layer for that matter), choose "blend if">"this layer" and drag the slider until a visible part of the image has disappeared, but a part is still there. Then create a new empty, transparent, layer and merge these two layers. Voilà.
    Now, that's *not* the way I proceeded in my original example. Just to demonstrate that merging with an empty layer can be a workaround.
    In the example here, you can see that a new layer has been created containing pixels with RGB and transparency values that produce exactly the same flattened-on-screen-image as before. You can go back and forth in the history and don't see any changes on-screen.
    In my original example, I used another blending technique (not "blend if" but "lighten"). But
    after merging, I also had a new layer containing pixels in "normal mode" that reproduced exactly the same on-screen picture as did previously the pixels in "lighten mode" in such a fashion, that - again - you would see no difference on-screen when going back and forth in history.

  • Alpha, blending modes and compositions

    Hello, I am an animator and have a problem with blending modes in a composition. Hopefully someone can help me.
    I use After Effects CS5 on Mac OS.
    Please take a look at this screenshot:
    I have several layers in a composition (trees and shadows). The trees are set to normal and the shadows are set to multiply. Outside of this composition there are other elements on layers.
    The problem is that I get this edge between shadows and trees where the multiply does not apply. I need it to be applyed to the "outside" layer too.
    Trying to look my problem up on the internet I found out that the blending mode "alpha add" could solve my problem but I need multiply and alpha add, if that makes sense.
    Can I somehow get rid of this edge?  

    Multiply is being applied to all pixels, it's just that the pixels around the edge are not the same color. You can use Matte tools to refine or choke the edges. (Effect>Matte>Matte Choker) If you very carefully look at the pixel values on the edges of your illustration while viewing the info palette you'll see that you have some semi transparent pixels on the edges. That is where you problem comes from. Alpha add will help in matching antialiased edges but it will not help in your situation.

  • Blending Modes ("vivid light") in After Effects?

    I discovered that in After Effects CS6 (Win7) some blending modes seem to not work as expected.
    I have a bitmap with transparencies above another bitmap and want to blend it with "vivid light" - but the result is the same as if i had no blending mode selected at all. The same is for "hard light", "linear light" or "hard mix".
    Other blending modes like "multiply", "soft light" and "overlay" work just fine.
    Does anyone have an idea what is wrong with my After Effects?

    I'm sorry for not being as specific as requested in the faq. I thought it might be more helpful to reduce the problem description to the most relevant facts first, and see if it can be solved in a simple way.
    My former experiences with providing all existing information in the first post is usually met with no answers at all, because people think: WOAH! Too much information. ;-)
    Okay, I designed my video design in Photoshop CS6 first. This is how the design was supposed to look like - as it was composed in Photoshop.
    There are two layers:
    1. a pattern of semi-transparent patches on top and
    2. a blue gradient background
    the pattern (1) is composited with blending mode "vivid light" on the background (2).
    After I exported both layers as pngs (24bit alpha) and imported them in After Effects and used the same settings as in photoshop, I got the following:
    As you can see, I used "vivid light" as blending mode, but it looks exactly as if blending mode "normal" was used.
    The render quality is set to final quality.
    The same happens with blending modes "hard light", "linear light" or "hard mix" (i guess, you don't need screenshots, because they all look the same)
    But other blending modes like "multiply", "soft light" and "overlay" work fine (in this case I used "overlay"):
    So, the problem is: Why do some blending modes not work, while others work?
    BTW: I also tried to import the PSD directly into After Effects with all layers retained, in case something was wrong with the pngs, that I exported - but the imported PSD produced exactly the same error. So, no difference there.
    Now for all the questions from the faq.  - i think most of them will not help to identify the issue, but i will try and answer all of them:
    What version of After Effects? Include the minor version number (e.g., After Effects CS5.5 with the 10.5.1 update).
    CS6 (11.0.2)
    Have you installed the recent updates? (If not, you should. They fix a lot of problems.)
    yes, I have
    What operating system? This should include specific minor version numbers, like "Mac OSX v10.6.8"---not just "Mac".
    Windows 7, 64bit latest version, all updates installed
    What kind(s) of source footage? When telling about your source footage, tell us about the codecs, not just the container types. For example, "H.264 in a .mov container", not just "QuickTime".
    any footage. it's regardless of what footage I use. in this special case it was 2 pngs (24bit alpha) - see above.
    If you are getting error message(s), what is the full text of the error message(s)?
    there is no error message
    What were you doing when the problem occurred?
    see above
    Has this ever worked before? If this worked before by doesn't work now, what has changed on your computer in the intervening time?
    it's the first time I tried
    What other software are you running?
    mainly software like Google Chrome or Microsoft Office - I'm not sure they have anything to do with the problem
    Do you have any third-party effects or codecs installed?
    I have Magic bullet looks installed, but since I don't use it in this project, I don't think it's got anything to do with the problem
    Tell us about your computer hardware. Include CPU type and number of processor cores, amount of RAM installed, GPU, number of disk drives, and how any external drives are connected.
    Intel something, 6 cores, 12GB RAM, and NVIDIA GTX 590 graphics card, (driver 306.97)
    Do you have any third-party I/O hardware (e.g., AJA, Matrox, Blackmagic, MOTU)?
    no
    Are you using OpenGL features in After Effects?
    I don't know.. I thought OpenGL in CS6 is all automatically and can not be turned off or on?
    but i switched quality to "final render".
    Does the problem only happen with your final output, RAM preview, or both?
    everywhere
    Are you using Render Multiple Frames Simultaneously multiprocessing?
    yes. but if I turn it off, nothings changes
    What is the exact sequence of steps that you are taking?
    see above
    hope this helps

Maybe you are looking for

  • 80G Video iPod - Not sure what the problem is

    So this problem just randomly started occuring. What will happen is my iPod will freeze completely, and then it will go to this screen which has a warning i have never seen before. It is an iPod with a triangular warning sign on it (with exclamation

  • BEx query : results and exceptions

    Hi people, I'm using BI 7. I've two questions. In a first part i want to know if i can use an exception in order to color all the line (characteristics + key figures) ? Because just the key figures are colored with many options I tried. In a second p

  • Is the windows firewall supose to be on or off when using Firefox

    Microsoft security essentials disappeared.

  • PKCS#11 pin initialization

    How to initialize smartcard's pin number using Sun PKCS#11 implementation ? How to personalize smartcard (generate keys and load certificate) using Sun PKCS#11 implementation ?

  • How to change RAW to JPEG without editing

    Normally, when I import RAW files into iphoto, edit them, and click Done, iphoto will convert those RAW files to JPEG. The problem is printer cannot print RAW files, but it can print files in JPEG format. However, there are many times that I don't wa