View Full Version : [AS3] scrollpane a movie clip

11-02-2009, 05:05 AM
I am new to actionscript 3.0 and am having problems when adding a scrollpane to my flash file. I want to scroll a movie clip. My scrollpane instance is aSp and my movie clip name is vendor_scroll. This is what I have:

import fl.events.ScrollEvent;

aSp.setSize(245, 458);

function scrollListener(event:ScrollEvent):void {
trace("horizontalScPosition: " + aSp.horizontalScrollPosition +
", verticalScrollPosition = " + aSp.verticalScrollPosition);
aSp.addEventListener(ScrollEvent.SCROLL, scrollListener);

aSp.source = vendor_scroll;

this.aSp.horizontalScrollPolicy = "off";

***And this is the error message I am receiving:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/addChildAt()
at fl.controls::BaseButton/drawBackground()
at fl.controls::LabelButton/draw()
at fl.core::UIComponent/callLaterDispatcher()

Any help would be greatly appreciated!

11-02-2009, 08:06 AM
Did you remember to add the needed skin symbols to the library?

11-02-2009, 11:49 AM
If you hadn't already figure this out, just drag an instance of the scrollPane component onto the stage and then delete it. This will add the component to your library. I don't think you need to use the word "this" in your scrollPolicy. It should work with out that.

11-02-2009, 03:35 PM
The skins are in the library and the instance "aSp" of the scrollpane is on the stage. If I delete that instance my movie doesn't work since the actionscript has that instance name in it. Is there something I should change in the actionscript as well?

11-02-2009, 03:56 PM
This new actionscript below made my scrollpane work. However I have a new problem now. My Flash file has 9 scenes. Once I go to the scene where the scrollpane is and then go to another scene it shows up in every scene. How do I change this?

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

var aSp:ScrollPane = new ScrollPane();

var vendor_scroll:cat = new cat();

aSp.source = vendor_scroll;
aSp.setSize(245, 458);
aSp.move(332, 120);

aSp.horizontalScrollPolicy = "off";


aSp.addEventListener(Event.ENTER_FRAME, aSp_ENTERFRAME);

function aSp_ENTERFRAME(e:Event):void
trace("horizontalScPosition: " + aSp.horizontalScrollPosition +
", verticalScrollPosition = " + aSp.verticalScrollPosition);

11-02-2009, 06:13 PM
I got the same problem with my scrollPane. I am not sure how to correct it.