开发者

Possible to control frame of a MovieClip that's in a Scroll Pane component?

Is there a way to control the frames of a movieclip that's in the scroll pane component?

On my stage I've got four buttons setup.

I've got the following actionscript but get an error.

import flash.events.MouseEvent;

scrollPane.source = pm_mc;
scrollPane.setSize(975开发者_运维技巧, 500);
scrollPane.scrollDrag = true;

start_but.addEventListener(MouseEvent.CLICK, start);
function start(e:MouseEvent):void
{
    scrollPane.pm_mc.gotoAndStop(1);
}

previous_but.addEventListener(MouseEvent.CLICK, previous);
function previous(e:MouseEvent):void
{
    scrollPane.pm_mc.prevFrame();
}

next_but.addEventListener(MouseEvent.CLICK, next);
function next(e:MouseEvent):void
{
    scrollPane.pm_mc.nextFrame();
}

end_but.addEventListener(MouseEvent.CLICK, end);
function end(e:MouseEvent):void
{
    scrollPane.pm_mc.gotoAndStop(31);
}

stop();

The errors I get are all the same: Access of possibly undefined property pm_mc through a reference with static type fl.containers:ScrollPane

I'm still very much learning AS3.

Thanks in advance for any responses.


You need to refer to the movie clip as:

scrollPane.source.gotoAndStop(1);

So in your code:
Replace scrollPane.pm_mc with scrollPane.source.

Update
I guess I understand what you are trying to do now. You have a symbol in your library (which is not on your stage) and you want to create an instance of it and add it to the scrollPane. If I am right try this.

import flash.events.MouseEvent;

scrollPane.source = new pm_mc();
scrollPane.setSize(975, 500);
scrollPane.scrollDrag = true;

start_but.addEventListener(MouseEvent.CLICK, start);
function start(e:MouseEvent):void
{
    scrollPane.source.gotoAndStop(1);
}

previous_but.addEventListener(MouseEvent.CLICK, previous);
function previous(e:MouseEvent):void
{
    scrollPane.source.prevFrame();
}

next_but.addEventListener(MouseEvent.CLICK, next);
function next(e:MouseEvent):void
{
    scrollPane.source.nextFrame();
}

end_but.addEventListener(MouseEvent.CLICK, end);
function end(e:MouseEvent):void
{
    scrollPane.source.gotoAndStop(31);
}

stop();

Note the new pm_mc(). It creates an instance of the library symbol (a MovieClip).

Also you can refer to the scrollPane contents like this

((MovieClip)(scrollPane.content)).nextFrame();

Both the content and the source should work for your purpose.


you are getting errors because you are getting movieclip from scrollPane in wrong way. check following code.

start_but.addEventListener(MouseEvent.CLICK, start);
function start(e:MouseEvent):void
{
    (Object(scrollPane.content)).gotoAndStop(1);
}

i hope it will work...............

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜