473,800 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listener run my function 2 times

2 New Member
Hello, I hope I could get some help with this issue, since I give up. It is too much for just me.
This script is originally from MX. I have a hard time trying to translate to AS3.
Anyway. There were a moment when I have to mix the original code with the slide show tutorial from kirupa site. Right now is almost functional. But it behave very weird when is online.
My problem is this. After all the work my final touch is to place a preloader to each loaded image(I already made it). But the secuence should be IF LOADED...then execute the FX and summ 1 number to the secuence...
At the end everything works OK, locally, but online the process show the previous images before it get to the preloader secuence of the new comming image. Becouse of this I step a few test behind the actual and noted this:
When the user see the first set of images, everything is OK, but if he move to other, then the listener seem to execute the click function 2 times, becouse the trace window show 2 outputs. At the end we have the right number, but I don't know if this is the problem.

This is the code:
[HTML]import flash.filters.B lurFilter;
import fl.transitions. Tween;
import fl.transitions. easing.*;
import fl.controls.Com boBox;
import flash.events.Ev ent;
import flash.text.Text Field;
import flash.text.Text FieldAutoSize;
import fl.data.DataPro vider;
import flash.text.Text Field;
import flash.text.Text Format;
import flash.display.* ;
import flash.net.URLRe quest;
import fl.transitions. *;


var movider:Number = 35;
var moviizq:Number = -45;
var filename:String = "modelo03.x ml";
//var filename:String = "http://quatpanama.com/qproyectos/convertidor05_f ra.php";
var foundAlbum:Numb er;
var numPhotosOnPage :Number;


var xmlLoader:URLLo ader = new URLLoader();
var album:XML = new XML();
var fileName:String ;
xmlLoader.addEv entListener(Eve nt.COMPLETE, envio);
xmlLoader.load( new URLRequest(file name));


function envio(e:Event): void {
XML.ignoreWhite space = true;
var album:XML = new XML(e.target.da ta);
newAlbum(album) ;
}

function newAlbum(album_ item:XML):void {
for (var e:int=0; e<album_item.le ngth(); e++) {
if (album_item[e].name().localNa me == "albums") {
var albumsDescrypti on:XML = new XML();
albumsDescrypti on = album_item[e];
}
}
buildAlbumList( albumsDescrypti on);
}
var albumCount = 0;

function buildAlbumList( albumsDescrypti on:XML):void {
var albdesc_pars:XM LList = albumsDescrypti on.photoset;
//trace(albdesc_p ars.length());
for (var u:int=0; u<albdesc_pars. length(); u++) {
var albumes_long:Nu mber = albdesc_pars.le ngth();
var album_element:X ML = albdesc_pars[u];
if (album_element. name() == "photoset") {
var etiqueta:String = album_element.a ttribute("name" );
var datos:String = album_element.a ttribute("name" );
combo(etiqueta, datos);
}
}
if (albumCount>0) {
chooseAlbum.sel ectedIndex = 0;
var currentAlbum = chooseAlbum.sel ectedItem.data;
//trace("cierto") ;
//trace(albumDesc );
cambiador();
}
function cambiador() {
var currentAlbum = chooseAlbum.sel ectedItem.data;
var showPhoto = 0;
var isNewAlbum = 1;
var albumselect = chooseAlbum.sel ectedIndex;
album_label.tex t = albdesc_pars[albumselect].attribute("alb um_desc");
findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album);
}

////////////FUNCIONS del COMBObox //////////////////////////////////////////////////////////////////////////
//funcion de llenado
function combo() {
albumCount++;
chooseAlbum.add Item( { label: etiqueta, data: datos } );
chooseAlbum.add EventListener(E vent.CHANGE, changeAlbum);
}
//FUNCION DEL CLICK
function changeAlbum (event:Event):v oid{
var currentAlbum = chooseAlbum.sel ectedItem.data;
//trace(currentAl bum);
var showPhoto = 0;
var isNewAlbum = 1;
var albumselect = chooseAlbum.sel ectedIndex;
//trace(albumsele ct);
//album_label.tex t = "wewewe";
//album_label.tex t = albdesc_pars[albumselect].toString();
album_label.tex t = albdesc_pars[albumselect].attribute("alb um_desc");
//trace(albdesc_p ars[albumselect].attribute("alb um_desc"));
findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album);
}

// FIN DEL COMBOBOX ///////////////////////////////////////////////////////////////////////////////////////////
function findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album) {
//trace(albumsDes cryption.childr en().length());
for (var ui=0; ui<albumsDescry ption.children( ).length(); ui++) {
//trace ("looking for match: currentAlbum "+currentAl bum + " to " + albumsDescrypti on.children()[ui].attribute("nam e").toLowerCase ());

if (albumsDescrypt ion.children()[ui].attribute("nam e").toLowerCase () == currentAlbum.to LowerCase()) {
//trace("true");
foundAlbum = 1;
//trace ("-------------");
//find out where the images will be
//imgBase = albumsDescrypti on.childNodes[count02].attributes.ima gebase;
//trace ("imagebase is "+imgBase);
var photoPage = albumsDescrypti on.children()[ui];
var numPhotos = photoPage.child ren().length();
break;
}
}
//trace(photoPage );
displayPhoto(ph otoPage, numPhotos)
}


function displayPhoto(ph otoPage, numPhotos) {
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
var titulo:XMLList = photoPage.child ren().children( ).attribute("ti tle");
var fuente:XMLList = photoPage.child ren().children( ).attribute("sr c");
var desc:XMLList = photoPage.child ren().children( ).attribute("ca ption");
/*for (var a:int=0; a<titulo.length (); a++){
//trace ("ITEM "+a+"==> "+titulo[a]);
}
for (var e:int=0; e<fuente.length (); e++){
var imagesourcefile :String = fuente[e];
//trace ("ITEM "+e+"==> "+fuente[e]);
}
for (var i:int=0; i<desc.length() ; i++){
//trace ("ITEM "+i+"==> "+desc[i]);
}*/


fwdButton.addEv entListener(Mou seEvent.CLICK, nextImage);
bkButton.addEve ntListener(Mous eEvent.CLICK, prevImage);
var p = 0;
firstImage();

function firstImage() {
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[0]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[0];
photoTitleInfo. text = titulo[0];
var sentido = 30;
filtros(sentido );
picture_num();
}
var myInterval;
function nextImage(event :MouseEvent){
trace("FUNCTION START---> p: "+p);
conte.x = -52
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
p++
p %= fotonu;
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[p]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[p];
photoTitleInfo. text = titulo[p];
var sentido = 30;
trace("END OF FUNCTION-----------------> P: "+p);
filtros(sentido );
picture_num();
clearInterval(m yInterval);
}

function prevImage(event :MouseEvent){
conte.x = -52
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
clearInterval(m yInterval);
if (p>0) {
p--;
} else {
p = fotonu-1;
}
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[p]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[p];
photoTitleInfo. text = titulo[p];
var sentido = -131;
filtros(sentido );
picture_num();

}



function picture_num() {
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
var current_pos = p+1;
//trace("foto cant: "+ fotonu+"fotos actual: "+current_p os+" la P:"+p);
pos_txt.text = current_pos+" / "+fotonu;
}

function filtros (sentido){

var myTween:Tween = new Tween(conte, "blur", Elastic.easeInO ut, 20, 0, 20, false);
myTween.addEven tListener(Tween Event.MOTION_CH ANGE, handleReset);
function handleReset(e:T weenEvent):void {
conte.filters = [new BlurFilter(cont e.blur, conte.blur, 1)];
}
var xPosT:Tween = new Tween(conte, "x", Regular.easeInO ut, -52, sentido, 3, true);
xPosT.addEventL istener(TweenEv ent.MOTION_CHAN GE, marcador);
function marcador(e:Twee nEvent):void {
var val = Math.round(cont e.x);
pos.text = val;
}

}
}




}[/HTML]
Sep 9 '07 #1
0 2099

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3741
by: Cherrish Vaidiyan | last post by:
sir, I have a small error in Listener configuration.I have two system with a database in each. I am using Red Hat 9 and Oracle 9i. so i shall anme the database and system. system 1 - node2 system 2 - node3 database - apple database - intel i have installed Oracle on 'node3' by copying the files and then creating a new database in it. Now i want to configure listener. I
5
13435
by: Axel Dachtler | last post by:
Hi, I have a listener problem. The listener cannot read SERVICE_NAME in TNS-Descriptor. The service-name I specified in Oracle Net Manager for this database is testdb as well. (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=axel-0560nntbn1) (PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=testdb))) It is a local database so I tried testdb.localhost, but this didn't
1
6070
by: UNIXNewBie | last post by:
I've just installed Oracle Standard on an XP Platform for demo. The listener was not installed. I have installed Oracle many times on 2000 server and never seen an case where the listener was not installed. How can I install the listener? It does not see to appear as an option to install usising the installation tool. Thanks
3
694
by: Bill | last post by:
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...). Why doesn't this work, and is there a work around I can make on the C# side to hear the connect request? -Bill (don't reply by e-mail, the address is a fake) ______________________________ Steps to reproduce: Start the C# Listener
3
1714
by: Geoff | last post by:
I need to keep a few VB6 tcpClients active, but have them talk to a dotNet tcpServer/tcpListener. The "Server"/Listener is running as a Plugin, and needs to respond to "outside requests". The dotNet versions of the exe's that make these requests take MUCH longer to load and start than the VB6 versions, so I'd like to keep the VB6 versions active (at least until the dotNet versions will load more quickly). Is there a way for these...
6
2097
by: Daz | last post by:
Hi, I am trying to find an event listener which will trigger when the pages starts loading, as opposed to when it's finished, or when the DOM content has finished loading. I am sure that such a listener exists, but I can't seem to find it. I would appreciate any pointers. Many thanks. Daz.
5
38837
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point, I believe another set of eyes on the issue is merited. I am a MSSQL DBA and somewhat new to ORACLE; but I have read the administrators manual having a basic thorough level of knowledge (Tho' I am still learning) and understanding of how to...
4
1766
by: jackwootton | last post by:
Hello, Currently I use setInterval to call a function every 1.5 seconds. The function checks the content of 6 divs on a page. The content of each div is retrieved use innerHTML. If the content of the div has changed since it was last checked (1.5 seconds previous), then I know the div has been updated, and I need to do something. My questions is: This seems to be a resource heavy and rather clunky way of checking if a div has been...
1
7846
by: abolduc | last post by:
I have had an underwhelming amount of success hunting down the source of this error and am hoping that someone here may have some insight. Error logged in the event log: Source: MSSQLSERVER Category: (2) EVENT ID: 17887 Description: IO Completion Listener (0x754) Worker 0x00FEC0E8 appears to be non-yielding on Node 1. Approx CPU Used: kernel 0 ms, user 0 ms, Interval: 15187.
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7574
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.