Skip to main content
Inspiring
January 21, 2022
Answered

Coming back to Animate after 2 years...need some basic help re: Scrollpane content in AS3

  • January 21, 2022
  • 2 replies
  • 446 views

I have found a snippet that will add a scrollpane to my timeline and it draws a red box for the content.  That's working fine.  Now I want to add my own movieclip to the scrollpane and it's not readily apparent to me how to do that.

Here is the code I'm using to draw the scrollpane...how do I add a movieclip to the pane?

import fl.containers.ScrollPane;
import fl.controls.ScrollPolicy;
import fl.controls.DataGrid;
import fl.data.DataProvider;

var aSp:ScrollPane = new ScrollPane();
var aBox:MovieClip = new MovieClip();
drawBox(aBox, 0xFF0000); //draw a red box

aSp.source = aBox;
aSp.setSize(1340, 170);
aSp.move(570, 120);

addChild(aSp);

function drawBox(box:MovieClip,color:uint):void {
box.graphics.beginFill(color, 1);
box.graphics.drawRect(0, 0, 1650, 150);
box.graphics.endFill();
}

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Hi.

 

Set the content you want to scroll as the source.

aSp.source = snapshottiles;

 

Please notice that you can also add the component using the IDE  by going to Window > Components.

 

I hope this helps.

 

Regards,

JC

2 replies

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
January 21, 2022

Hi.

 

Set the content you want to scroll as the source.

aSp.source = snapshottiles;

 

Please notice that you can also add the component using the IDE  by going to Window > Components.

 

I hope this helps.

 

Regards,

JC

Inspiring
January 21, 2022

Thanks for the feedback. I tried that and nothing shows up on the page.  No red box, no scrollpane, no nothing.

JoãoCésar17023019
Community Expert
Community Expert
January 21, 2022

Oh I see. For being able to add components at runtime, you have to first add any component to the stage, delete it on stage and keep the symbols and bitmaps in the Library so that Animate will recognize the related classes. Yeah, I know, it's weird, but that's the way things are...

Inspiring
January 21, 2022

I have a movieclip on the stage named membersnapshottiles with an instance name of snapshottiles...this is the clip I want in the scrollpane.