Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
which is line 63?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
when you see that message holder_mc exists and holder_mc.fl_Quiz does not exist (as far as animate is concerned).
Copy link to clipboard
Copied
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!??
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now