I changed some of the VAR names in mine...the var in the textField too..
Printable View
I changed some of the VAR names in mine...the var in the textField too..
No difference. I still get nothing.
To be clear, the attachProduct.label is assigned the proper values, I just don't know how to show them on the stage.
o
post the current code you have.
which example are you trying?..the exampel with 1 ARRAY or with TWO ARRAYS??
I made an edit to my original post as well (had the wrong "attachProduct.label =" at first) but I corrected it before you had posted...so not sure if you saw new or old code?
also..post the contents of your .txt file...so i can see how you have it set up.
Here is the text file
myVars=Ceridian_Nonexempt_Employee_QRG|Computer_Se curity_QRG|Construction|betatesting|toocool|right| left|middle of the road.Why is sthat|
here is the code
var myVarText = "C:\\Documents and Settings\\wallen\\Desktop\\Flash buttons\\myVars.txt"
var my_lv = new LoadVars();
var my_X = 100 //horizontal spacing
var my_Y = 40 //vertical spacing(from top)
my_lv.onLoad = function(success){
if (success){
myArray = [];
myArray = my_lv.myVars.split("|");
for(i=0;i<(myArray.length -1);i++) {
var attachProduct = attachMovie("button","button"+i,i);
//set position of button
attachProduct._x += i*my_X; //incremented for each button
attachProduct._y += my_Y; //pixels from top
attachProduct.label = myArray[i];
//if buttons reach a certain point, start a new row.
if(attachProduct._x > 600){
attachProduct._x += -700; //incremented for each button
attachProduct._y += my_Y +10; //pixels from top
attachProduct.label = myArray[i];
}
}
}
}
my_lv.load(myVarText);
I am using the one with 1 ARRAY
can you use {code} & {/code} tags? (but replace the { with brackets [ ] ;)
it makes the code easier to read..
but it looks as if you have added another "if" statement...and you have the attachProduct.label INSIDE that if statement...it should be outside of it.. just by a quick look atthe code in the 'email' I have tested it out yet...
I also have the attachProduct.label outside of the if statement. The code will run the first time then test to see if it is at the edge of the screen. I am able to assign the right value to the attachProduct.label, the problem is nothing shows on the screen. If I debug, I will see the proper values for each button. I am trying to find out how to show the labels on the screen.
Thanks!
Bill
your buttons show up..but they are blank? Are you using your OWN buttons? ones you made?..or the component buttons? If they are your OWN, then they do not HAVE labels.
you will have to create yoru OWN 'buttons' (they will really have to be movieClips) with a dynamic textField inside of it to get the "text" to show up.
www.dmstudios.net/demos/splitArrayHelp.zip
I was using my own buttons. (Did I say I was a newbie?) Well that explains it! I will try it using the componet buttons
Thanks!
0
LOL..its ok. (you learn something new everyday). basically you can create ANYTHING in the library and attach it as you are doing your 'buttons'. So you could create a movieClip that has dynamic textFields that you can populate with data..or blank/empty movieClips that you can populate with images or .swf's..possibilities are endless...
Could you send me that file again in flashMX format? I don't seem to be able to open the FLA.
Thanks
O
unfortunately..I can NOT...I am solely on FLASH 8 now... and can only save to FLASH 8 or MX 2004. I can however post it in MX 2004 format..and anyone with MX 2004 can save to MX. You would probably have to post and ask for someone with MX 2004 to save in MX format fo ryou.
up to you....let me know.
that would work. I think some one here has 2004
thanks!
Thanks! While I am waiting on someone to convert that file for me, can you tell me about this code. I decided to us my own buttons. I created a button with the three states (up,over,down). then on a level above the button but IN the same button symbol I added a layer and put a dynamic textbox on it with an instance name of "label" then I use this code,
<code>
//set position of button
attachProduct._x += i*my_X; //incremented for each button
attachProduct._y += my_Y; //pixels from top
attachProduct.label = myArray[i];
</code>
...from yesterday. everything loads but the text fields are still blank. any ideas?
O
you can NOT target omvieClips or even specific 'states' of a button. what you will need to do is make a movieClip that acts exactly as your button does.
example:
1.) make blank movieCip
2.) frame 1 / layer 1: red square (or image of button, up state of 'button')
3.) frame 1 / layer 2: dynamic textField (INSTANCE NAME not VAR name called label1)
4.) stop action on frame 1
5.) frame 2 / layer 1: blue square (or image for down state of 'button')
6.) frame 2 / layer 2: continue same frame (insert frame) from frame 1/ layer 2.
7.) stop action on frame 2
make a new layer (3) call it actions.
put this code in it:
test it....this should work just like a regular button now... now in the library, set the linkage like you did for your REAL buttons...Code:this.onRollOver = function() {
this.gotoAndStop(2);
}
this.onRollOut = function() {
this.gotoAndStop(1);
}
Too cool! Works like a charm!
Thanks!
what you have just learned is VERY VERY powerful code in my opinion...maybe not too fancy..but VERY practical. the objects you attach, dont have to be simple images or buttons, that can be comeplete movies, templates for a product even..that each attachedClip gets populated by that products image, price, color, size, description, and than placed on the stage.
I like to think of them as a .NET repeater panel equivelent. :)
code for GRID layout/positioning:
actionscript Code:var totalClips:Number = 25;
function createTemplates():Void {
//Define the grid columns
var columns:Number = 5;
//Define the spacing/padding
var hPadding:Number = 5;
var vPadding:Number = 5;
for (i = 0; i < totalClips; i++) {
var newClip:MovieClip = attachMovie("templateClip", "product" + i, i);
//initial positions
newClip._x = 10;
newClip._y = 10;
//grid positioning
newClip._x += (i % columns) * (hPadding + newClip._width);
newClip._y += Math.floor(i / columns) * (hPadding + newClip._width);
}
}
createTemplates();