Pagination With Actionscript
I have a simple script that attaches movie clips based on the number of items I have in my array. It currently spits out all of items in one long list. How, with actionscript, can I get my long list to paginate. I basically need it setup such that once I change a variable, that will control the number of items i see. Then i can click next or previous buttons to navigate thorugh the rest of my items. Any help with this would be greatly appreciated.
// ================ // code below // ================
names =[ "Mike", "John", "Bob", "Chris", "Peter", "Steve", "Jason", "Paul", "David", "Brandon", "Walter", "Joe", "Ariel", "Teresa", "Nancy", "Jane", "Brian", "Patrick", "Mark", "Peter", "Michelle", "Michael", "Richard", "Jennifer", "Jane", "Doug", "Jack", "Allan", "Nancy", "Nick", "Dylan", "Sean", "Julie", "Jackie", "Lisa", "Donna", "Vince", "Ronald", "Josh", "Don"];
nameCount = names.length;
for(var i = 0; i < nameCount; i++) {
var oInit:Object = new Object(); oInit._x = 0; oInit._y = i * 20;
item = listContainer.attachMovie("nameItem", "item" + i, i, oInit); item.label.text = names[i]; }
FlashKit > Flash Help > Flash ActionScript
Posted on: 12-29-2006, 05:29 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pagination With Actionscript
I have a simple script that attaches movie clips based on the number of items I have in my array. It currently spits out all of items in one long list. How, with actionscript, can I get my long list to paginate. I basically need it setup such that once I change a variable, that will control the number of items i see. Then i can click next or previous buttons to navigate thorugh the rest of my items. Any help with this would be greatly appreciated.
// ================
// code below
// ================
names =[
"Mike", "John", "Bob", "Chris", "Peter", "Steve", "Jason", "Paul", "David", "Brandon", "Walter", "Joe", "Ariel", "Teresa", "Nancy", "Jane", "Brian", "Patrick", "Mark", "Peter", "Michelle", "Michael", "Richard", "Jennifer", "Jane", "Doug", "Jack", "Allan", "Nancy", "Nick", "Dylan", "Sean", "Julie", "Jackie", "Lisa", "Donna", "Vince", "Ronald", "Josh", "Don"];
nameCount = names.length;
for(var i = 0; i < nameCount; i++) {
var oInit:Object = new Object();
oInit._x = 0;
oInit._y = i * 20;
item = listContainer.attachMovie("nameItem", "item" + i, i, oInit);
item.label.text = names[i];
}
Pagination With Actionscript
I have a simple script that attaches movie clips based on the number of items I have in my array. It currently spits out all of items in one long list. How, with actionscript, can I get my long list to paginate. I basically need it setup such that once I change a variable, that will control the number of items i see. Then i can click next or previous buttons to navigate thorugh the rest of my items. Any help with this would be greatly appreciated.
// ================
// code below
// ================
names =[
"Mike", "John", "Bob", "Chris", "Peter", "Steve", "Jason", "Paul", "David", "Brandon", "Walter", "Joe", "Ariel", "Teresa", "Nancy", "Jane", "Brian", "Patrick", "Mark", "Peter", "Michelle", "Michael", "Richard", "Jennifer", "Jane", "Doug", "Jack", "Allan", "Nancy", "Nick", "Dylan", "Sean", "Julie", "Jackie", "Lisa", "Donna", "Vince", "Ronald", "Josh", "Don"];
nameCount = names.length;
for(var i = 0; i < nameCount; i++) {
var oInit:Object = new Object();
oInit._x = 0;
oInit._y = i * 20;
item = listContainer.attachMovie("nameItem", "item" + i, i, oInit);
item.label.text = names[i];
}
Actionscript Gallery Pagination Help?
I've been unsuccessfully trying to implement pagination in a xml gallery with thumbnails. I use the method on the kirupa site for loading the xml and generating the thumbnails:
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
thedate = [];
link = [];
linktxt = [];
_global.total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thedate[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
link[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
linktxt[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
thumbnailer(i);
if (linktxt[i] == undefined) {
linktxt[i] = "";
}
}
} else {
trace("file not loaded!");
}
}
and the thumbnails --
Code:
function thumbnailer(k) {
loaded_counter = 0;
total_thumbs = _global.total;
var page:Number = 1;
var limit:Number = 15;
var row:Number = 0;
var totalPages:Number = Math.ceil(total/limit);
port_mc.pageTxt = "page "+page+" of "+totalPages;
var container = eval("port_mc.t"+k);
trace(k);
var image = container.createEmptyMovieClip("img", "port_mc.t"+k.getNextHighestDepth());
removeMovieClip(container.circle);
//trace (eval(container));
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
if (total>14) {
port_mc.prev_mc._visible = false;
port_mc.next_mc._visible = false;
port_mc.pagenum._visible = false;
}
port_mc.next_mc.onRelease = function() {
}
port_mc.prev_mc.onRelease = function() {
}
target_mc.pictureValue = k;
target_mc.filters = [dropShadow];
target_mc.onRelease = function() {
//p = this.pictureValue;
p = this.pictureValue-1;
nextImage();
//trace(container.img);
container.attachMovie("indicate_mc", "circle", container.getNextHighestDepth());
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k],"port_mc.t"+k+".img");
}
I have a mc with 15 thumbnail holders in which the first 15 images are loaded, then I want to have a prev and next button which will load the next 15 images into the holders. Any step in the right direction will be greatly appreciated. Thanks!
Pagination
Hi
I am having to load a large amount of variables into flash to be outputted, and instead of scrolling them I want to use pagination.
Does anybody have any ideas on how I could sort, and then group my data into small groups and the allow user to select them as s/he wish's.
Thanks
Pagination With XML
Hi gang. Plese, i have problens with pagination and xml. I triing to some days without sucess. Some one can help me?
My code without pagination.
HTML Code:
var menuXML:XML = new XML();
menuXML.ignoreWhite = true;
menuXML.load("inicio.xml");
//Declarando a função montaMenu
function montaMenu() {
var menuBot:String = "modelos_mc2";
//Colocamos aqui o valor do Linkage do nosso MovieClip
var posX:Number = -150;
//Posição inicial de X
var posY:Number = -135;
//Posição inicial de Y, mais a frente entenderão o porque do -20
//Criamos um for que criará um item no menu para cada valor do XML
for (var i = 0; i<menuXML.childNodes[0].childNodes.length; i++) {
//Criamos 2 variáveis que conterão os valores dos atributos do xml (titulo e url) para que possamos acessar esses valores através dessas variáveis
var titulo:String = (menuXML.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue);
var link:String = (menuXML.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue);
var link2:String = (menuXML.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue);
//
//
//O valor da variável link será o mesmo do atributo url do xml
this.attachMovie(menuBot, titulo, i+10);
//Anexamos o MovieClip "itemMenu" no _root do filme, o novo nome dele será o correspondente a variável titulo, que contém o valor do atributo titulo do xml. o i+10 é o valor de i somado a 10 que será o nível do MovieClip no palco
var item:Object = this[titulo];
//Criamos um novo objeto. os [] tem a mesma função que o eval(), com a diferença que o eval não pode acessar valore do objeto e propriedades. Para saber mais F1 =)
item.tituloItem.text = (titulo);
item.rollover_mc.texto_txt.text = (titulo);
//Definimos o valor do texto tituloItem do item
item._x = posX += (item._height)+2;
//Definimos a posição X de item sendo igual a da variável posX
item._y = posY;
//Definimos a posição Y de item sendo igual a da variável posY = posY +(altura de item)+1
item.link = (link);
item.especificacoes = (especificacoes);
item.dados = (dados);
item.link2 = (link2);
item.zoom = (zoom);
item.zoomdois = (zoomdois);
item.desenho = (desenho);
item.titulo2 = (titulo2);
//if (variavel == undefined) {
//variavel = " ";
//}
//Definimos o valor link ao objeto item
//Ação onRelease do objeto
loadMovie(item.link, (""+item.picture+""));
item.teste_txt.text = item.titulo2;
item.teste2_txt.text = item.dados;
item.onRelease = function() {
};
//Ação onRelease
item.onRelease = function() {
_root.boka.alphaTo(100, 1);
_root.xml_txt.text = (this.link2);
_root.mask1_mc.alphaTo(100, 1);
_root.boka.menuXML2.load(""+_root.xml_txt.text+"");
_root.mask1_btn._visible = true;
_root.mask1_btn.useHandCursor = false;
_root.item_mc.alphaTo(100, 1);
_root.boka._visible = true;
};
//Ação onRollOver
item.onRollOver = function() {
_root.xml_txt.text = (this.link2);
this.rollover_mc.alphaTo(100, 1);
//this.rollover_mc.texto_txt.text = (titulo);
};
//Ação onRollOut
item.onRollOut = function() {
this.rollover_mc.alphaTo(0, 1);
};
}
}
menuXML.onLoad = function(ok) {
if (ok) {
montaMenu();
} else {
trace(orrra);
}
};
tanks.
Pagination
Hey Guys,
Looking for a little guidance.
I have an xml file. it has a title and a description tag with properties (not attributes).
i've loaded the xml file into flash and stored the results in 2 arrays.
titles[] and descs[].
What id like to do is create pagination showing 6 items at a time and u can paginate through the pages to show the next 6 items and so on and so forth.
At the moment i can scroll to the next and previous result with controls ive made.
Could any1 direct me on how i would go about creating a pagination system.
Cheers
Hkl
Pagination With AS3
How do you pagintate with AS3? I'm using a htmlText to display XML info but I cant figure out how to paginate with that object. Any help is greatly appreciated!
.: Pagination :.
Hello,
I´m working on a Flash site for a women´s clothing store. I´ve got everything pretty much figured out, but I´m having trouble with pagination from thumbnails. Anyway...here is what I want to happen. The thumb url is pulled from a XML file. I want AS to read through the XML and load all the thumbs into a 4 col. x 3 lines grid with a certain spacing between them. That gives me 12 thumbs per grid. The Problem is that I have 32 thumbs. So I want to be able to show only 12 thumbs at a time.
Bellow the thumbs I´d like to have dinamically generated links with number of "pages", so that when the user clicks o a number, he or she will see a different set of thumbs.
Example:
1 2 3
Clicking on "1", would show the 12 first thumbs.
Clicking on "2", would show from thumb 13 - 24.
Clicking on "3", would show from thumb 25 - 32.
When the user clicks on a thumb, a larger image is then loaded on large movieclip.
This is what I have done so far:
XML File read [OK]
Thumbs load on a 4x3 grid through a function called loadThumbs() [OK]
Page number links generated automatically using array.length calculation and for loop. [OK]
Each number link takes me ONLY to it´s respective thumbnail set [FAIL]
Previous thumbs are removed when a particular thumbset has less than 12 thumbs [FAIL]
Anyway...it´s a little confusing. Right now..no matter which number link I click, it´ll always give me the next 12 thumbs. And when I get to the last thumbset with only 6 thumbs, The first 6 thumbs are replaced with new ones, but the last 6 are not removed.
Here is my code:
Code:
//init global variables and properties
Stage.scaleMode = "noscale";
import gs.TweenFilterLite;
import gs.TweenLite;
import mx.transitions.*;
import mx.transitions.easing.*;
/****************************************************************************
XML LOADING
****************************************************************************/
//handle loading of external images..
var slide:XML = new XML();
slide.ignoreWhite = true;
var counter:Number = 0;
var largeImageUrl:Array = new Array();
var thumbUrl:Array = new Array();
var captions:Array = new Array();//not used
var p:Number = 0;//tracks position in arrays
var maxThumbs:Number = 12;
k = 0;
j = 0;
var totalImages:Number = 0;
slide.onLoad = function() {
largeImageUrl = [];
thumbUrl = [];
xmlNode = this.firstChild;
colecao_txt.text = xmlNode.attributes.nome;
var images:Array = this.firstChild.childNodes;
totalImages = images.length;
for (i=0; i<images.length; i++) {
thumbUrl[i] = xmlNode.childNodes[i].attributes.thumb;
largeImageUrl[i] = xmlNode.childNodes[i].attributes.largeimg;
}
//load the thumbs
pagination();
loadThumbs();
};
slide.load("xml/colecoes.xml");//load xml
var imageWidth:Number = 0;//default x position of our movieclips relative to containing movieclip
var buffer:Number = 20;//padding between images
var thumbsToShow:Number = 5//
/****************************************************************************
LOAD THUMBNAILS, ADD ACTIONS & PADDING TO THUMBS
****************************************************************************/
//here we load in our thumbnails
function loadThumbs() {
// Define number of clips per line
if (k == 4){
j++;
};
if (k > 3){
k = 0;
};
//remove the movieclip loade listener on each iteration of this function
Clip.removeListener(mclListener);
//attach and associate with a variable a MC to hold each loaded movieClip
var container:MovieClip = this.thumbHolder.attachMovie("mini_mc", "thumbBox"+p, counter, {_x:0+(7*k + k*80), _y:0+(7*j+ j*107)});
k++;
//create a movieclip loader
var Clip:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
target_mc._alpha = 0;//set thumb alpha to be zero
};
//handle loading progress - simple counter here
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//use this if you want to indicate loading of your thumbnails etc...
//loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
//here we can access our loaded clips properties!
//here is where we attach functions to our clip so that we can dynamically create rollovers etc.
//make our thumbnails visible again
TweenLite.to(target_mc, 2, {_alpha:100});
//based off image width this places our thumbs next to each other
imageWidth = (imageWidth+target_mc._width)+buffer;
//associate a variable here with our p value, we use this later to load in large images
target_mc.pictureValue = p;
//handle image rollovers these are active only on the thumb image!!! Watch the US spelling!
target_mc.onRollOver = function() {
TweenFilterLite.to(target_mc,.4,{type:"Color", brightness:1.5, ease:None.easeOut});
};
target_mc.onRollOut = function() {
TweenFilterLite.to(target_mc,4,{type:"Color", brightness:1, ease:None.easeOut});
};
//handle a click on a thumbnail
target_mc.onRelease = function() {
//load large images
var tween:Tween = new Tween(largeImage_mc, "_alpha", Regular.easeInOut, 0, 100, 3, true);
mcLoader.loadClip(largeImageUrl[target_mc.pictureValue],largeImage_mc);
};
p++; //increment value to cycle through array
counter++; //increment value to stop at 12 thumbs
if (counter<maxThumbs){
loadThumbs();//create loop
}
else{
}
};
//load in the next thumb
Clip.addListener(mclListener);
Clip.loadClip(thumbUrl[p],container);
}
/****************************************************************************
LOAD LARGE IMAGES MOVIECLIP LOADER FUNCTION
****************************************************************************/
/*generic load object here we handle loading in external images etc
this block of code loads the large images into the bright blue mc
for instance, you could fade in/out big images or make a progress indicator
using this block of script*/
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadStart = function(target_mc:MovieClip) {
//empty
};
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//amountLoaded = Math.floor((bytesLoaded/bytesTotal)*100);//calulate a loading percentage!
};
listener.onLoadInit = function(target:MovieClip):Void {
//empty
};
mcLoader.addListener(listener);
/****************************************************************************
PAGINATION
****************************************************************************/
// NUmber of thumbs per page
function pagination() {
var thumbHolder:MovieClip = this.createEmptyMovieClip("thumbHolder",100);
thumbHolder._x= 500;
thumbHolder._y= 80;
if (totalImages < 12){
target_mc.pictureValue=0;
loadThumbs();
}
else{
var totalPages:Number =totalImages/maxThumbs;
totalPages = Math.round(totalPages);
for(i=0;i<totalPages;i++){
var pageNumber:MovieClip = this.createEmptyMovieClip("pageNumber"+i,this.getNextHighestDepth());
this["pageNumber"+i]._y = 450;
this["pageNumber"+i]._x = 500 + (7*i + i*20);
var numberText:TextField = this["pageNumber"+i].createTextField("number",1,0,0,20,20);
numberText.text=i+1;
this["pageNumber"+i].onRelease=function(){
k=0;
j=0;
counter=0;
target_mc.pictureValue=0;
loadThumbs();
}
}
}
}
Any help with this would VERY MUCH apreciated.
Thanks.
Pagination Incrementation
Gads. I know there's a way to do this. I'm developing a slide show (very similar to powerpoint, actually) and I would really like to have a page counter (X of Y where X is the current page and Y is the total number of pages) on each page that increments and decrements every time the user clicks the next or back buttons. The I have each "page" set up on its own scene with an action on a button click that goes to next scene or previous scene.
I know there has to be a variable set up as a counter but I"m at a loss as to where I need to start this.
Thanks in advance.
<edit> I'm using Flash MX.
Pagination With Flash 8
I wonder if anyone has been able to load external content (preferably XML) with this pagination technique:
http://ultrashock.com/tutorials/flash8/pagination.php
[AS] Flash Pagination
Hello guys, long time no see,
I have a small problem i must make a flash gallery that supports pagination, i searched in kirupa's forum, found some threads, but i didn't found the answer for my problem.
I have a xml that contains 30 pictures, i parse (read) in flash and i attach some mcs that loads those pictures. I split the pictures in 5 pages, 1 | 2 | 3 | 4 | 5 |. Until know no problems but when i press 2 the mcs 7 - 12 are shown after the 1 - 6 mcs. What i want is that the mcs 7 - 12...to appear in the same place as the mcs 1 - 6.
I have this code:
ActionScript Code:
public function xmlLoad(displayPage:Number) { this.nodes = this.xml.firstChild.childNodes; this.total = this.nodes.length; this.numPage = Math.floor (total / perPage); this.displayMax = Math.min ((displayPage + 1) * this.perPage, total); var init:Number = displayPage * this.perPage; for(var k:Number = 0; k<this.lastMc; k++) { var mc:MovieClip = _root.thumbHolder_mc["_item" + k]; mc.removeMovieClip (); } for(var i:Number = init; i < this.displayMax; i++) { this.firstMC = displayPage * this.perPage; this._thumb = this.attachMovie("_item","_item"+i,i); this._thumb._x = Math.floor(i / 3) * (this._thumb._width + this.spacer); this._thumb._y = Math.floor(i % 3) * (this._thumb._height + this.spacer); this._thumb._title._title.text = this.nodes[i].attributes.title; this._thumb._thumb.loadMovie(this.nodes[i].attributes.thumbSLink); this._thumb.id = i; this._thumb.onRelease = Delegate.createExtendedDelegate(this._thumb,this.Release,[this._thumb.id]); _root.description_mc._description = this.nodes[0].attributes.description; } this.lastMc = this.displayMax; }
*** The script is done in class, but any advice are welcome how to resolve this problem!
Initial i call xmlLoad(0) and when i press the second button i call xmlLoad(1) and so on!
I know that the answer is near, but i to blind to see it!
Thank you in advance, btibia out
Text Pagination In AS 3.0
Has anyone attempted to update the great Ultrashock pagination tutorial to AS 3.0?
http://www.ultrashock.com/tutorials/...pagination.php
Pagination Using Arrays: Can Someone Help?
I've been trying to figure out how to return iterative arrays from a loop for pagination. Can someone please help me accomplish this and clean up my code?
As the code stands below, I need to clean-up the remaining mc's. I plan on doing this by comparing the outputted slice arrays to the main one, and pass any keys not mentioned into to their own iterated array.
I think I'm close, but I can't get over this last hurdle alone. Help would be greatly appreciated!
Thanks
Code:
var totalImg:Array = new Array();
var howManyImgs:Number = 66;
var totImgTally:Number = null;
var count:Number = 0;
var lastCount:Number = null;
var imgPerPage:Number = 8;
for (var i:Number = 0; i < howManyImgs; i++) {
totalImg.push(this.createEmptyMovieClip("imgHolder_" + i, this.getNextHighestDepth()));
}
totImgTally = totalImg.length;
for (var j:Number = 0; j < totImgTally; j++) {
if (count <= 0) {
firstCount = count;
trace("firstCount" + firstCount);
}
count++;
trace("loop" + count);
if ((count % imgPerPage) == 0) {
//trace(totalImg / imgPerPage);
lastCount = count;
firstCount = Number(lastCount - imgPerPage);
trace("lastCount: " + lastCount);
//I'd like to return iterated arrays containing the appropriate mc's, but I don't know how. If
//I put a return statement in, this loop quits, but I don't know why.
var tempLoopArray:Array = totalImg.slice(firstCount, lastCount);
trace("tempLoopArray" + tempLoopArray);
}
// As it stands, I need to clean-up the remaining mc's. I plan on comparing the sliced
//arrays to the main one, and pass the remaining keys to their own iterated array.
}
I was able to find a solution after a few days hacking it up. I'd like to know ways of making this more efficient, though....
http://www.kirupa.com/forum/showthread.php?t=257111
Pagination Gallery Help
i am trying to get this gallery to work correctly, i have 13 images from an xml file and i have broken it down to 6 images per page which gives me 3 pages (6, 6, 1).
the problem:
it's only looping through the first group of 6 images, 3 times.
1,2,3,4,5,6
1,2,3,4,5,6
1,2,3,4,5,6
it should be like this:
1,2,3,4,5,6
7,8,9,10,11,12
13,
Actionscript
PHP Code:
function pages(plusOrMinus) { _global.currentNews = _global.currentNews+plusOrMinus; toolong = NewsStack1.length-1; if (_global.currentNews<0) { _global.currentNews = 0; } if (_global.currentNews>toolong) { _global.currentNews = toolong; } checkprevnext = function () { if (_global.currentNews>toolong-1) { btnState = new mx.transitions.Tween(nextx, "_alpha", Normal.easeOut, nextx._alpha, 25, 0.2, true); a2._visible = false; } else { var btnState = new mx.transitions.Tween(nextx, "_alpha", Normal.easeOut, nextx._alpha, 100, 0.2, true); a2._visible = true; } if (_global.currentNews<1) { btnState = new mx.transitions.Tween(prevx, "_alpha", Normal.easeOut, prevx._alpha, 25, 0.2, true); a1._visible = false; return; } btnState = new mx.transitions.Tween(prevx, "_alpha", Normal.easeOut, prevx._alpha, 100, 0.2, true); a1._visible = true; }; /* MOVES DATA NEXT & PREV */ pagex.txtx.text = [_global.currentNews+1]+" of "+[toolong+1]; txtx.txtx.htmlText = _global.NewsStack1[_global.currentNews]; txtx.txtx_2.htmlText = _global.NewsStack2[_global.currentNews]; trace("item: "+_global.NewsStack1[_global.currentNews]); //_parent.pic1x.picx.loadMovie(_global.NewsStack3[_global.currentNews]);}stop();txtx._alpha = 0;pagex._alpha = 0;_parent.contentArea._y = 160;var yTween = new mx.transitions.Tween(_parent.pic1x, "_alpha", mx.transitions.easing.Strong.easeOut, 0, 100, 1.4, true);var newsx = new XML();_global.currentNews = 0;_global.NewsStack1 = new Array();_global.NewsStack2 = new Array();_global.currentNews = "";_global.descStack = {};newsx.ignoreWhite = true;function reloadXML(xmlFile) { var aTween = new mx.transitions.Tween(txtx.imageHolder, "_alpha", mx.transitions.easing.Strong.easeOut, txtx.imageHolder._alpha, 0, .3, true); aTween.onMotionFinished = function() { var aTween = new mx.transitions.Tween(txtx.imageHolder, "_alpha", mx.transitions.easing.Strong.easeOut, txtx.imageHolder._alpha, 100, .3, true); newsx.load(xmlFile); idx = 1; };}if (xmlFile == null) { newsx.load("http://cs.jameslawrie.com/gallery.php?category=panoramic");}newsx.onLoad = function(success) { gotoAndPlay("in"); txtx.heading.htmlText = this.firstChild.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue; if (success) { var imgCon = txtx.imageHolder; trace("Pages: "+newsx.firstChild.childNodes.length); for (i=0; i<newsx.firstChild.childNodes.length; ++i) { var xmlItems = this.firstChild.firstChild.childNodes; var perPage = xmlItems.length; trace("Per Page: "+perPage); trace(" "); var n:Number; for (n=0; n<perPage; n++) { if (xmlItems[n].attributes.ID) { trace("ID: "+xmlItems[n].attributes.ID+" - IMGTITLE: "+xmlItems[n].attributes.IMGTITLE+" - IMGTHUMB: "+xmlItems[n].attributes.IMGTHUMB); imgCon.attachMovie("imgItem","imgItem"+i,imgCon.getNextHighestDepth()); imgCon["imgItem"+i]._x = i%3*212; imgCon["imgItem"+i]._y = (i/3)*71; } } _global.NewsStack1[i] = this.firstChild.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue; _global.NewsStack2[i] = this.firstChild.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue; a1.onRelease = function() { a1._visible = false; a2._visible = false; gotoAndPlay("outx"); idx = -1; }; a2.onRelease = function() { a1._visible = false; a2._visible = false; gotoAndPlay("outx"); idx = 1; }; } pages(-1); }};
please help.
FILE HERE: GALTEST FLA
AS3 - Gallery With Pagination
Hi
does anybody know of a good tutorial/s on pagination in AS3?
i`m trying to build a gallery that load its thumbs and big pics from an xml file. my problem is to loop the thumbs on the x and the y, and that if i have more then a number of pics a button will appear and create a new "page" with the rest of the thumbs. i`m learning AS3.
ho and maby another question: what do i need to do inorder to have credits?
best regards
ron
XML Pagination -- Previous / Next Buttons
hey everyone,
i'm trying to seperate some xml data into seperate pages. six entries on each page with three rows and two columns. i got the data to go into two columns...now i'm just trying to set up the next and previous buttons as well as showing only six entries per page.
i looked over online but had no luck. any help would be greatly appreciated!
source and xml file attached.
Controlling Pagination With Arrays
How do I create pages of thumbnails based on a total image count?
I'm using a loop to populate an image holder mc, (imageHolder) I create 80 (arbitrary) empty movie clips and push them into a large array. That part works fine.
Using the length of the large array (newImages), I loop through the clips in that to shift the larger array into smaller ones, incrementally named (pgArray). Since imagesPerPage is 10, I expected to have 10 arrays that contained the empty mcs, but something has gone wrong. Here's my pagination function:
Code:
function cullArray():Void {
trace("cullArray called");
var allImgCount:Number = newImages.length;
for (var k:Number = 0; k < Number(allImgCount / imagesPerPage); k++) {
var pgArrayName:String = String("pageArray" + k);
var pgArray:Array = [];
for (var j:Number = 0; j < imagesPerPage; j++) {
var img:Object = newImages.shift();
trace("img name: " + img);
pgArray.push(img);
}
trace("Here are the images on the " + k + "st page" + " (" + String(pgArrayName) + ")
");
trace(" " + pgArray);
}
trace("cullArray ended");
}
Can someone help me out? I think I'm referencing the strings and the arrays incorrectly. Thanks!
I found a solution after a while, but it probably needs cleaning up:
http://www.kirupa.com/forum/showthread.php?t=257111
[CS3, AS2]Minor Pagination Problem
I have combined together a pagination script to work with external xml which rather took me a long time to figure out. Everything work out great except the "total pages" required to make the pages work. The xml passes fine and displays the nodes great, but the next page button wont changes pages unless it knows what the total pages are.
heres my xml modified script:
PHP Code:
var xmlPath:String = "scripts/xml/issues.xml";
//the current page we're on
var page:Number = 1;
//the limit of values we need per page
var limit:Number = 6;
//the current row that we're working on
var row:Number = 0;
//The total pages that we have
var totalPages:Number = Math.ceil(values.length/limit);
//the text at the bottom of the page
var pageTxt:String = 'Page '+page+' out of '+totalPages;
//the function that will add all of the mc's to stage
function createValues():Void{
//this values array will hold all of the values we need to paginate
var nodes = xmlObj.firstChild.childNodes;
values = nodes.length;
//this will always limit the amount to the limit variable
//but, "i" will act as a marker for which part of the values
//array that we're going to use
for(var i = (page-1)*limit; i<page*limit; i++){
//checks if there actually is a value where "i" is
//otherwise we'll get some undefined movieclips
if(i < values){
//attaches the movieclip to the stage
attachMovie('artists_thumb', 'value'+row, i+1);
//sets the coordinates based on the row
this['value'+row]._x = 5;
this['value'+row]._y = 5+this['value'+row]._height*row;
//sets this guys value to the correct part of the array
this['value'+row]._issue.text = "Issue nº "+ nodes[i].childNodes[2].firstChild.nodeValue; //thisValue = values[i];
trace(nodes[i].childNodes[2].firstChild.nodeValue);
//move onto the next row
row ++;
}
}
//then we reset the rows so we can use the variable again
row=0;
}
//we have to remove movieclips from the stage if we're going to paginate
function removeValues():Void{
//its a simple function, hopefully you can understand it
for(i=0;i<limit;i++){
this['value'+i].removeMovieClip();
}
}
//adding functions to the buttons when they're clicked
mcPrev.onRelease = function(){
//if the page isn't too low
if(page > 1){
//then go to the previous page
removeValues();
page --;
createValues();
//updating the text
pageTxt = 'Page '+page+' out of '+totalPages;
}
}
mcNext.onRelease= function(){
//if the page isn't too high
if(page < totalPages){
//then go to the next page
removeValues();
page ++;
createValues();
//updating the text
pageTxt = 'Page '+page+' out of '+totalPages;
}
}
// XML Object
var xmlObj = new XML();
xmlObj.ignoreWhite = true;
xmlObj.onLoad = function(ok) {
if (ok) {
createValues();
trace(values)
} else {
trace("error loading xml");
}
};
xmlObj.load(xmlPath);
where I think the problem lies is the:
PHP Code:
var totalPages:Number = Math.ceil(values.length/limit);
i have tried countless times to modify it and place it else where for flash to get the node.length variable, but with no luck.
your help would be greatly appreciated. thank you.
XML Grid W/ Pagination & Effects
Hi,
I'm looking for help on creating an xml thumbnail grid that allows for pagination with effects or a "transition" when the user clicks next or previous page.
Kind of the same idea as www.badassembly.com 's work area, but using a different effect of course.
What I'm looking for is just some general direction, maybe some tutorial links etc.
I've created numerous xml grids before, but none with pagination. Which I would really like to learn for future reference. And I believe the ability to have transitions from one page to the other like the site I linked would be great.
Any links, code, tips, etc would be greatly appreciated as I can't seem to come up with a good logic on how you would put this together.
Thanks in advance!
Pagination - Dynamic Text Field
Has anyone figured a way to do true pagination in dynamic text fields?
I usualy do page breaks by hand in the content but am working on a project that would benifit greatly from smart pagination.
As far as I know there isn't a way to find out if text overflows a textfield, but I don't know. Anyone have anything on this?
Dynamic Text, Pagination, Resizable
I am trying to create a dynamic text box that pulls data from an external source. I'm using php to pull data from a mysql database. I want the box to be resizable and I accomplished this without any problems. I can pull in the external data without problems. However, my text sizes along with the box. How do I eliminate this? Also, I wish to have no scrollbar and use buttons to page up or down if the text overflows. Is there actionscript to handle pagination?
Many thanks to anyone who can help me with this.
Smart Whole Word Pagination With Strings
Hi all,
I created a SWF file that loads text into a dynamic textbox with a "pagination feature". If the text cannot fit into the textbox, the text will be split up into elements of an array. These elements are then loaded into the textbox whenever the next or previous button are hit.
See example:
http://zenofken.com/textBox.swf (30kb)
Here's the code:
Code:
var textFoo:String = "Save the Planet"; //sample text
var tempHolder:String = ""; //temporary placeholder
var arrayFoo:Array = new Array; //place the contents here
while(textFoo.length > 0) {
tempHolder = textFoo.substr(0,50);
textFoo = textFoo.slice(50);
arrayFoo.push(tempHolder);
}
textBox_txt.text = arrayFoo[0]; //load the first element by default
var fooCounter:Number = 0; //determines which element is being accessed
next_btn.onRelease = function() {
if(fooCounter < (arrayFoo.length-1) ){
fooCounter++;
}
textBox_txt.text = arrayFoo[fooCounter];
}
previous_btn.onRelease = function() {
if(fooCounter > 0){
fooCounter--;
}
textBox_txt.text = arrayFoo[fooCounter];
}
Question: Is it possible to determine cut the text at an exact whole word?
For example: if the phrase "Save the Planet" were to be cut into only 10 characters, we would get "Save the P". Instead of ending at "P", is it possible to end at "the" and have "P" be in the next page as part of the whole world "Planet"?
Pagination/printing Fields - Request To Macromedia
This is a suggestion that I emailed to wish-flash@macromedia.com. I thought others might be interested in it, and may be able to contribute to it.
Send email to the above email address requesting this or other features for Flash 7.
-----
Greetings
Just got back from FlashForward2002, where I was a finalist for my site "zeroEra.com", and wanted to submit my wishlist for printing features in future versions of Flash.
Currently, Flash is excellent for printing off a single page of dynamic content, or numerous pages of static content, but it provides no robust controls for paginated dynamic content.
Most modern online administrative systems, some user systems, and a number of CDROM deployable applications benefit from printable reports or summaries, based on user entries. Currently, implementing such solutions requires developers to build the Flash application, and then create supporting HTML-based pages for printing. This was a minor issue with Flash 5, in that the user had to leave their familiar environment to print. It becomes far more of a concern now with FlashMX, where developers now can create genuine applications, independent of a server back-end, with SharedObjects.
For instance, say I would like to build a CDROM (or even an online) piece, where users can enter variable amount of information (which would be stored with SharedObjects), and then print off a report on that information - this report could be anywhere from one page, through to tens of pages long. Currently, I could not do this in Flash, without having to have the user either: run through the print dialogue once for each page; or print off a bunch of extra blank pages. This is because Flash does not have any support for multiple page print jobs, except via the (VERY) static #P method. Currently, I would have to use a third party tool to write a temporary HTML file to their drive, then use another third party tool to open it, then instruct the user to print it out from their browser - hardly an ideal solution.
I could go on, but I would rather provide some potential solutions for the above mentioned issues.
One excellent solution would be a print queue object. This would allow you to queue up a number of print "objects" for a single print job. For instance:
printJob = new PrintQueue();
printJob.setFooter("myfooterMC",showOnFirstPage,"p ageNumberVariableName");
printJob.setHeader("myHeaderMC",showOnFirstPage,"p ageNumberVariableName");
printJob.addItem("target",arguments);
// carry out some actions that modify target
printJob.addItem("target",arguments);
print(printJob);
arguments would contain bounding box information, etc.
In this fashion, you could generate any number of pages to print, 1 at a time, and then print them all in a single job. You could also specify any parameters that would be universal to the job (for instance, a footer and header).
Another potentially useful capability would be the ability to print a field, and have Flash automatically handle pagination. A rough example would be:
printJob = new PrintQueue();
printJob.setHeader("myHeaderMC",showOnFirstPage,"p ageNumberVariableName");
printJob.addItem("myCoverPageMC",arguments);
printJob.addItem("fieldTarget",boundingBox,paginat e,backgroundColor);
print(printJob);
This would make it very simple to generate simple multi-page reports. Developers could format the text in the field using HTML to create titles, etc. and then add a header to give it a cohesive branded look. Developers could add text fields correlating to "pageNumberVariableName", and it would automatically update the page number in the header/footer.
These are just my early thoughts for this, and are somewhat undeveloped. Please feel free to contact me for clarification or for more information.
Thank you for the great product!
Multi-column Text Layout With Pagination
I'm trying to figure out how to create an AS3 multi-column layout with pagination, much like the functionality on theFWA.com articles. If anyone can give me some direction or offer links to source files, it would be a great help.
I've begun learning AS3 and came across a sample .fla that shows how to create a newspaper style layout with multiple columns. I just need to figure out how to add the pagination feature. The sample I found is here:
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000236.html
[FCS3] Adding Actionscript To A Movieclip Through Actionscript?
Yo, is there a way to add actionscript to a movieclip created in actionscript? Such as a onClipEvent(load) and onClipEvent(enterframe)? I have a onEnterFrame already for the movie clip as its created though. I have taken code thats from a gravity tutorial where it uses the two methods above. I've tried adding them into the onEnterFrame that I had already to add gravity to the movieclips created though that did'nt work =(
Jigsaw Puzzle - Changing From Actionscript 2.0 To Actionscript 3.0
Hello Everyone,
I was hoping someone could help me convert the following actionscript from actionscript 2.0 to actionscript 3.0. I'm trying to complete a jigsaw puzzple but I'm having problems converting it into actionscript 3.0.
Below is my actionscript:
//Puzzle Pieces
scramble_btn.onRelease = function(){
piece1._x = random(250);
piece1._y= random(250);
piece2._x = random(250);
piece2._y= random(250);
piece3._x = random(250);
piece3._y= random(250);
piece4._x = random(250);
piece4._y= random(250);
startGame();
messageOn.text = "";
counter.text = "00:00";
clearInterval(timeStarted);
timeStarted = setInterval(countdown, 1000);
time_start = 0;
}
//Puzzle Move
function startGame(){
piece1.onPress = function(){
this.startDrag();
piece1.swapDepths(1)
}
piece1.onRelease = function() {
this.stopDrag();
hit1();
checker();
};
piece2.onPress = function(){
this.startDrag();
piece2.swapDepths(1)
}
piece2.onRelease = function() {
this.stopDrag();
hit2();
checker();
};
piece3.onPress = function(){
this.startDrag();
piece3.swapDepths(1)
}
piece3.onRelease = function() {
this.stopDrag();
hit3();
checker();
};
piece4.onPress = function(){
this.startDrag();
piece4.swapDepths(1)
}
piece4.onRelease = function() {
this.stopDrag();
hit4();
checker();
}
};
//HitTest Script
function hit1(){
if(piece1.hitTest(container1)){
piece1._x = container1._x;
piece1._y = container1._y;
}else{
piece1._x = random(250);
piece1._y = random(250);
}
}
function hit2(){
if(piece2.hitTest(container2)){
piece2._x = container2._x;
piece2._y = container2._y;
}else{
piece2._x = random(250);
piece2._y = random(250);
}
}
function hit3(){
if(piece3.hitTest(container3)){
piece3._x = container3._x;
piece3._y = container3._y;
}else{
piece3._x = random(250);
piece3._y = random(250);
}
}
function hit4(){
if(piece4.hitTest(container4)){
piece4._x = container4._x;
piece4._y = container4._y;
}else{
piece4._x = random(250);
piece4._y = random(250);
}
}
//Timer
counter.text = "00:00";
function countdown() {
started();
time_start = time_start+1;
if (time_start>10) {
messageOn.text = "GAME OVER!!!";
clearInterval(timeStarted);
}
}
function started(){
sec = Math.floor(time_start+1/1000);
sec = (sec<10)?"0"+sec:sec;
min = Math.floor(sec/60);
min = (min<10)?"0"+min:min;
counter.text = min+":"+sec;
};
//This will check if all puzzle pieces are complete...and display game finish messsage.
function checker(){
if((piece1.hitTest(container1)) && (piece2.hitTest(container2)) && (piece3.hitTest(container3)) && (piece4.hitTest(container4))){
messageOn.text = "CONGRATULATIONS!!!";
clearInterval(timeStarted);
}
}
Giving Actionscript To An Actionscript-loaded Movie
How can I (if possible) set actionscript (say, an on-mouse event) to a movie that I load via attachMovie()? I poked around and I couldn't seem to find an answer...
I want the movie that I load via attachMovie() to have an on(RollOver) event...any thoughts?
Warning: An ActionScript 1.0/2.0 SWF File Has Loaded An ActionScript 3.0 SWF;
Hi all,
I'm trying to clone an swf (produced in CS3) that has been loaded into my app (built using Actionscript/mxmlc) but keep getting the following message appear in my logs:
Code:
Warning: An ActionScript 1.0/2.0 SWF file has loaded an ActionScript 3.0 SWF; code in the ActionScript 3.0 SWF will not run.
I know the CS3 swf has been produced using Actionscript 3 as it's settings and published for FP9. It does nothing more than a motion tween of a graphic.
Here is a really simple example of how to emulate the problem:
ActionScript Code:
package{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
[SWF(backgroundColor=0x000000)]
public class Test extends Sprite{
private var _mc:MovieClip;
public function Test():void{
var mc:String = "rain.swf";
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedSWF);
ldr.load(new URLRequest(mc));
}
private function loadedSWF(e:Event):void{
var mc:MovieClip = MovieClip(e.target.content);
this._mc = MovieClip(new (mc.constructor)());
this.addChild(this._mc);
}
}
}
I'm using the following version of mxmlc: Version 3.0.0 build 1844
I've also tried a slightly more convoluted way:
ActionScript Code:
package{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getQualifiedClassName;
import flash.net.URLRequest;
[SWF(backgroundColor=0x000000)]
public class Test extends Sprite{
private var _mc:MovieClip;
public function Test():void{
var mc:String = "rain.swf";
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedSWF);
ldr.load(new URLRequest(mc));
}
private function loadedSWF(e:Event):void{
var c:Class = Class(e.target.applicationDomain.getDefinition(getQualifiedClassName(e.target.content)));
this._mc = new c();
this.addChild(this._mc);
}
}
}
I would like to know what's causing the warning message, am I doing something wrong?
Actionscript - User Input Actionscript
I am trying to develop a way where by a users input can determine the number of fields in a form e.g. the user inputs the number 3 then the form would have 3 fields
can you show me or point me in the direction of an example i can look at and manipulate?
[F8] Flash6 Actionscript 2, Flash 8 Actionscript 2...help
Ok loosing it a bit now, have gone back to a very old project from a Flash 6 file, managed to convert the script language to ActionScript2, works fine as flash6 actionscript2, but once I change the project to be flash 8 I get One error......and I know where it's coming from (see below), Have come to a dead - end here, so hope that one of you guys may be able to help me....
Feel free to use this if you can get it working, just credit the designer (Me).
On the main stage MC named "site", go inside and double click on any of the MC's (named "str0, or str1 etc....all instances). Once inside an "str" MC move to frame 2 and the MC on the stage should be called "seg0 or seg1 etc...(again all instances"), go inside the MC and click on frame 1 of the actions layer. Scroll down and look for the variable named "var nummer = _parent.plus+Number(this._name.substr(3, 1));"....this always returns NaN in flash player 8, but works in flash player 6?.................help me.....I'm drowning.
link to files:
http://www.solidvision.co.uk/dev/help.zip
Moving A Game From Actionscript 1.0 To Actionscript 2.0...
Hi there.
I hope someone can help me out here. I have been asked to create a simple Flash memory game, and I have been given a template to use as a basis. However, this template has been created in Actionscript 1.0 for Flash player 5. I now need to transfer it over to Actionscript 2.0 Flash player 8, and Ive noticed lots of odd behaviour once it has been changed.
Here is the code....
Code:
initGame();
stop();
function initGame() {
// make sorted list of cards
cardsListOrdered = [];
for (i=1; i<=18; i++) {
cardsListOrdered.push(i, i);
}
// shuffle list
cardsListSorted = [];
while (cardsListOrdered.length>0) {
r = int(Math.random()*cardsListOrdered.length);
cardsListSorted.push(cardsListOrdered[r]);
cardsListOrdered.splice(r, 1);
}
// create card clips and assign their location and picture
x = 0;
y = 0;
for (i=0; i<36; i++) {
attachMovie("Card", "Card"+i, i);
_root["Card"+i].picture = cardsListSorted[i];
_root["Card"+i]._x = x*60+200;
_root["Card"+i]._y = y*60+50;
// move to next card spot
x++;
if (x>5) {
x = 0;
y++;
}
}
firstclip = 0;
}
function clickCard(clip) {
// see if two card are showing
if (secondclip != 0) {
// turn those two cards back over
firstclip.enabled = true;
secondclip.enabled = true;
firstclip.gotoAndStop(1);
secondclip.gotoAndStop(1);
firstclip = 0;
secondclip = 0;
}
// see if same card was clicked
if (firstclip == clip) {
// turn card back over
firstclip.gotoAndStop(1);
firstclip = 0;
// see if no cards are showing
} else if (firstclip == 0) {
// turn first card over
clip.gotoAndStop(clip.picture+1);
firstclip = clip;
firstclip.enabled = false;
// must be one card showing
} else {
// turn second card over
clip.gotoAndStop(clip.picture+1);
secondclip = clip;
secondclip.enabled = false;
// see if two cards match
if (firstclip.picture == secondclip.picture) {
// Disable both cards
firstclip.enabled = false;
secondclip.enabled = false;
firstclip = 0;
secondclip = 0;
}
}
}
When set to FlashPlayer5, all works well. If a player tries clicking the same tile twice, it stops them. Also, when a pair of tiles are uncovered, again, the user is no-longer able to press them. This was done using the "enabled = false".
However, when I change it to Flash Player 8, none of these seems to work. Ill include the .fla so someone could possibly play around with it and see where the problem is, or whether there is another way to do it....
Hope someone can help.
Many thanks
Swf Actionscript 3, Load A Actionscript 2 File.
Hey dudes.
I need some help over here:
i have one banner player, and load some external swf files in actionscript 2, but the player is actionscript 3.
The files is loaded like a movie, when load a as2 files into as3. I just need a trigger when the swf file ends, when is in the last frame of movie.
Someone have a ideia in how do that?
thanks!
Flash ActionScript == Flex ActionScript?
Is ActionScript basically programmed the same way for Flash as it is for Flex? I know some folks who develop in AS for Flex. I didn't know if it was exactly the same for Flash, so I could tap them as a resource when I have an AS question.
Thanks,
Loren
Urgent :Getting Actionscript To 'pause' - Actionscript 2.0
Hi guys,
I need the actionscript to carry out a piece of code, then pause for 0.5 seconds, then carry out the next piece of code, then pause, then next code e.t.c
There will be twenty pieces of code that build up an animation with tweens that need to start at different times.
I guess its something to do with setInterval, but I'm not sure on the syntax, as there 20 pieces of code I don't want lots of nested code (though if thats the only way to do it then so be it!)
I'd really appreciate your help guys
cheers
Obtaining An ActionScript 2 Variable From ActionScript 3
Probably one of the most subjects on this forum has to be ActionScript 3 and ActionScript 2 communication. I found several threads on how to communicate between the two using a LocalConnection class, but there is one problem with this approach - I can't transport any values with it. Because LocationConnection.send doesn't have a return type, there is no way to transport a value from AS2 to AS3. This is very unfortunate, as I need to have access to a value that is set somewhere in the AS2 code.
I could use JavaScript as a middle layer to communicate the data between the two, but this will be a very ineffective way to achieve it. Are there any better ways for doing this?
ActionScript 3.0 Is 5~7 Times Slower Then ActionScript 2.0
I have a code that will translate this XML
quote:
<?xml version='1.0'?>
<Member>
<M>
<Username>Test 1</Username>
<Password>Test 1 Password</Password>
</M>
<M>
<Username>Test 2</Username>
<Password>Test 2 Password</Password>
</M>
<M>
<Username>Test 3</Username>
<Password>Test 3 Password</Password>
</M>
</Member>
Into this array
quote:
Array[0].Username = "Test 1"
Array[0].Password = "Test 1 Password"
Array[1].Username = "Test 2"
Array[1].Password = "Test 2 Password"
Array[2].Username = "Test 3"
Array[2].Password = "Test 3 Password"
Here is my variable declaration
quote:
var StartTime:Number = getTimer();
var EndTime:Number = getTimer();
var j:Number = 0;//This Variables used for ActionScript 3.0 Loop
var k:Number = 0;//This Variables used for ActionScript 3.0 Loop
Here is the XML String
quote:
var MyXMLString:String = "<?xml version='1.0'?><member><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O></member>";
var MyXML:XML = new XML(MyXMLString);//Parse the XML ONCE
I have a function called ConvertXML , and to check the performance i made it loop every frame by calling the following RunXML function
quote:
function RunXML(Events:Event){
StartTime = getTimer();
for(var i:Number=0;i<100;i++){
var MyXMLArr:Array = ConvertXML(MyXML, false, false);
}
EndTime = getTimer();
trace(EndTime - StartTime + " ms");
}
and here is my code for parsing the variable MyXML in ActionScript 3.0 (ConvertXML function)
quote:
//Action Script 3.0 ConvertXML
import flash.xml.*;
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (j=0; j<RecvXML.child("*").length(); j++) {
var TempObject = new Object();
for (k=0; k<RecvXML.child("*")[j].elements("*").length(); k++) {
TempObject[RecvXML.child("*")[j].elements("*")[k].name()] = RecvXML.child("*")[j].elements("*")[k];
}
RowArr.push(TempObject);
}
return RowArr;
}
addEventListener(Event.ENTER_FRAME, RunXML);
The code above run 5~7 times slower then the following actionscript 2.0 code
quote:
//Action Script 2.0 ConvertXML
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (var aNode:XMLNode = RecvXML.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
var TempRecord:Object = new Object();
for (var bNode:XMLNode = aNode.firstChild; bNode != null; bNode=bNode.nextSibling) {
TempRecord[bNode.nodeName] = bNode.firstChild.toString();
}
RowArr.push(TempRecord);
}
return RowArr;
}
this.onEnterFrame = RunXML;
they both does exactly the same thing.. and yet the actionscript 3.0 code run 5~7 TIMES SLOWER . why?
i have tried other benchmark, and it seems that actionscript 3.0 perform 10 to 100 TIMES FASTER then actionscript 2.0 , only for this one it run slower... why?
I also attach all the code for actionscript 3.0
should you want to try the actionscript 2.0 , just uncomment the ConvertXML and this.onEnterFrame for actionscript 2.0 and comment the one for actionscript 3.0
Why? have i done something wrong?
Cheers and God Bless,
Chowi
Attach Code
var StartTime:Number = getTimer();
var EndTime:Number = getTimer();
var MyXMLString:String = "<?xml version='1.0'?><member><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O><O><member_id>1</member_id><currency_id>0</currency_id><name>Administrator</name><description>Account Administrator</description><contact>-</contact><billing_info>-</billing_info><opening_payable>0.0000000000</opening_payable><opening_receivable>0.0000000000</opening_receivable><type>STAFF</type><asset_chart_of_account_id>0</asset_chart_of_account_id><liability_chart_of_account_id>0</liability_chart_of_account_id><staff_username>administrator</staff_username><staff_password>21232f297a57a5a743894a0e4a801fc3</staff_password><staff_privileges>ADMIN</staff_privileges></O></member>";
var MyXML:XML = new XML(MyXMLString);//Parse the XML ONCE
var j:Number = 0;//This Variables used for ActionScript 3.0 Loop
var k:Number = 0;//This Variables used for ActionScript 3.0 Loop
/*
//Action Script 2.0 ConvertXML
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (var aNode:XMLNode = RecvXML.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
var TempRecord:Object = new Object();
for (var bNode:XMLNode = aNode.firstChild; bNode != null; bNode=bNode.nextSibling) {
TempRecord[bNode.nodeName] = bNode.firstChild.toString();
}
RowArr.push(TempRecord);
}
return RowArr;
}
this.onEnterFrame = RunXML;
*/
//Action Script 3.0 ConvertXML
import flash.xml.*;
function ConvertXML(RecvXML:XML, ChildBranch:Boolean, IsTable:Boolean):Array {
var RowArr:Array = new Array();
for (j=0; j<RecvXML.child("*").length(); j++) {
var TempObject = new Object();
for (k=0; k<RecvXML.child("*")[j].elements("*").length(); k++) {
TempObject[RecvXML.child("*")[j].elements("*")[k].name()] = RecvXML.child("*")[j].elements("*")[k];
}
RowArr.push(TempObject);
}
return RowArr;
}
addEventListener(Event.ENTER_FRAME, RunXML);
function RunXML(Events:Event){
StartTime = getTimer();
for(var i:Number=0;i<100;i++){
var MyXMLArr:Array = ConvertXML(MyXML, false, false);
}
EndTime = getTimer();
trace(EndTime - StartTime + " ms");
}
Edited: 10/09/2008 at 12:17:57 AM by M4G1C14N
URGENT How Do I Get Actionscript To Pause Actionscript 2.0
Hi guys,
sorry to repost, I know its an annoying thing to do, but this is pretty urgent on a project I'm doing.
I need the actionscript to carry out a piece of code, then pause for 0.5 seconds, then carry out the next piece of code, then pause, then next code e.t.c
There will be twenty pieces of code that build up an animation with tweens that need to start at different times.
I guess its something to do with setInterval, but I'm not sure on the syntax, as there 20 pieces of code I don't want lots of nested code (though if thats the only way to do it then so be it!)
I'd really appreciate your help guys
cheers
Help: This Works In Actionscript 1 But I Need It To Work In Actionscript 2
I have some scrolling navigation that works when published using actionscript 1 but not actionscript 2. I need to use actionscript 2 because it supports the streaming video that I'm trying to navigate. Can someone help me rewrite my button logic to get the scroll bar to work as it did in actionscript 1? Please see my fla if necessary, but here is the area I need help with.
if (Number((getProperty("../scrollhandle", _y)))>Number((Number(../:top)+Number((../:speed/(../:height/../:scrolllength)))))) {
setProperty("../scrollhandle", _y, (getProperty("../scrollhandle", _y)-(../:speed/(../:height/../:scrolllength))));
} else {
setProperty("../scrollhandle", _y, ../:top);
}
tellTarget ("../scrollhandle") {
gotoAndPlay(3);
}
the error that I get is:
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 1: Operator '>' must be followed by an operand
if (Number((getProperty("../scrollhandle", _y)))>Number((Number(../:top)+Number((../:speed/(../:height/../:scrolllength)))))) {
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 2: Operator '-' must be followed by an operand
setProperty("../scrollhandle", _y, (getProperty("../scrollhandle", _y)-(../:speed/(../:height/../:scrolllength))));
**Error** Symbol=buttonlogic, layer=Layer 1, frame=2:Line 4: Unexpected '.' encountered
setProperty("../scrollhandle", _y, ../:top);
Please help if you can.
Actionscript 3 Tutorials For Actionscript Beginners
hey all, looking for some tutorials on actionscript 3 for people who are relatively new to actionscript altogether? Finding loads of tutorials but they seem to expect u to already have a grasp of actionscript 2!!
cheers in advance!
Works In Actionscript 1.0, Not Actionscript 2.0, Help?
Any idea why this would work fine in Flash MX but not MX 2004 Pro? I'm new to the upgrade but I can't imagine why this doesn't work.
_root.mission.gotoAndStop("mission");
I'm publishing in Actionscript 1.0 so I don't see what the difference would be.
Thank you much!
Converting ActionScript 1 To ActionScript 2
Flash keeps giving me a "type mismatch" error for this particular line of code:
myItemArray[x] = parseInt(Math.random()*9) + myItemArray[x];
Based on my research it's because it's old script and I'm not sure how to go about converting it so I don't get the error. I've pasted the entire block of code for your understanding. Thanks in advance for you help.
Code:
//Build array
myItemArray = new Array("a1","a2","a3","a4","a5","a6","b1","b2","b3" ,"b4","b5","b6");
for(var x = 0; x < 12; x++){
myItemArray[x] = parseInt(Math.random()*9) + myItemArray[x];
}
//Sort array
myItemArray.sort();
//Strip off random num at beginning
for (var x = 0; x < 12; x++){
myItemArray[x] = myItemArray[x].substr(1,myItemArray[x].length);
}
Works On ActionScript 1.0 But Not On ActionScript 2.0
The following code works if you have your flash file set to:
Flash Player 6
Action Script 1
I need it to work for
Flash Player 7
Action Script 2
What it does is that basically if i have
1 2 3 4 5
and i click on the 5 it will arrange the movie clips so they will be
5 1 2 3 4
mc is the name for action script of the movie clip i'm using
I think
the function that doesn't work correctly is the move function
HOW CAN I FIX THIS Sad
Code:
var acceleration = 12;
var friction = 0.7;
clipArray = [];
posArray = [];
for (var k = 0; k<5; k++) {
myclip = attachMovie("mc", "mc"+k, k);
myclip._y = 100;
myclip._x = 170+myclip._width*k;
//myclip.myText.text = "Button "+k;
clipArray.push(myclip);
//countArray.push(k);
posArray.push(myclip._x);
myclip.onPress = dostuff;
}
function move() {
var xdif = posArray[this.jvar]-this._x;
this.xspeed += xdif/this._parent.acceleration;
this.xspeed *= this._parent.friction;
this._x += this.xspeed;
this.checkDistance();
}
checkDistance = function () {
if (Math.abs(posArray[this.jvar]-this._x)<1) {
this._x = posArray[this.jvar];
delete this.onEnterFrame;
}
};
function dostuff() {
for (var i = 0; i<clipArray.length; i++) {
// setting indexes
clipArray[i].ivar = i;;
}
// deleting the mc the user clicked
k = clipArray.splice(this.ivar, 1);
// the mc you click is on the front
clipArray = k.concat(clipArray);
for (var j = 0; j<posArray.length; j++) {
// re setting the indexes
clipArray[j].jvar = j;
trace(clipArray[j]+" "+clipArray[j].jvar);
// calls move
clipArray[j].onEnterFrame = move;
}
}
|