dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: xml based dynamic variables to post to form

  1. #1
    Junior Member
    Join Date
    Jul 2003
    Posts
    2

    xml based dynamic variables to post to form

    Hey,

    I am trying to create dynamic variables to post to a form based on the content of some xml. I have loaded 15 objects which act as buttons into my movie and each button will trace the exact title as wanted. What i want to know is that when i click the button the title is stored in a dynamically created variable to be used later for posted to a php form. Below is my code, any help will greatly be accepted.

    PHP Code:
    // sprinkles function
    function GenerateSprinkles(sprinkles_xml) {
        var 
    sprinkles_qty sprinkles_xml.firstChild.attributes.maxi;
        
    _global.sprinkles_images sprinkles_xml.firstChild.childNodes;
        
    _global.totalSprinklesheight sprinkles_images.length*31;
        for (var 
    0i<sprinkles_images.lengthi++) {
            var 
    varbuttons "select"+i;
            var 
    currentSprinkles sprinkles_images[i];
            
    _global.current_sprinkles_mc sprinkles_menu.createEmptyMovieClip("sprinkles_object"+ii);
            
    current_sprinkles_mc._y i*sprinkles_space;
            
    current_sprinkles_mc.createEmptyMovieClip("thumb_sprinkles_container",0);
            if (
    currentSprinkles.attributes.thumb.length == 0) {
                
    current_sprinkles_mc.thumb_sprinkles_container.attachMovie("sprinkles_mc","sprinkles_mc_list",1);
                
            } else if (
    currentSprinkles.attributes.thumb.length>0) {
                
                
    current_sprinkles_mc.createEmptyMovieClip("thumb_sprinkles_inner_container",1);
                
    current_sprinkles_mc.thumb_sprinkles_inner_container.attachMovie("sprinkles_mc_img","sprinkles_mc_list_img",1);
                
    current_sprinkles_mc.thumb_sprinkles_inner_container.sprinkles_mc_list_img.sprinkles_img.loadMovie(currentSprinkles.attributes.thumb);
                
    current_sprinkles_mc.thumb_sprinkles_inner_container.sprinkles_mc_list_img.sprinkles_name.autoSize true;
                
    current_sprinkles_mc.thumb_sprinkles_inner_container.sprinkles_mc_list_img.sprinkles_name.htmlText currentSprinkles.attributes.title;
                
    current_sprinkles_mc.thumb_sprinkles_inner_container.sprinkles_mc_list_img.sprinkles_name._y = (current_sprinkles_mc.thumb_sprinkles_inner_container._height*.5)-(10*.5);
                
            }
            if(
    curFrame != "sprinkles"){
                
    current_sprinkles_mc.enabled false;
            }
            var 
    SprinklesBtnColour = new Color(current_sprinkles_mc.thumb_sprinkles_container.sprinkles_mc_list.sprinkles_colour);
            
    SprinklesBtnColour.setRGB(currentSprinkles.attributes.colour);

            
    current_sprinkles_mc.thumb_sprinkles_container.sprinkles_mc_list.sprinkles_name.autoSize true;
            
    current_sprinkles_mc.thumb_sprinkles_container.sprinkles_mc_list.sprinkles_name.htmlText currentSprinkles.attributes.title;
            
    current_sprinkles_mc.thumb_sprinkles_container.sprinkles_mc_list.sprinkles_name._y = (current_sprinkles_mc.thumb_sprinkles_container._height*.5)-(current_sprinkles_mc.thumb_sprinkles_container.sprinkles_mc_list.sprinkles_name._height*.5);
            
            
    current_sprinkles_mc.title currentSprinkles.attributes.title;
            
    current_sprinkles_mc.image currentSprinkles.attributes.colour;
            
    current_sprinkles_mc.cost currentSprinkles.attributes.cost;
            
            
    current_sprinkles_mc.onRelease = function() {
                
    current_sprinkles_mc this.title;
                
    trace(current_sprinkles_mc);
                
    output4.text current_sprinkles_mc;
                
    clicked++;
                if(
    clicked >= sprinkles_qty){
                    
    Twease.tween({target:sprinkles_menutime:0.5_alpha:30});
                    
    alerts.alertmsg.text "You have reached the limit";
                    
    Twease.tween({target:alerts_y:'300'time:1ease:'easeInOutQuad'});
                    
    Twease.tween({target:alerts_y:'-300'time:1delay:3ease:'easeInOutQuad'});
                }
                
                
    _global.sprinklescost Number(this.cost);
                
    sprinkles_costs sprinklescost+sprinklescost+sprinklescost;
                
    totalcost shapecost+fillingcost+icingcost+sprinkles_costs;
                
    price_tv.total_cost.text ""+totalcost;
                };
            
    scrollingSPRINKLE = function () {
                
    sprinkles_menu.setMask(maskedSprinkles);
                var 
    scrollHeight:Number scrollTrack._height;
                var 
    contentHeight:Number sprinkles_menu._height+15;
                var 
    scrollFaceHeight:Number scrollFace._height;
                var 
    maskHeight:Number maskedSprinkles._height;
                var 
    initPosition:Number scrollFace._y=scrollTrack._y;
                var 
    initContentPos:Number sprinkles_menu._y;
                var 
    finalContentPos:Number maskHeight-contentHeight+initContentPos;
                var 
    left:Number scrollTrack._x;
                var 
    top:Number scrollTrack._y;
                var 
    right:Number scrollTrack._x;
                var 
    bottom:Number scrollTrack._height-scrollFaceHeight+scrollTrack._y;
                var 
    dy:Number 0;
                var 
    speed:Number 10;
                var 
    moveVal:Number = (contentHeight-maskHeight)/(scrollHeight-scrollFaceHeight);
                
    scrollFace.onPress = function() {
                    var 
    currPos:Number this._y;
                    
    startDrag(thisfalselefttoprightbottom);
                    
    this.onMouseMove = function() {
                        
    dy Math.abs(initPosition-this._y);
                        
    sprinkles_menu._y Math.round(dy*-1*moveVal+initContentPos);
                    };
                };
                
    scrollFace.onMouseUp = function() {
                    
    stopDrag();
                    
    delete this.onMouseMove;
                };
                
    SPbtnUp.onPress = function() {
                    
    this.onEnterFrame = function() {
                        if (
    sprinkles_menu._y+speed<maskedSprinkles._y) {
                            if (
    scrollFace._y<=top) {
                                
    scrollFace._y top;
                            } else {
                                
    scrollFace._y -= speed/moveVal;
                            }
                            
    sprinkles_menu._y += speed;
                        } else {
                            
    scrollFace._y top;
                            
    sprinkles_menu._y maskedSprinkles._y;
                            
    delete this.onEnterFrame;
                        }
                    };
                };
                
    SPbtnUp.onDragOut = function() {
                    
    delete this.onEnterFrame;
                };
                
    SPbtnUp.onRelease = function() {
                    
    delete this.onEnterFrame;
                };
                
    SPbtnDown.onPress = function() {
                    
    this.onEnterFrame = function() {
                        if (
    sprinkles_menu._y-speed>finalContentPos) {
                            if (
    scrollFace._y>=bottom) {
                                
    scrollFace._y bottom;
                            } else {
                                
    scrollFace._y += speed/moveVal;
                            }
                            
    sprinkles_menu._y -= speed;
                        } else {
                            
    scrollFace._y bottom;
                            
    sprinkles_menu._y finalContentPos;
                            
    delete this.onEnterFrame;
                        }
                    };
                };
                
    SPbtnDown.onRelease = function() {
                    
    delete this.onEnterFrame;
                };
                
    SPbtnDown.onDragOut = function() {
                    
    delete this.onEnterFrame;
                };
                if (
    contentHeight<maskHeight) {
                    
    scrollFace._visible false;
                    
    SPbtnUp.enabled false;
                    
    SPbtnDown.enabled false;
                } else {
                    
    scrollFace._visible true;
                    
    SPbtnUp.enabled true;
                    
    SPbtnDown.enabled true;
                }
            };
            
    scrollingSPRINKLE();
        }

    Dee

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I didnt go through you code alot.. since there is alot there..and you really only need to focus on the CLICK (onPress) event of these 'buttons'....correct?


    You need to save the 'title/var' inside of each of these buttons..once it is clicked... to (eventually be sent to a php script).....correct?

    is there any requirements? or order....or ID to the data being sent so the PHP script knows how to handle it?

    can you create an object array and just push your data into it on each click..then pass the whole array to your script?.. or loop through it?

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