Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Swipe gallery in a movie clip

Explorer ,
Dec 17, 2017 Dec 17, 2017

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.

TOPICS
ActionScript
546
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2017 Dec 17, 2017

which is line 63?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 17, 2017 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2017 Dec 17, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 17, 2017 Dec 17, 2017

So is it just seeing the blank holder_mc before before .fl_Quiz has been loaded with the addChild function?

Is that what you think is happening? That kind of makes sense to me because the button that calls the Child (.fl_Quiz) into the holder_mc has not been activated.

If that is the case, I've got no idea how to resolve that!?

I'm confused!??

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2017 Dec 17, 2017

i can't say why the problem is occurring when it's occurring with checking your fla (which i don't do unless hired).

you should be able to track the problem by using the trace function. using

trace(this.name) in the problematic movieclip should help find the problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 17, 2017 Dec 17, 2017
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines