Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : MANIPULATE THIS CODE


jonnybennett
10/1/2005 6:28:37 PM
MANIPULATE THIS

Whatever way I change this code, I either can't get var rowCounter to be read
by function makeTextFields(), or as the code is below it no longer reads
thisTimeline["text"+p].titlage.htmlText = splitArray[p]; within the function
makeTextFields().
To those that have been following this thread (Maffe) I have added a blue box
within my textbox to see if the this.attahMovie is working. It is. Therefore
the problem is that the line..
thisTimeline["text"+p].titlage.htmlText = splitArray[p]; can?t be read within
the function makeTextFields().
Your continued help and anyone else?s on this matter would be much
appreciated.

For those who don?t know? WHAT I AM TRYING TO DO: I want to create a site...IT
MUST BE IN FLASH. Where people can upload there personal details, pictures etc.
to a mysql database. I then want for example a page that displays these peoples
names only. Then when a user clicks on a name, a new frame is played with the
rest of that persons details. I have searched the web for tutorials many of
them similar to what I am trying to do, however I couldn?t find any that really
did what I wanted it to do.
Perhaps there is a better way to create what I am trying to do. As I?ve
mentioned before I am new to coding so if the way I am going is totally wrong
if you point me in the right direction I can research that area. The code below
is attempting to display the names data that can when clicked return the rest
of that?s persons details? The problem I am having is stated above? I am very
close and really once this problem is solved I think I am pretty much home and
dry. So thanks in advance.

stop();

var rowCounter;
var numberx = 250;
var numbery = 0;
var spacing = 50;
thisTimeline=this;

darren = new LoadVars();

darren.onLoad = function() {
splitArray = darren.flashResults1.split("|");
rowCounter = splitArray.length;
looping.looping.text = rowCounter;
for (var p = 0; p<rowCounter; p++) {
thisTimeline["text"+p].titlage.htmlText = splitArray[p];
}
makeTextFields();
};
darren.load("one.php");

function makeTextFields () {
for (var p = 0; p<rowCounter; p++) {
rclip = this.attachMovie("textbox", "text"+p,
this.getNextHighestDepth());
rclip._x = numberx+spacing;
rclip._y = numbery;
numbery += 50;
}
}


receive = new LoadVars ();
receive.onLoad= function () {
infoArray = receive.toresults.split("|");
resultsText.titlage.htmlText= infoArray[0];}

//New function to clear all textboxes.
function clearText(){
for (var p = 0; p<loops; p++){
removeMovieClip("text"+p);}}

for (var p = 0; p<loops; p++) {
thisTimeline["text"+p].onRelease= function(){
darren.filmName = this.titlage.htmlText;
receive.load("oneb.php");
darren.sendAndLoad("oneb.php",receive,"POST");
clearText();
_root.gotoAndPlay ('pleasework');
}
}

kglad
10/1/2005 8:07:34 PM
it looks like you're assigning text to your textfields before they are
instantiated. try:

darren.onLoad = function() {
splitArray = darren.flashResults1.split("|");
rowCounter = splitArray.length;
makeTextFields();
looping.looping.text = rowCounter;
for (var p = 0; p<rowCounter; p++) {
thisTimeline["text"+p].titlage.htmlText = splitArray[p];
}
};
jonnybennett
10/2/2005 7:07:41 PM
Special thanks to Maffe from Sephorit forums and Kglad from Macromedia forums.
You are both legends and your help has been greatly appreciated.

I thought I had tried every way of moving round the code to make it work, but
Kglad you were right by simply moving the makeTextFields(); it populates the
textboxes. This still left the problem that when you pressed any of the text
fields they wouldn?t move to the next frame clear all attachedMovies and
populate the new text field with their respective information. However I have
made some changes to the code above, and I?m pleased to say the code below is
now fully working.

I have one hopefully final problem, however having spent a day and night
struggling with it I have a feeling it is a big one!?
I don?t know the size of var rowCounter. If it becomes larger than say 15, the
attached results go off the stage. For design reasons I don?t want to use a
scrollPane, plus I think the stage size would still limit this as a
possibility?. What I would like to do, and have tried to do, is to only display
the first ten results (while p<10). Then have a button that the displays the
next ten. However when I try and put the results into onRelease buttons I have
the same problems I?ve had all along? The text boxes become unpopulated.

If anyone has any ideas I would be very apprciatative. Thanks again for past
help. Jonny Bennett.

Below is the working code, but not yet put into a system where it attaches the
first 10clips, and then on a button press, attatches the next 10.

stop();

var rowCounter;
var numberx = 250;
var numbery = 0;
var spacing = 50;
thisTimeline=this;

darren = new LoadVars();

receive = new LoadVars ();
receive.onLoad= function () {
infoArray = receive.toresults.split("|");
resultsText.titlage.htmlText= infoArray[0];}


darren.onLoad = function() {
splitArray = darren.flashResults1.split("|");
rowCounter = splitArray.length;
makeTextFields();
looping.looping.text = rowCounter;
for (var p = 0; p<rowCounter; p++) {
thisTimeline["text"+p].titlage.htmlText = splitArray[p];
}

};
darren.load("one.php");

function makeTextFields () {
for (var p = 0; p<rowCounter; p++) {
rclip = this.attachMovie("textbox", "text"+p, this.getNextHighestDepth());
rclip._x = numberx+spacing;
rclip._y = numbery;
numbery += 50;
thisTimeline["text"+p].onRelease= function(){
darren.filmName = this.titlage.htmlText;
receive.load("oneb.php");
darren.sendAndLoad("oneb.php",receive,"POST");
clearText();
_root.gotoAndPlay ('pleasework');


}
}
}

function clearText(){
for (var p = 0; p<rowCounter; p++){
removeMovieClip("text"+p);}}
LuigiL
10/4/2005 7:33:21 AM
Initialize as follows:
var i:Number=0;
var thisTimeline:MovieClip=this;

correct the code:
function makePages(){
for (v=1;v<rounded;v++){
pClip = this.attachMovie('pages','pageNum'+v,this.getNextHighestDepth());
thisTimeline["pageNum"+v].pages.htmlText = v;
pClip._x=pPosx;
pClip._y=pPosy;
pPosx+=100;
thisTimeline["pageNum"+v].onRelease = function (){
i = this.pages.htmlText-1;
// the -1 is there because i=0 page number =1.
checkTwo.check.htmlText=i;

LuigiL
10/4/2005 7:17:44 PM
What is this line:
_global.i = this.pages.htmlText-1; // my guess is this returns NaN (String -
Number)
Trace that:
trace(_global.i);

About the scope:
You can use the reference you have to the current timeline:
thisTimeline["pageNum"+v].onRelease = function (){
thisTimeline.i = 10;
trace(thisTimeline.i);

And _global.i works too.
AddThis Social Bookmark Button