Solved

Shape with multiple lineStyle assigned

Posted on 2013-05-25
6
252 Views
Last Modified: 2013-08-11
Hello

What would be the best way to assign two diffrent color borders to an shape?
var rectangle:Shape = new Shape();
rectangle.graphics.lineStyle(2, 0xffffff);
and then also:
rectangle.graphics.lineStyle(1, 0xcccccc);
0
Comment
Question by:JoachimPetersen
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 39197266
You can use "filters" easiest way I am using drop filter

var rectangle:Shape = new Shape();
rectangle.graphics.lineStyle(1, 0xff0000);
rectangle.graphics.lineTo(100, 100);
addChild(rectangle);

var shadow:DropShadowFilter = new DropShadowFilter();
shadow.distance = 1;
shadow.angle = 1;
shadow.color = 0x0000ff;
shadow.alpha = 1;
shadow.blurX = 1;
shadow.blurY = 1;
rectangle.filters = [shadow];
0
 

Author Comment

by:JoachimPetersen
ID: 39197508
How can you make the dropshadowfilter act as a border, and not as an shadow effect?
0
 
LVL 29

Expert Comment

by:dgofman
ID: 39198026
Unfortunately I cannot find the code how adobe implemented flash.filters classes

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/package-detail.html

In my application I am using DropShadowFilter

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/DropShadowFilter.html

another way you can draw two rectangles

import flash.filters.ColorMatrixFilter;

var rectangle:Shape = new Shape();
rectangle.graphics.lineStyle(1, 0xff0000);
rectangle.graphics.drawRect(10, 10, 150, 150);

var shadow:DropShadowFilter = new DropShadowFilter();
shadow.distance = 1;
shadow.color = 0x0000ff;
shadow.blurX = 0;
shadow.blurY = 0;
rectangle.filters = [shadow];

//DropShadowFilter(distance:Number = 4.0, angle:Number = 45, color:uint = 0, alpha:Number = 1.0,
                        //blurX:Number = 4.0, blurY:Number = 4.0, strength:Number = 1.0, quality:int = 1,
                        //inner:Boolean = false, knockout:Boolean = false, hideObject:Boolean = false)

addChild(rectangle);
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 29

Expert Comment

by:dgofman
ID: 39198038
Actually using BevelFilter you can apply 3 colors (I am using green for shadow)


var rectangle:Shape = new Shape();
rectangle.graphics.lineStyle(1, 0xff0000);
rectangle.graphics.drawRect(10, 10, 150, 150);

//BevelFilter(distance:Number = 4.0, angle:Number = 45, highlightColor:uint = 0xFFFFFF, highlightAlpha:Number = 1.0, shadowColor:uint = 0x000000, shadowAlpha:Number = 1.0, blurX:Number = 4.0, blurY:Number = 4.0, strength:Number = 1, quality:int = 1, type:String = "inner", knockout:Boolean = false)

rectangle.filters = [ new BevelFilter(2,
                                   45,
                                   0x00ff00,
                                   1,
                                   0x0000ff,
                                   1,
                                   1,
                                   1,
                                   1,
                                   BitmapFilterQuality.HIGH,
                                   BitmapFilterType.OUTER,
                                   false)];

addChild(rectangle);
0
 

Author Comment

by:JoachimPetersen
ID: 39198686
I think I have to go with the two shape solotion, how do you combine shapes so that first you draw the 'border shape', then the other shape and 'lay' it over the first shape?
0
 
LVL 29

Accepted Solution

by:
dgofman earned 400 total points
ID: 39199734
that easy can be archive such this

function drawRect(x:int, y:int, width:int, height:int, color:Number, offset:int) {
      var rectangle:Shape = new Shape();
      rectangle.graphics.lineStyle(1, color);
      rectangle.graphics.drawRect(x - offset, y - offset, width + offset * 2, height + offset * 2);
      addChild(rectangle);
}

drawRect(10, 10, 150, 150, 0xff0000, 0);   //shape
drawRect(10, 10, 150, 150, 0x00ff00, -1);  //inner shape
drawRect(10, 10, 150, 150, 0x0000ff, 1);   //outer shape
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question