Copy link to clipboard
Copied
Hello every one. iam new to flash as developing. i develop one scrooll thumb xml image gallery.
now iam try to convert Touch application .
in this i have one problam Regarding swipeing .
please any body help me.
Here is XML data ("Images.xml")
<?xml version="1.0" encoding="utf-8"?>
<PLAYLIST THUMB_WIDTH="125" THUMB_HEIGHT="70" THUMBS_X="10" THUMBS_Y="295" VIDEO_X="10" VIDEO_Y="10" >
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb1.jpg" big_img="big_imgs/11.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb2.jpg" big_img="big_imgs/22.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb3.jpg" big_img="big_imgs/33.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb4.jpg" big_img="big_imgs/44.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb5.jpg" big_img="big_imgs/55.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb1.jpg" big_img="big_imgs/11.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb2.jpg" big_img="big_imgs/22.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb3.jpg" big_img="big_imgs/33.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb4.jpg" big_img="big_imgs/44.jpg"/>
<VIDEO TITLE="Lincoln Memorial Concert" THUMB="thumbs/thumb5.jpg" big_img="big_imgs/55.jpg"/>
</PLAYLIST>
Here is My script :
import fl.video.*;
import flash.ui.Mouse;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.text.*
import flash.events.*;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.events.TransformGestureEvent;
Multitouch.inputMode=MultitouchInputMode.GESTURE;
Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;
var speed:Number;
var padding:Number = 5;
var thumb_width:Number;
var thumb_height:Number;
var thumbs_x:Number;
var thumbs_y:Number;
var video_x:Number;
var video_y:Number;
var my_videos:XMLList;
var my_total:Number;
var spl_height:Number;
var spl_width:Number;
var main_container:MovieClip;
var thumbs:Sprite;
var titles:Sprite;
var my_player:FLVPlayback;
var normal:MovieClip;
var title_txt:TextField = new TextField();
var thumb_title
var mc:MovieClip;
var images_loader = new Loader();
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("Images.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
thumb_width = myXML.@THUMB_WIDTH;
thumb_height = myXML.@THUMB_HEIGHT;
thumbs_x = myXML.@THUMBS_X;
thumbs_y = myXML.@THUMBS_Y;
video_x = myXML.@VIDEO_X;
video_y = myXML.@VIDEO_Y;
my_videos = myXML.VIDEO;
my_total = my_videos.length();
makeContainers();
callThumbs();
callimages();
}
mmc5.alpha=0;
function makeContainers():void {
main_container = new MovieClip();
addChild(main_container);
thumbs = new Sprite();
thumbs.addEventListener(TouchEvent.TOUCH_BEGIN, playVideo);
thumbs.addEventListener(TouchEvent.TOUCH_ROLL_OVER, onOver);
thumbs.addEventListener(TouchEvent.TOUCH_ROLL_OUT, onOut);
thumbs.x = thumbs_x;
thumbs.y = thumbs_y;
thumbs.buttonMode = true;
main_container.addChild(thumbs);
titles = new Sprite();
titles.x = thumbs_x;
titles.y = thumbs_y;
main_container.addChild(titles);
}
function callThumbs():void {
for (var i:Number = 0; i < my_total; i++) {
var thumb_url = my_videos.@THUMB;
var thumb_loader = new Loader();
thumb_loader.name = i;
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.x = (thumb_height+35)*i;
}
}
function callimages():void {
var images_url = my_videos[0].@big_img;
images_loader.load(new URLRequest(images_url));
images_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imagesLoaded);
function imagesLoaded(e:Event):void {
addChild(images_loader);
images_loader.x=10;
images_loader.y=-10;
spl_width=images_loader.width
spl_height=images_loader.height
}
}
function thumbLoaded(e:Event):void {
var my_thumb:Loader = Loader(e.target.loader);
thumbs.addChild(my_thumb);
thumbs.y =330.85;
thumbs.x = padding;
thumbs.mask=box_mc;
thumbs.addEventListener(Event.ENTER_FRAME, moveScrollerThumbs);
thumbs.addEventListener(TransformGestureEvent.GESTURE_SWIPE, moveScrollerThumbs)
}
function moveScrollerThumbs(e:TransformGestureEvent):void {
if ( e.offsetX > thumbs.y && e.offsetY < thumbs.y + thumbs.height) {//vertically over thumbs
if (e.offsetX < stage.stageWidth/2 - padding*2 && e.offsetX > 0) {//left of stage explicitly
speed = -(e.offsetX - (stage.stageWidth/2 - padding*2)) / 10;
} else if (e.offsetX > stage.stageWidth/2 + padding*2 && e.offsetX < stage.stageWidth) {//right of stage explicitly
speed = -(e.offsetX - (stage.stageWidth/2 + padding*2)) / 10;
} else {
speed = 0;
}
thumbs.x += speed;
//thumbs limits
if (thumbs.x < -thumbs.width + stage.stageWidth - padding) {//if scrolled too far left
thumbs.x = -thumbs.width + stage.stageWidth - padding;
} else if (thumbs.x > padding) {//if scrolled to far right
thumbs.x = padding;
}
}
}
function playVideo(e:TouchEvent):void {
var images_url=my_videos[e.target.name].@big_img;
images_loader.load(new URLRequest(images_url));
}
function onOver(e:TouchEvent):void {
var my_thumb:Loader = Loader(e.target);
my_thumb.alpha = 0.5;
}
function onOut(e:TouchEvent):void {
var my_thumb:Loader = Loader (e.target);
my_thumb.alpha = 1;
}
btn_full.addEventListener(TouchEvent.TOUCH_BEGIN, stageResize);
images_loader.addEventListener(TouchEvent.TOUCH_BEGIN, stageResize1);
function stageResize(e:TouchEvent):void
{
var ev:Event=new Event("clicks",true);
mmc5.addEventListener(MouseEvent.CLICK, stageResize1);
this.addChild(mmc5);
mmc5.alpha=1;
mmc5.x=btn_full.x+285;
mmc5.y=btn_full.y+195
this.dispatchEvent(ev);
function ext(){
stage.displayState = StageDisplayState.NORMAL;
images_loader.height=spl_height
images_loader.width=spl_width
}
this.StageAlign=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.EXACT_FIT;
images_loader.scaleX = images_loader.scaleY = 1;
if( stage.displayState == StageDisplayState.NORMAL ){
stage.displayState = StageDisplayState.FULL_SCREEN;
} else {
}
if ((stage.stageHeight / stage.stageWidth) <images_loader.height / images_loader.width) {
images_loader.width = stage.stageWidth;
images_loader.scaleY = images_loader.scaleX;
} else {
images_loader.height = stage.stageHeight;
images_loader.scaleX =images_loader.scaleY;
};
images_loader.x = stage.stageWidth / 2 - images_loader.width / 2;
images_loader.y = stage.stageHeight / 2 - images_loader.height / 2;
}
function stageResize2(e:TouchEvent):void
{
mmc5.alpha=0;
images_loader.height=1000
images_loader.width=600
}
function stageResize1(e:TouchEvent):void
{
stage.displayState = StageDisplayState.NORMAL;
var ev:Event=new Event("clicks1",true);
this.dispatchEvent(ev);
images_loader.height=spl_height
images_loader.width=spl_width
images_loader.x=10;
images_loader.y=-10;
mmc5.x=btn_full.x-30
mmc5.alpha=0
}
Anybody Please give some suggusation.
Thank you.
Copy link to clipboard
Copied
I don't really have time to look at all your code, but here's another thread about a similar topic. http://forums.adobe.com/thread/873313
Copy link to clipboard
Copied
Hello phonefusionryan,
Thanks for your timely reply.
Regards
P,NAGARAJU
Copy link to clipboard
Copied
You are making calls to both the Transformgesture event AND the TouchEvent methods. You can only use one at a time. I would suggest refactoring the touchevents to use traditional MouseEvents.
There is a gallery sample that is included in the templates for Flash Professional. It might help you along.
Chris
Copy link to clipboard
Copied
Hello Chris W. Griffith,
Thanks for your timely reply
could you please suggest me with the URL for sample gallery on Flash Professional.
Regards.
P,NAGARAJU
Copy link to clipboard
Copied
Launch Flash Pro CS5.
File > New
Change to the template tab.
Select AIR for Android
You should see the Swipe Gallery listed.
Chris
Copy link to clipboard
Copied
Hi Chris W. Griffith,
great it was helpful to me, a new problem raised now....
everything is working fine now
1.Multitouch.inputMode=MultitouchInputMode.GESTURE;
2.Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;
when i comment line 2 swipe is working and when i comment line 1 touch is working, i need both to work simultaniously... Thanks in advance and thanks for your time.
Regards
Nagaraju!
Copy link to clipboard
Copied
Exactly, one can only use ONE input mode at a time. Disbale TOUCH_POINT, and change all event handlers that you were using TOUCH_POINTS for into traditional MouseEvents.
Chris
Copy link to clipboard
Copied
Have a look at greensocks ThrowProps plugin and blitMask.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now