Posts Tagged ‘Flash As3’

Bug in photoflipcs_v_1_4_0 opening popup twice

March 5, 2010

Original photoflipcs code:
In the below code if you click on any frame, pop up will open twice.
You can trace this by adding trace(event.index); to below code.
//import event
import com.digicrafts.events.*;

//add click action to the photoflip
photoflip.addEventListener(ItemEvent.CLICK, iEventHandler);
photoflip.addEventListener(ItemEvent.CHANGE, iEventHandler);
/*
photoflip.addEventListener(ItemEvent.DOUBLE_CLICK, iEventHandler);
photoflip.addEventListener(ItemEvent.MOUSE_OVER, iEventHandler);
photoflip.addEventListener(ItemEvent.MOUSE_OUT, iEventHandler);
photoflip.addEventListener(ItemEvent.SELECT, iEventHandler);
*/

function iEventHandler(event:ItemEvent){
switch(event.type){
//Event when selection change
case ItemEvent.CHANGE:
//change the caption to filename
caption.htmlText = event.item.title;
//Event when click on the item
case ItemEvent.CLICK:
ExternalInterface.call(‘pathtoxmlfile’);

break;
default:
break;
}

}

Corrected code:

import com.digicrafts.events.*;
var currentcoverage:Object;
var selectedItemIndex:Number = 0;

//Event handler for the item

photoflip.load(this.root.loaderInfo.parameters[“xmlFile”]);

function mouseMoveHandler(event:ItemEvent):void
{

selectedItemIndex = Number(event.index);
caption.htmlText = event.item.title;
currentcoverage = event.item;
if(Number(event.index) == selectedItemIndex)
ExternalInterface.call(“function_name”,currentcoverage.title,xyz……….);

}
photoflip.addEventListener(ItemEvent.MOUSE_UP,mouseMoveHandler);

Advertisements