PDA

View Full Version : [AS3] How to use a button within a moviclip into a ScrollPane


ryosaeb4
05-06-2010, 10:12 AM
Hi everybody..

I've a ScrollPane component on my time line called scrollX.
The scrollX source is a movieclip called contentX from library.

Now inside my contentX I've a button whit this code:


inviaScriviBTN.addEventListener (MouseEvent.MOUSE_DOWN, goReplyScrivi);
function goReplyScrivi (event:MouseEvent):void
{
MovieClip(root).gotoAndStop ("invio_con_successo");
trace("invio_con_successo");
}


I need go to a label called "invio_con_successo" into my root timeline (where the scrollpane live).

But It dosn't work... may be the MovieClip path is wrong...

How Can I do it?
:confused:


I've this error:
ArgumentError: Error #2109: Frame label invio_con_successo not found in scene Scena 1.
at flash.display::MovieClip/gotoAndStop()
at contentX/goReplyScrivi()

blue112
05-06-2010, 10:20 AM
MouseEvent.MOUSE_DOWN => Listen to MouseEvent.CLICK instead of this one.
Then, use Stage instead of root to refer to the timeline (I believe so, it should be wrong)

Good luck.

ryosaeb4
05-06-2010, 10:26 AM
Ok I've try this:


inviaScriviBTN.addEventListener (MouseEvent.MOUSE_DOWN, goReplyScriviINPS);
function goReplyScriviINPS (event:MouseEvent):void
{
MovieClip(Stage).gotoAndStop ("invio_con_successo");
trace("invio_con_successo");
trace(MovieClip(parent.parent.parent.parent));
}


But It dosn't work may be becouse I've this path in my project:

root -> mainMobile -> htc_hd2 -> pda -> scrollPane -> inviaScriviBTN


It means that:

Root of Flash project
mainMobile is a movieclip on the 1th frame
htc_hd2 is a moviclip inside mainMobile
pda is a movieclip inside htc_hd2
scrollPane is a component on my pda movieclip
invia ScriviBTN is a button on my scrollpane

mmmmhhhh I think that i need to indicate a right path...

But which?

blue112
05-06-2010, 10:29 AM
MouseEvent.MOUSE_DOWN => Listen to MouseEvent.CLICK instead of this one. (second time).

Use "stage" instance instead of "Stage" class.

ryosaeb4
05-06-2010, 10:38 AM
MouseEvent.MOUSE_DOWN => Listen to MouseEvent.CLICK instead of this one. (second time).

Use "stage" instance instead of "Stage" class.



It dosn't work


inviaScriviBTN.addEventListener (MouseEvent.CLICK, goReplyScrivi);
function goReplyScrivi (event:MouseEvent):void
{
MovieClip(stage).gotoAndStop ("invio_con_successo");
trace("invio_con_successo");
}



Error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@50224ba1 to flash.display.MovieClip.
at contentX/goReplyScrivi()