Swipe gallery in a movie clip
Hi,
I'm using the Swipe Gallery template which works perfectly on the main timeline using the default supplied code.
However, I need to use two different swipe galleries so I'm loading them in to a "holder_mc" on the main timeline using the addChild method ie:
home_menu.button_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_4);
function fl_ClickToGoToAndStopAtFrame_4(event:MouseEvent):void
{
MovieClip(root).holder_mc.addChild(fl_Quiz);
}
I've amended the supplied code for the Swipe gallery to target the loaded mc as follows but it's not working. I'm getting this error message
I'm getting in the Adobe Air panel:
TypeError: Error #1010: A term is undefined and has no properties.
at _1BBBBBBBBB_fla::MainTimeline/frame1()[_1BBBBBBBBB_fla.MainTimeline::frame1:63]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
This is the code I'm using:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
var fl_Quiz:quiz = new quiz();
var currentGalleryItem:Number = 1;
var totalGalleryItems:Number = 4;
holder_mc.fl_Quiz.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame);
function fl_SwipeToGoToNextPreviousFrame(event:TransformGestureEvent):void
{
if(event.offsetX == 1)
{
if(currentGalleryItem > 1){
currentGalleryItem--;
slideRight();
}
}
else if(event.offsetX == -1)
{
if(currentGalleryItem < totalGalleryItems){
currentGalleryItem++;
slideLeft();
}
}
}
var slideCounter:Number = 0;
function slideLeft(){
holder_mc.fl_Quiz.addEventListener("enterFrame", moveGalleryLeft);
}
function slideRight(){
holder_mc.fl_Quiz.addEventListener("enterFrame", moveGalleryRight);
}
function moveGalleryLeft(evt:Event){
holder_mc.fl_Quiz.x -= 48;
slideCounter++;
if(slideCounter == 10){
holder_mc.fl_Quiz.removeEventListener("enterFrame", moveGalleryLeft);
slideCounter = 0;
}
}
function moveGalleryRight(evt:Event){
holder_mc.fl_Quiz.x += 48;
slideCounter++;
if(slideCounter == 10){
holder_mc.fl_Quiz.removeEventListener("enterFrame", moveGalleryRight);
slideCounter = 0;
}
}
I think it's something to do with the file path I'm using but not sure what it should be. Both movie clips are loading fine in to the holder_mc on the main timeline. They're just not swiping.
Thanks for any advice.