A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [MX04] Out of my depth, advice needed

  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    84

    Unhappy [MX04] Out of my depth, advice needed

    I have been working on my shopping cart for months now but can't seem to get my head around arrays . This is the only thing that holding me back. I download some examples, but just got more confused then ever.

    Anyway heres the code. Can someone give me any advice?

    PHP Code:
    //changing infomation. text will be varibles on stage.
    tempproduct "title"
    tempdescription "description"
    tempsize "UK size 12"
    tempqty "1"
    tempprice "100.00"
    carttext "Your Cart Is Now Empty"
    _root.slidertwo.infotext "Your Cart Is Empty";
        
    //Setup array
    var itemtemp:Array = new Array()
    itemtemp = [tempproducttempdescriptiontempsizetempqtytempprice];

    trace(itemtemp);
    //trace each in array
    trace(itemtemp[0]);
    trace(itemtemp[1]);
    trace(itemtemp[2]);
    trace(itemtemp[3]);
    trace(itemtemp[4]);

    addbtn.onPress = function() {
        
    //gets height of cart so I can place mc under last mc
        
    +i;
        
    i++;
        
    mcheight _root.slidertwo.myScroller.spContentHolder._height;
        
    itemheight 90;
        var 
    scrollheight:Number mcheight+itemheight;
        
    trace(itemheight);
        
    trace(mcheight);
        
    trace(scrollheight);

    //
        //search all mcs to see if its already in the basket, if it matches then
        //itemtemp.quantity++; ?
        
    if (_root.slidertwo.myScroller.spContentHolder["productitem"+i].product == tempproduct) {
            
    // if the qty is under 10.
            
    if (this.inputItem1q 10) {
                
    // add the tempqty amount to it.
                
    this.inputItem1q+tempqty;
                
    //if it is over 10.
                
    if (this.inputItem1q+tempqty 10) {
                    
    //set it to 10
                    
    this.inputItem1q 10
                
    }
            }
        } else {
            
    totalproducts++;
            
    trace(totalproducts);
            if (
    totalproducts == 1) {
                
    _root.slidertwo.infotext = +totalproducts +" product in your cart";;
            } else {
                
    _root.slidertwo.infotext = +totalproducts +" products in your cart";;
            }
            
    _root.slidertwo.myScroller.spContentHolder.attachMovie("productitem""productitem"+ii, {id:i});
            var 
    tempVal = eval("_root.slidertwo.myScroller.spContentHolder.productitem"+i);
            
    tempVal.mymenu = new Object();
            
    tempVal.product tempproduct;
            
    tempVal.description tempdescription;
            
    tempVal.sizeandcolour tempsize;
            
    tempVal.inputItem1q tempqty;
            
    tempVal.item1p tempprice;
            
    //tempVal.loader_mc.loadMovie(cStr);
            
    setProperty("_root.slidertwo.myScroller.spContentHolder.productitem"+i_ymcheight);
            
    //deletebtns
            
    tempVal.deletebtn.onRelease = function() {
                
    totalproducts--;
                
    trace(totalproducts);
                for (var 
    = (this._parent.id+1); i<100i++) {
                    
    this._parent.removeMovieClip();
                    
    _root.slidertwo.myScroller.spContentHolder["productitem"+i]._y -= itemheight;
                    if (
    totalproducts == 1) {
                        
    _root.slidertwo.infotext = +totalproducts +" product in your cart";;
                    } else {
                        
    _root.slidertwo.infotext = +totalproducts +" products in your cart";;
                    }
                }
                
    _root.slidertwo.myScroller.invalidate();
                
    _root.slidertwo.myScroller.vPosition _root.slidertwo.myScroller.maxVPosition;
                if (
    totalproducts == 0) {
                    
    _root.slidertwo.inputTotal totalproducts;
                    
    _root.slidertwo.infotext carttext;
                }
            }
            
    _root.slidertwo.deleteallbtn.onRelease = function() {
                
    totalproducts 0;
                
    trace(totalproducts);
                
    _root.slidertwo.inputTotal 0;
                for (var 
    = (tempVal.id-100); i<100i++) {
                    
    _root.slidertwo.myScroller.spContentHolder["productitem"+i].removeMovieClip();
                    
    _root.slidertwo.myScroller.invalidate();
                    
    _root.slidertwo.infotext carttext;
                }
            }
        }
    }
    addbtn.onRelease = function() {
        
    _root.slidertwo.myScroller.vPosition _root.slidertwo.myScroller.maxVPosition;


  2. #2

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    84
    when I created the cart I did not use any arrays at all. so when I buy something it just copies a movieclip from the library put the varibles in the newly created mc and puts it in a scroll area. What I have to do is use arrays, so I can send the contents of the cart to a third party. ie Paypal. I created the a array but I don't know what to do now. Do I push array? Do I use the array to fill in the movieclips automatically and to check qty.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center