13 Replies - 3091 Views - Last Post: 06 November 2008 - 12:13 PM

#1 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 08:00 AM

Hi,

I have this array that I'm trying to get the info out.

What I want is when I click next and previous that my text changes to whatever is next in my array.

Here is my array:

var linkArrayTitle:Array = Array("Children","Adults","Johnny","penthouse","PlayHouse","DoGEatDog","Oh Yeah"); 


I use this to get the info out, but only works on the load.

author.text = linkArrayTitle.join("\n");


So that loads up the first text title. Now I want to

button.onRelease{
slideRight():

}


function slideLeft() {
	// There is a bunch of stuff here you don't need to see
	  // But I need the code for increasing the array and putting the data inside a author.text
	
}
function slideRight() {
	// There is a bunch of stuff here you don't need to see
	  // But I need the code for increasing the array and putting the data inside a author.text
}




I want something that will go up the array and that I can use to go down the array.

I used this but it didn't work.

function slideRight() {
	author.text += linkArrayTitle[-1].join("\n");
}





Thanks,

This post has been edited by bmcc81: 05 November 2008 - 08:05 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Array to text Box - Next button jumps up array Previous Jumps back in

#2 -Fabez-  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 19-October 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 08:27 AM

So to clarify, when you click the next button it displays the next index in your array and the opposite for the back button ?
Was This Post Helpful? 0
  • +
  • -

#3 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 08:57 AM

Yeah that is the idea. Do you know of something I can do?
- much appreciated
Was This Post Helpful? 0
  • +
  • -

#4 -Fabez-  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 19-October 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 09:50 AM

The following Actionscript will handle the OnRelease event for Next_mc and Back_mc, changing the Position variable appropriately. The CurrentIndex variable is then updated, changing the text in the dynamic text box.

var MyArray:Array=Array("Index One","Index Two")
var Position:Number=0
var CurrentIndex=MyArray[Position]
Next_mc.onRelease=function(){
	Position+=1
	CurrentIndex=MyArray[Position]
}
Back_mc.onRelease=function(){
	Position-=1
	CurrentIndex=MyArray[Position]
}


In order for this code to work the variable property of your dynamic text box must be set to Position. Ask if you have any questions. :D
Was This Post Helpful? 0
  • +
  • -

#5 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 11:31 AM

Hey Thanks dude,

But when I put this inside my slideRight function

I get "undefined"



function slideRight() {
	
	Position -= 1;
	CurrentIndex=linkArrayTitle[Position];
	trace(CurrentIndex);
	author.text = linkArrayTitle[CurrentIndex].join("\n");
	



Do you know what I'm doing wrong?

Thanks again,

This post has been edited by bmcc81: 05 November 2008 - 11:39 AM

Was This Post Helpful? 0
  • +
  • -

#6 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 12:00 PM

Could it be something wrong with my array?

trace(linkArrayTitle);


var linkArrayTitle:Array = Array("Children","Adults","Johnny","penthouse","PlayHouse","DoGEatDog","Oh Yeah");

Was This Post Helpful? 0
  • +
  • -

#7 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 12:46 PM

View Postbmcc81, on 5 Nov, 2008 - 11:00 AM, said:

Could it be something wrong with my array?

trace(linkArrayTitle);


var linkArrayTitle:Array = Array("Children","Adults","Johnny","penthouse","PlayHouse","DoGEatDog","Oh Yeah");



I figured why this wasn't showing...
The array has to be on top:

trace(linkArrayTitle);

var linkArrayTitle:Array = Array("Children","Adults","Johnny","penthouse","PlayHouse","DoGEatDog","Oh Yeah");


But I still can't get the data inside my text box. ARGHHH!!!! :crazy:
Was This Post Helpful? 0
  • +
  • -

#8 -Fabez-  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 19-October 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 05 November 2008 - 01:55 PM

Change this line in your code.

 author.text = linkArrayTitle[CurrentIndex].join("\n");



To this line

 author.text = linkArrayTitle[Position]


Was This Post Helpful? 0
  • +
  • -

#9 garfield  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-November 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 02:38 AM

Hi Community

So, i have almost the same target but ....ahh

ok

I having a simple array, wich works fine:

 
var inbox = new Array();

inbox.push({A:"1", B:"2", C:"3", D:"4"});
inbox.push({A:"4", B:"3", C:"2", D:"1"});





Now i having two Buttons a "up" and "down"

And now i want that when i push "up" or "down" that the next line is marked or the upper.........

onClipEvent (load) {
	var inbox:Array;
	var Position:Number = 0;
	down.onRelease = function() {
		Position += 1;
	};
}



[/quote]

any ideas?
Was This Post Helpful? 0
  • +
  • -

#10 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 08:08 AM

View Postgarfield, on 6 Nov, 2008 - 01:38 AM, said:

Hi Community

So, i have almost the same target but ....ahh

ok

I having a simple array, wich works fine:

 
var inbox = new Array();

inbox.push({A:"1", B:"2", C:"3", D:"4"});
inbox.push({A:"4", B:"3", C:"2", D:"1"});





Now i having two Buttons a "up" and "down"

And now i want that when i push "up" or "down" that the next line is marked or the upper.........

onClipEvent (load) {
	var inbox:Array;
	var Position:Number = 0;
	down.onRelease = function() {
		Position += 1;
	};
}




any ideas?
[/quote]


Hi Garfield,


It's not too clear what you want to do. You might be better off working with my code to go through an array. I'm not too sure about your structure. For instance this is off

var inbox:Array;

Should be:

var inbox:Array = Array("First", "Second", "Third");




Back to my code. I'm still having trouble with updating my text box every time I go to the next element in the array. Is there someway to get it updated everytime a button is released?

Thanks,

Attached File(s)

  • Attached File  Why.zip (9.47K)
    Number of downloads: 56

Was This Post Helpful? 0
  • +
  • -

#11 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 08:33 AM

So, I got most of it working now. I just need it to output the data into my text box called author. The first one works and then that's it.

Can someone tell me what to do?


var Position:Number = 0;
var CurrentIndex = linkArrayTitle[Position];
var linkArrayTitle:Array = Array("Children", "Adults", "Johnny", "penthouse", "PlayHouse", "DoGEatDog", "Oh Yeah", "Brandon", "Dan", "Marcel", "Dudley", "Frank", "Jimbo");
//
author.text = linkArrayTitle[0];
//
function slideLeft() {
	Position -= 1;
	if (Position == -1) {
		Position = linkArrayTitle.length-1;
	}
	CurrentIndex = linkArrayTitle[Position];
	//
	trace(CurrentIndex);
	author.replaceText = CurrentIndex;
	
}
//
function slideRight() {
	Position += 1;
	if (Position == linkArrayTitle.length) {
		Position = 0;
	}
	CurrentIndex = linkArrayTitle[Position];
	//
	trace(CurrentIndex);
	author.replaceText = CurrentIndex;
	
}
//
this.left_button_mc.onRelease = function() {
	slideLeft();
	updateAfterEvent;author.text = CurrentIndex.toString("\n");
	clearInterval();
};
//
this.right_button_mc.onRelease = function() {
	slideRight();
	updateAfterEvent;author.text = CurrentIndex.toString("\n");
	clearInterval();
};

Was This Post Helpful? 0
  • +
  • -

#12 -Fabez-  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 19-October 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 10:41 AM

Does clicking the next button trace the correct number ? Do you want to send me the .Fla file, to see if I can make any adjustments to make it work ? Also chane the line.

author.text = CurrentIndex.toString("\n");



To

author.text = linkArrayTitle[Position]


Was This Post Helpful? 0
  • +
  • -

#13 bmcc81  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 312
  • Joined: 10-July 07

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 11:44 AM

View Post-Fabez-, on 6 Nov, 2008 - 09:41 AM, said:

Does clicking the next button trace the correct number ? Do you want to send me the .Fla file, to see if I can make any adjustments to make it work ? Also chane the line.

author.text = CurrentIndex.toString("\n");



To

author.text = linkArrayTitle[Position]




I got it all working now. Thanks for all your help. this is my code. The problem was I had my instance name named as well as the var, inside my properties. Everything works fine now.

;) Much appreciated

var Position:Number = 0;
var CurrentIndex = linkArrayTitle[Position];
var linkArrayTitle:Array = Array("Children", "Adults", "Johnny", "penthouse", "PlayHouse", "DoGEatDog", "Oh Yeah", "Brandon", "Dan", "Marcel", "Dudley", "Frank", "Jimbo");
//
author.text = linkArrayTitle[0];
//
function slideLeft() {
	Position -= 1;
	if (Position == -1) {
		Position = linkArrayTitle.length-1;
	}
	CurrentIndex = linkArrayTitle[Position];
	//
	trace(CurrentIndex);
	author.replaceText = CurrentIndex;
	author.text = CurrentIndex.toString("\n");
}
//
function slideRight() {
	Position += 1;
	if (Position == linkArrayTitle.length) {
		Position = 0;
	}
	CurrentIndex = linkArrayTitle[Position];
	//
	trace(CurrentIndex);
	author.replaceText = CurrentIndex;
	author.text = CurrentIndex.toString("\n");
}
//
this.left_button_mc.onRelease = function() {
	slideLeft();
};
//
this.right_button_mc.onRelease = function() {
	slideRight();

};

Attached File(s)

  • Attached File  Why.zip (9.02K)
    Number of downloads: 68

Was This Post Helpful? 0
  • +
  • -

#14 -Fabez-  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 46
  • Joined: 19-October 08

Re: Array to text Box - Next button jumps up array Previous Jumps back in

Posted 06 November 2008 - 12:13 PM

Glad it worked for you :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1