Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Referencing


krl
6/21/2004 9:56:21 PM
If I create a clip or text field like this:

max_amt = 10
for(i=0; i<=max_amt; i++){
createEmptyMovieClip("clip"+i,i);
clipi.createTextField("text"+i,i+max_amt, i, i*2,100,20);
}

how do I access clip0._x or clip5's value with i's?
a cheesy example how do I assign the first clip's (clip0) _x to the value of
the last clip then increment...
Jack.
6/21/2004 10:02:28 PM
something like -
max_amt = 10
for(var ii=0; ii<=max_amt; ii++){
rClip = createEmptyMovieClip("clip"+ii,ii);
rClip.createTextField("text"+ii,ii+max_amt,0,0,100,20);
tClip = rClip["text"+ii];
tClip.text = ii;
tClip._y = ii*30;
}

hth
krl
6/21/2004 10:26:36 PM
Jack,
Thanks for the help.
Jack.
6/21/2004 10:54:20 PM
passing arrays through a function is probably
the most efficient, create your array in your loop
and pass it, or hardcode as in this example -

aTxt1=["q","w","e","r","t"];
aTxt2=["a","s","d","f","g"];

function fields(arr){
max_amt = 4;
for(var ii=0; ii<=max_amt; ii++){
rClip = createEmptyMovieClip("clip"+ii,ii);
rClip.createTextField("text"+ii,ii+max_amt,0,0,100,20);
tClip = rClip["text"+ii];
tClip.text = arr[ ii ];
tClip._y = ii*30;
}
};

fields(aTxt1);

btn.onPress = function(){
fields(aTxt2);
}

hth
krl
6/21/2004 11:58:55 PM
I want to add a button to each of the clips so that they'll go to a location,
but it's not working.
Here's what I got:
aTxt1=["q","w","e","r","t"];
aTxt2=["a","s","d","f","g"];

function fields(arr){
max_amt = 4;
for(var ii=0; ii<=max_amt; ii++){
rClip = createEmptyMovieClip("clip"+ii,ii);
rClip.createTextField("text"+ii,ii+max_amt,i,i*100,100,20);
tClip = rClip["text"+ii];
tClip._y = ii*30;

tClip.text = arr[ ii ];
rclip.onPress = function(){
getURL("http://www."+aTxt1[ii],"_blank")
//getURL("http://www."+aTxt1[3],"_blank") // works, but is wierd...
fields(aTxt2);
}
}
};
fields(aTxt1);

Any way to press functions for each in the main function?

Jack.
6/22/2004 11:38:44 AM
try -
aTxt1=["q","w","e","r","t"];
aTxt2=["a","s","d","f","g"];

function fields(arr){
max_amt = 4;
for(var ii=0; ii<=max_amt; ii++){
rClip = createEmptyMovieClip("clip"+ii,ii);
rClip.createTextField("text"+ii,ii+max_amt,i,i*100,100,20);
tClip = rClip["text"+ii];
tClip._y = ii*30;
tClip.text = arr[ ii ];
rClip.onPress = function(){
temp = this._name.split("clip");
openWindow(temp[1]); };
}
};
fields(aTxt1);

function openWindow(num){
getURL("http://www."+aTxt1,"_blank");
};

hth
Jack.
6/22/2004 4:26:56 PM
that should be -
function openWindow(num){
getURL("http://www."+aTxt1[ num ],"_blank");
};

why does this forum post screw up on
krl
6/22/2004 5:59:08 PM
Thanks Jack,
That's great, I changed the getURL to _self and in while in flash it was opening the link 3 times, but when I changed it to _blank it only opened it once. Ever seen that happen before?
Jack.
6/22/2004 6:23:47 PM
_self is the default action of getURL, so should not be needed,
old pros - (Byron Canfield comes to mind) recommended
that it should NEVER be used as it is unstable.

hth

ps .. for correct results, always test getURL in the browser.
krl
6/22/2004 6:31:03 PM
Cool. I'll keep that in mind. Thanks.
AddThis Social Bookmark Button