Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:07:21+00:00 2026-06-13T18:07:21+00:00

I am stuck with something that I am sure should be fairly straightforward. I

  • 0

I am stuck with something that I am sure should be fairly straightforward. I declare two vertical lines from the library, then pass each in turn to a function which operates on the line it has been passed. The code executes without error, but apparently is overwriting the first line when the function is called the second time, presumably because of the use of the term “myLine” in the function header. Can anyone inform me how to pass each line to the same function but have the function operate on that line only?

The code is:

//declare new lines from library
var myLine1:letterLine = new letterLine();
var myLine2:letterLine = new letterLine();

//call function and pass each line in turn
VerticalLine(myLine1, lineX = stage.stageWidth/2 - lineOffset, lineY, lineLength, lineThickness, lineColour, lineTweenSpeed);
VerticalLine(myLine2, lineX = stage.stageWidth/2 - lineOffset, lineY, lineLength, lineThickness, lineColour, lineTweenSpeed);

//operate on the line passed to the function
function verticalLine(myLine, lineX:int, lineY:int, lineLength:Number, lineThickness:int, lineColour, lineTweenSpeed:Number):void {
    //draw line
    myLine.height = 0;
    myLine.x = lineX;
    myLine.y = lineY;
    myLine.width = lineThickness;

    var myColour:ColorTransform = myLine.transform.colorTransform;
    myColour.color = lineColour;
    myLine.transform.colorTransform = myColour;
    addChild(myLine);

    //set mask properties for line
    var maskW:uint = lineThickness;
    var maskH:uint = lineLength;

    //set gradient properties for mask
    var gradientFillType:String = GradientType.LINEAR;
    var gradientColours:Array = [0x123456, 0x654321, 0x123456, 0x654321];
    var gradientAlphas:Array = [0.4, 1, 1, 0.4];
    var gradientRatios:Array = [0, 100, 155, 255];
    var gradientMatrix:Matrix = new Matrix;

    var maskRotation:Number = Math.PI/2;
    var maskX:int = lineX;
    var maskY:int = myLine.y - lineLength/2;;
    gradientMatrix.createGradientBox(maskW, maskH, maskRotation, maskX, maskY);
    var spreadMethod:String = SpreadMethod.PAD;

    myLine.cacheAsBitmap = true;

    //draw mask shape
    var myMask = new Shape ;
    myMask.graphics.beginGradientFill(gradientFillType, gradientColours, gradientAlphas, gradientRatios, gradientMatrix, spreadMethod);
    myMask.graphics.drawRect(maskX, maskY, maskW, maskH);
    myMask.cacheAsBitmap = true;
    addChild(myMask);

    //mask line
    myLine.mask = myMask;

    TweenLite.to(myLine, lineTweenSpeed,{height:lineLength, ease:Linear.easeIn});
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:07:23+00:00Added an answer on June 13, 2026 at 6:07 pm

    The trick is, you are sending equal values for both lines, so they strictly overlap, and you see this as an overwriting. When you call your function, you need to provide actual values for corresponding lines. Like this:

    verticalLine(myLine1, stage.stageWidth/2 - 100, 10, 125, 1, 0xff0000, 0.2);
    verticalLine(myLine2, stage.stageWidth/2 - 2, 300, 40, 2, 0x0000ff, 0.3);
    

    Also check if you have proper casing when declaring the function and when calling it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pick up Lua programming but I'm stuck on something that's probably
I'm sure it's something obvious, but I'm pretty stuck here. I have a LAMP
when debugging java code, in the stack trace, I noticed that something in the
I'm kinda stuck on something... I'm trying to get #right to be the same
I am stuck with something quite simple but really annoying: I have an xml
I'm kinda stuck with something which must be appalingly simple. I'm trying to write
I´ve been stuck on a minor jquery problem, it´s probably just something minor I´m
I think I have a basic understanding of REST, but something I'm stuck on
Background I'm working on a symmetric rounding class and I find that I'm stuck
It might be that my math is rusty or I'm just stuck in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.