Skip to main content
Inspiring
December 17, 2017
Question

Swipe gallery in a movie clip

  • December 17, 2017
  • 2 replies
  • 580 views

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.

This topic has been closed for replies.

2 replies

Inspiring
December 17, 2017

It's a right challenge for me but it should be straightforward enough.

If I can target nested movie clips with other functions, I should be able to do it with this swipe function.

I'll try the trace function for now and see if that helps sort it out.

Thanks.

kglad
Community Expert
Community Expert
December 17, 2017

which is line 63?

Inspiring
December 17, 2017

It's this one:

holder_mc.fl_Quiz.addEventListener (TransformGestureEvent.GESTURE_SWIPE, fl_SwipeToGoToNextPreviousFrame);

But looking at this it makes sense to me - the movie gallery I want to swipe is the one inside the holder_mc

It's obviously not working though is it!!?

Thanks

kglad
Community Expert
Community Expert
December 17, 2017

when you see that message holder_mc exists and holder_mc.fl_Quiz does not exist (as far as animate is concerned).