Question

When I make my movieclip selectable I lose the ability to scroll the textarea in the movie clip

Asked by: dyarosh

I am new to Flash and AS3.  I've created an application that displays a list of "abstracts" in a scroll pane.  THe "abstracts" contain information that includes a name and description of the abstract.  Each abstract within the scroll pane can also be scrolled if the text takes up more space than I've allocated.  The abstracts are loaded from an XML file.  The problem I have and can't figure out is this.  If I don't make the movie clip that stores the abstract info selectable (ie. user can click on the abstract and it goes to another frame that displays more information on the abstract) then I can scroll the text that is within the abstract.  If I do make the movie clip selectable, I no longer can scroll the text.  The scroll bars appear but when I try and scroll, it acts as if the abstract was clicked and goes to the appropriate frame.

This is the last part of my project that I need to get working by the end of this week so any help or suggestions would be greatly appreciated.

Here are the technical details:
SCENE 1
-----------
ScrollPane, Instance Name: aSp
MovieClip, Instance of abstractContainer, Instance Name: abstractContainer_mc
 
ActionScript
---------------
import fl.containers.ScrollPane;
var mcMain:MovieClip;	// empty movie clip in library with linkage name "scrollMovieClip"
 
for (i=0; i<abstarctcount; i++)
{
mcMain = new AbstractDisplay;	// Get new instance of AbstractDisplay
mcMain.name = "a" + i;		// Set instance name
mcMain.x = 0;		// Set x position
mcMain.y = yPos;		// Set y position, height of AbstractDisplay is 130
yPos = yPos + 135;		// Set yPos height of AbstractDisplay
mcMain.buttonMode=true;                      // Make selectable
mcMain.mouseChildren=false;              // Make selectable
mcMain.audio_mc.visible = false;
mcMain.video_mc.visible = false;
mcMain.abstractText.text = aText;
mcMain.abstractText.textField.setTextFormat(tf);
 
mcMain.addEventListener(MouseEvent.MOUSE_UP, selectedAbstract);  // Make selectable
abstractContainer_mc.addChild(mcMain);
}
 
// Update the scroll pane
aSp.source = abstractContainer_mc;
aSp.update();
 
stop();
 
AbstractDisplay
-------------------
TextArea, Instance Name: abstractText, horizontalScrollPolicy=auto, verticalScrollPolicy=auto

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-09-02 at 06:08:55ID24701134
Topics

ActionScript

,

Adobe Flash

Participating Experts
1
Points
500
Comments
18

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. movie clip
    since i am newbie using flash , I have some question as follow How to I jump back to a frame/lable of the main movie from a movie clip ?
  2. load Movie(clip)
    I know Load Movie can load a .swf onto a level or into a target. I want to load an existing movie clip into a target at run time This doesn't work as it is looking for a url. Load Movie ("/store", "/st1") Anyone know how I can load my existing mov...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: asaivanPosted on 2009-09-02 at 20:44:24ID: 25247709

I would just make certain elements in your MovieClip "unclickable", that is you can't have two event listeners on one movieclip which pertain to mouse events.  Flash will do one thing or another.  If you have images, or something else which you could designate as a "clickable" area, then do that, but if you put a blanket "click area" over your whole movieclip, you will get results like you are getting now.  You may also want to try to load a "tooltip" so that when you roll over the information in the Abstract, a tooltip comes up with the info, that way you don't have to worry about scrolling.  Here's a simple one, http://hairydoodle.blogspot.com/2009/04/as3-tooltip.html

 

by: asaivanPosted on 2009-09-02 at 20:45:52ID: 25247717

Also, one thing you could try changing is the event which is being listened for, you have mcMain.addEventListener(MouseEvent.MOUSE_UP, selectedAbstract);

But you could try variations
mcMain.addEventListener(MouseEvent.CLICK, selectedAbstract); or
mcMain.addEventListener(MouseEvent.DOUBLE_CLICK, selectedAbstract);

That may be a more simple solution to your problem.

 

by: dyaroshPosted on 2009-09-03 at 07:16:42ID: 25250894

I tried the MouseEvent.DOUBLE_CLICK and it would not work at all.  I wasn't able to double click and have the abstract event trigger.

I'm going to try your idea of a tool tip.  Hopefully it won't require too much rework of what I've already done.

 

by: asaivanPosted on 2009-09-03 at 08:14:11ID: 25251514

By the way, to get DoubleClick to work you have to have mcMain.doubleClickEnabled = true;

 

by: dyaroshPosted on 2009-09-03 at 08:16:04ID: 25251529

I'm trying to implement your Tool Tip idea with the link you provided.  One of the changes I'm making is to use a TextArea instead of a TextField so I can display a large amount of data that can be scrolled.  When I replace _tf:TextField = new TextField(); with _tf.TextArea = new TextArea(); I get the following error:

1046: Type was not found or was not a compile-time constant: TextArea.

TextArea is a component in my Library so I'm not sure why I'm getting this.  Do I need to import another class?

 

by: asaivanPosted on 2009-09-03 at 08:21:17ID: 25251601

First thing I would try is import fl.controls.TextArea;

 

by: dyaroshPosted on 2009-09-03 at 09:42:33ID: 25252444

Importing fl.controls.TextArea got rid of the area but now I have another problem.  When I hover over the abstract, it shows the tool tip but the info falls behind the other abstracts in the list because the height is bigger than the height of the first abstract.  How can I get the tool tip to stay on top of all of the abstracts?

// Tooltip.as
 
package {
 
    import flash.display.Sprite;
	import fl.controls.TextArea;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextLineMetrics;
    import flash.display.BlendMode;
    import flash.utils.Timer;
    import flash.events.MouseEvent;
    
    public class ToolTip extends Sprite {
 
        private var _tip:String;
 
        // You'll need this for proper text formatting
        //private var _tf:TextField = new TextField();
        private var _tf:TextArea = new TextArea();
        private var _format:TextFormat = new TextFormat();
 
        private static const ROUND:Number = 2;
        //private static const HEIGHT:Number = 25;
		private static const HEIGHT:Number = 400;
		private static const WIDTH:Number = 400;
        private static const FONT_SIZE:uint = 14;
        private static const FONT:String = 'Arial';
		private static const FONTCOLOR:String = "#ffffff";
        private static const PADDING:Number = 5;
        private static const MIN_ALPHA:Number = .00;
        private static const ALPHA_INC:Number = .05;
        //private static const MAX_ALPHA:Number = .75;
        private static const MAX_ALPHA:Number = 1.0;
        private static const REFRESH:Number = MAX_ALPHA / ALPHA_INC;
 
        // For fading in and out
        private var _timer:Timer;
        
        public function ToolTip( tip:String ) {
 
            // Hold onto the tip for posterity
            _tip = tip;
            
            // This ensures the textfield inherits this class's
            // alpha property.  Very important because otherwise tf
            // would always have an alpha of 1 meaning it will always be visible
            this.blendMode = BlendMode.LAYER;
            
            _format.size = FONT_SIZE;
            _format.font = FONT;
			_format.color = FONTCOLOR;
            _tf.setStyle("size", FONT_SIZE);
			_tf.setStyle("font", FONT);
			_tf.setStyle("color", FONTCOLOR);
			
            // Make sure the text behaves and looks
            // the way text on a button should
            //_tf.defaultTextFormat = _format;    // Always call defaultTextFormat before setting text otherwise
                                           // the text doesn't use the formatting defined in tf
			
            //_tf.autoSize = TextFieldAutoSize.LEFT;  // You have to set autoSize to TextFieldAutoSize.LEFT
                                                    // for box.textWidth to be accurate
            //_tf.multiline = true;
			_tf.width = WIDTH;
			_tf.height = HEIGHT;
            _tf.text = tip;
            //_tf.selectable = false;
            _tf.x += PADDING;
            _tf.y += PADDING;
            addChild( _tf );
 
            // Draw the background
            graphics.beginFill( 0x666666, 1 );
            //graphics.drawRoundRect( 0, 0, _tf.textWidth+PADDING*4, HEIGHT, ROUND );
            graphics.drawRoundRect( 0, 0, WIDTH+PADDING*4, HEIGHT, ROUND );
            graphics.endFill();
            this.alpha = MIN_ALPHA;
        }
 
        // You have to call this after
        // the tooltip has been added to the
        // display list
        public function start():void {
            this.parent.addEventListener( MouseEvent.MOUSE_OVER, mouse_over );
        }
 
        public function mouse_over( e:MouseEvent ):void {
            this.parent.setChildIndex( this, this.parent.numChildren-1 ) // Move the tool tip to the top!
            var fadeSpeed:Number = 500 / REFRESH;
            _timer = new Timer( fadeSpeed, REFRESH );
            _timer.addEventListener( "timer", fadeIn )
            _timer.start();
            this.parent.addEventListener( MouseEvent.MOUSE_OUT, mouse_out );
        }
        
        public function mouse_out( e:MouseEvent ):void {
            var fadeSpeed:Number = 500 / REFRESH;
            _timer = new Timer( fadeSpeed, REFRESH );
            _timer.addEventListener( "timer", fadeOut )
            _timer.start();
        }
 
        private function fadeIn( i:uint ):void {
            this.alpha += ALPHA_INC;
        }
        
        private function fadeOut( i:uint ):void {
            this.alpha -= ALPHA_INC;
        }
    }                                      
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:

Select allOpen in new window

 

by: asaivanPosted on 2009-09-03 at 09:51:05ID: 25252519

On Line 72 of previous code, try changing addChild( _tf );

to this.parent.addChild( _tf );

 

by: dyaroshPosted on 2009-09-03 at 12:25:01ID: 25254032

I made the change you suggested and it still doesn't work.  I've come up with another idea but need help figuring out where to put the event listener.  

In the AbstractDisplay I created a rectangle that covers 75% of the text area.  I converted the rectangle to a button symbol with an instance name of hitarea_btn and set the alpha to 0 so it appears invisible.  Now when I run the program, the abstracts show up and I can scroll the text and when my cursor is over the area that I put the hitarea_btn, the cursor changes to a hand cursor.  Now I just have to figure out where do I put the event listener for it?  I want to use the selectedAbstract function that I've already written.

 

by: asaivanPosted on 2009-09-03 at 12:27:09ID: 25254057

ok, so,  just say hitarea_btn.addEventListener( MouseEvent.CLICK, doSomething );

Or if that doesn't work right what I would do is actually change the button symbol to a movieclip symbol.

 

by: dyaroshPosted on 2009-09-03 at 12:31:40ID: 25254107

Do I put that on my main timeline or within the AbstractDisplay timeline?

 

by: asaivanPosted on 2009-09-03 at 12:32:44ID: 25254115

You would put that in the code where your building your individual Abstracts to put in the ScrollPane. In your for loop.

 

by: dyaroshPosted on 2009-09-03 at 12:42:04ID: 25254214

Ok.  I did that but now I lose the information that I need to deteremine which abstract was clicked.  In the loop, I set the the name of the new AbstractDisplay object to "a1", "a2", "a3", etc.  With the original code, I was able to get the name and from that parse what abstract number to use.  Now I don't know how to figure out which abstract was clicked.  I'm attaching the selectAbstract code below.

function selectedAbstract(e:Event):void {
	var abstractName:String;// Abstract name with index (i.e., a0, a1, a2, etc.)
	var abstractIndex:Number;// Abstract number
	var strLen:Number;// Length of abstract name
 
	strLen=e.currentTarget.name.length;
	abstractName=e.currentTarget.name.substring(1);
	abstractIndex=Number(abstractName);
 
	AAPglobal.whichAbstract=abstractIndex;
	gotoAndPlay("abstractPlayer");
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

Select allOpen in new window

 

by: asaivanPosted on 2009-09-03 at 12:45:23ID: 25254239

I'm not sure how your implementing it, but you should still be able to access the e.currentTarget.name property, no?  It should still work by addEventListener( MouseEvent.CLICK, selectedAbstract ).  

 

by: asaivanPosted on 2009-09-03 at 12:49:07ID: 25254274

Come to think of it you may run into compiler errors.  You may have to cast your e.currentTarget as AbstractDisplay.

Literally

function selectedAbstract(e:Event):void {
        var abstract:AbstractDisplay = e.currentTarget as AbstractDisplay;
        var abstractName:String;// Abstract name with index (i.e., a0, a1, a2, etc.)
        var abstractIndex:Number;// Abstract number
        var strLen:Number;// Length of abstract name
 
        strLen= abstract.name.length;
        abstractName=abstract.name.substring(1);
        abstractIndex=Number(abstractName);
 
        AAPglobal.whichAbstract=abstractIndex;
        gotoAndPlay("abstractPlayer");
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

Select allOpen in new window

 

by: dyaroshPosted on 2009-09-03 at 12:51:27ID: 25254289

The problem is that the event.currentTarget.name is now hitarea_btn, not a1, a2, a3, etc.

 

by: asaivanPosted on 2009-09-03 at 13:24:42ID: 25254580

Oh, of course...duh. Try e.currentTarget.parent

 

by: dyaroshPosted on 2009-09-03 at 16:07:49ID: 31623862

Thank you so much for your help.  That did the trick.  I wish I could award you even more points.  Because of your help I will make my deadline.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...