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 7197095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:54:19+00:00 2026-05-28T20:54:19+00:00

I am working on a class for building drop down buttons dynamically. Here is

  • 0

I am working on a class for building drop down buttons dynamically. Here is excerpt one of my code (located in the Class constructor):

_button.onRollOver = function()
            {
                this.gotoAndStop("over");
                TweenLite.to(this.options,0.2 * optionCount,{_y:mask._y, ease:Strong.easeOut, onComplete:detectMouse, onCompleteParams:[button]});
                function detectMouse(button:MovieClip)
                {
                    button.options.onMouseMove = function()
                    {
                        for (var option:String in this._parent.children)
                        {
                            if (this._parent.children[option].hitTest(_root._xmouse, _root._ymouse, true))
                            {
                                if (!this._parent.children[option].active) {
                                    this._parent.children[option].clear();
                                    drawOption(this._parent.children[option], "hover");
                                    this._parent.children[option].active = true;
                                }                               
                            }
                        }
                    };
                }
            };

I am attempting to call on the function drawOption() which is inside the same class and looks like so:

private function drawOption(option:MovieClip, state:String)
    {
        trace("yo");
        switch (state)
        {
            case "hover" :
                var backgroundColour:Number = _shadow;
                var textColour:Number = 0xffffff;
                break;
            default :
                var backgroundColour:Number = _background;
                var textColour:Number = _shadow;
                break;
        }
        option._x = edgePadding;
        option._y = 1 + edgePadding + (optionPadding * (option.index)) + (optionHeight * option.index);
        option.beginFill(backgroundColour,100);
        option.lineStyle(1,_border,100,true);
        option.moveTo(0,0);
        option.lineTo(_optionWidth,0);
        option.lineTo(_optionWidth,optionHeight);
        option.lineTo(0,optionHeight);
        option.endFill();
        var textfield:TextField = option.createTextField("string", option.getNextHighestDepth(), 20, 2, _optionWidth, optionHeight);
        var format:TextFormat = new TextFormat();
        format.bold = true;
        format.size = fontSize;
        format.font = "Arial";
        format.color = textColour;
        textfield.text = option.string;
        textfield.setTextFormat(format);
    }

But because I am trying to call from inside an onRollOver it seems that it is unable to recognise the Class methods. How would I go about accessing the function without making a duplicate of it (very messy, do not want!).

  • 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-05-28T20:54:20+00:00Added an answer on May 28, 2026 at 8:54 pm

    In AS2 I prefer to use the Delegate class to add functions to event handlers whilst maintaining control over the scope.

    You implement it like this:

    import mx.utils.Delegate;
    
    //create method allows you to set the active scope, and a handler function
    _button.onRollOver = Delegate.create(this,rollOverHandler);
    
    function rollOverHander() {
        // since the scope has shifted you need to use 
        // the instance name of the button
        _button.gotoAndStop("over");
        TweenLite.to(_button.options,0.2 * optionCount,{_y:mask._y, ease:Strong.easeOut, onComplete:detectMouse, onCompleteParams:[button]});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a high school team application using Django. Here is my working
I'm currently working on building a library to modularize some of my code and
I am working on building a USB Video Class camera, which is supposed to
I'm building some classes for working with playing cards. I have a Card class
I'm building a class library which references a file in its working directory. However,
I'm building a custom authentication filter class in Grails. It's working, but it bugs
I'm working through Google's Python class exercises . One of the exercises is this:
Does anyone have a working class or function to create the hashed email that
using System; using System.IO; using System.Net; using System.Text.RegularExpressions; namespace Working { class Program4 {
I have a working wrapper class for Dallmeier camera devices, It contains a callback

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.