Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

actionscript expert needed....

Status
Not open for further replies.

gwu

MIS
Joined
Dec 18, 2002
Messages
239
Location
US
why is it that this works:
**************************
var myLoadVars = new LoadVars();
record = _global.record;
myLoadVars.onLoad = function(success) {
picName = myLoadVars.picName;
createEmptyMovieClip("record"+record, 1);
_root.main["record"+record].loadMovie("images/"+picName);
_root.main["record"+record]._x = ourData[0];
_root.main["record"+record]._y = ourData[1];
_root.main["record"+record]._alpha = ourData[2];
_root.main["record"+record]._xscale = ourData[3];
_root.main["record"+record]._yscale = ourData[4];
};
myLoadVars.load('asp/asp.asp?Record='+record);
**************************
but this doesnt:
**************************
var myLoadVars = new LoadVars();
record = _global.record;
myLoadVars.onLoad = function(success) {
picName = myLoadVars.picName;
createEmptyMovieClip("record"+record, 1);
_root.main["record"+record].loadMovie("images/"+picName);
_root.main["record"+record]._x = ourData[0];
_root.main["record"+record]._y = ourData[1];
_root.main["record"+record]._alpha = ourData[2];
_root.main["record"+record]._xscale = ourData[3];
_root.main["record"+record]._yscale = ourData[4];
};
myLoadVars.load('asp/asp.asp?Record='+record);

var myLoadVars = new LoadVars();
record = _global.record;
myLoadVars.onLoad = function(success) {
picName = myLoadVars.picName;
createEmptyMovieClip("record"+record, 1);
_root.main["record"+record].loadMovie("images/"+picName);
_root.main["record"+record]._x = ourData[5];
_root.main["record"+record]._y = ourData[6];
_root.main["record"+record]._alpha = ourData[7];
_root.main["record"+record]._xscale = ourData[8];
_root.main["record"+record]._yscale = ourData[9];
};
myLoadVars.load('asp/asp.asp?Record='+record);
**************************
the only differece is that i am trying to repeate the code in the same frame using different data stored in the array...

thanks
 
2 variables with same name

for 2nd loadvars just use something like

var myLoadVars1 = new LoadVars();
record = _global.record;
myLoadVars1.onLoad = function(success) {
picName = myLoadVars1.picName;
createEmptyMovieClip("record"+record, 1);
_root.main["record"+record].loadMovie("images/"+picName);
_root.main["record"+record]._x = ourData[5];
_root.main["record"+record]._y = ourData[6];
_root.main["record"+record]._alpha = ourData[7];
_root.main["record"+record]._xscale = ourData[8];
_root.main["record"+record]._yscale = ourData[9];
};
myLoadVars1.load('asp/asp.asp?Record='+record);

also better to use

myloadvars1.sendandload("asp/asp.asp",myloadvars1,"post");


 
thanks for the reply!!

i had a feeling you would say that..so i tried this...still no luck. What is wrong??
**************************************
_global.myLoadVars = new array()

for (i=0;i<5;i++) {
myLoadVars = new LoadVars();
record=_global.a;
myLoadVars.onLoad = function() {
_global.total = myLoadVars.totalRecords;
picName = myLoadVars.picName;
createEmptyMovieClip(&quot;record&quot;+_global.a, 1);
_root.main[&quot;record&quot;+_global.a].loadMovie(&quot;images/&quot;+picName);
_root.main[&quot;record&quot;+_global.a]._x=ourData[5];
_root.main[&quot;record&quot;+_global.a]._y=ourData[6];
_root.main[&quot;record&quot;+_global.a]._alpha=ourData[7];
_root.main[&quot;record&quot;+_global.a]._xscale=ourData[8];
_root.main[&quot;record&quot;+_global.a]._yscale=ourData[9];
};
myloadvars.sendandload(&quot;asp/asp.asp&quot;,myloadvars,&quot;post&quot;);
 
let me try that again..i had which tek-tips thinks italics :)

******************
_global.myLoadVars = new array()

for (x=0;x<5;x++) {
y=0;
myLoadVars[x] = new LoadVars();
record=_global.a[x];
myLoadVars[x].onLoad = function() {
_global.total = myLoadVars[x].totalRecords;
picName = myLoadVars.picName;
createEmptyMovieClip(&quot;record&quot;+_global.a[x], 1);
_root.main[&quot;record&quot;+_global.a[x]].loadMovie(&quot;images/&quot;+picName);

_root.main[&quot;record&quot;+_global.a[x]]._x=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._y=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._alpha=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._xscale=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._yscale=ourData[y];
y=y+1;
};

myloadvars[x].sendandload(&quot;asp/asp.asp&quot;,myloadvars[x],&quot;post&quot;);
}
******************
 
perhaps if you just gave an explanation of what you are trying to do. I also notice now that variable picname shows up twice in original script. Are you trying to dynamically load a number of pictures into different locations.
 
thats exactly what i am trying to do. when the movie starts..load 5 pictures on the screen into 5 different locations. the name of the pic is retrieved from the database. I will try and simplify it:

******************************************
_global.myLoadVars = new array()

_global.a = new array()
_global.a[0]=0;
_global.a[1]=1;
_global.a[2]=2;
_global.a[3]=3;
_global.a[3]=4;

for (x=0;x<5;x++) {
y=0;
myLoadVars[x] = new LoadVars();
myLoadVars[x].onLoad = function() {
picName = myLoadVars.picName;
createEmptyMovieClip(&quot;record&quot;+_global.a[x], 1);
_root.main[&quot;record&quot;+_global.a[x]].loadMovie(&quot;images/&quot;+picName);
_root.main[&quot;record&quot;+_global.a[x]]._x=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._y=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._alpha=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._xscale=ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._yscale=ourData[y];
y=y+1;
};
myloadvars[x].sendandload(&quot;asp/asp.asp&quot;,myloadvars[x],&quot;post&quot;);
}
******************
 
ok much easier to load it all at once as 1 object (array)
and then use split to seperate out pics and other data

i dont know asp but with php

in php:
$string = implode(&quot;splitter&quot;,$array);

in flash:
array = string.split(&quot;splitter&quot;);

splitter can be anything you like

then loop through array placing pics and information...no need for global stuff.
 
its working a little better...but now only one image shows up,not five. it doesnt seem to want to create the other four movie clips. thanks again

************************************
var myLoadVars = new LoadVars();
myLoadVars.onLoad = function() {
picNames = myLoadVars.picNames;
test = picNames.split(&quot;,&quot;);
y=0;
z=0;
x=0;
while (x<5) {
_root.main.createEmptyMovieClip(&quot;record&quot;+_global.a[x], 1);
_root.main[&quot;record&quot;+_global.a[x]].loadMovie(&quot;images/&quot;+test[z]);
z=z+1;
_root.main[&quot;record&quot;+_global.a[x]]._x = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._y = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._alpha = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._xscale = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._yscale = ourData[y];
y=y+1;
x=x+1
}
};
myLoadVars.load('asp/asp2.asp');
stop();
 
you might try creating boxes for the movie clips first
this code will make small boxes but alter to suit

for(i=0;i<5;i++){
_root.createEmptyMovieClip(i, 100+i);
_root.main.moveTo(-12, -12);
_root.main.lineto(12, -12);
_root.main.lineTo(12, 12);
_root.main.lineTo(-12, 12);
_root._x=((130)+(i*35));
_root._y=20;
_root.main[&quot;record&quot;+_global.a[x]].loadMovie(&quot;images/&quot;+test[z]);
z=z+1;
_root.main[&quot;record&quot;+_global.a[x]]._x = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._y = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._alpha = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._xscale = ourData[y];
y=y+1;
_root.main[&quot;record&quot;+_global.a[x]]._yscale = ourData[y];
y=y+1;
x=x+1
}
}

if it still dont work why not post your fla and i will take a look at it. its often easier if you see the whole picture rather than snippets.
 
dont know if this will help but it is a workaround

import the images into the library

Place the images inside movieclips, export the movieclips for actionscript (using the linkage setting in the library) and then call it using attachMovie
 
if you are still seeking a solution I got this to work on my machine with the jpgs in the same folder as the swf

image_ary = new Array(&quot;pic1.jpg&quot;,&quot;pic2.jpg&quot;,&quot;pic3.jpg&quot;,&quot;pic4.jpg&quot;);
clip_ary = new Array();
for(index= 0; index < image_ary.length; index++) {
_root.createEmptyMovieClip(&quot;clip_&quot;+index, index+10);
clip_ary[index] = eval(&quot;clip_&quot;+index);
clip_ary[index].loadMovie(image_ary[index]);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top