dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Multiple Paramaters in functions get them to work... help..

Hybrid View

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147

    Multiple Paramaters in functions get them to work... help..

    Hi guys me again... One last cry for help..

    Ok what i'm basicly trying to do is write a function where i can populate several vars at once by hitting a button... my data is coming from an array ported from xml.. the areas in my array are sectional array.

    Inspire
    Create
    Play

    and the attributes attached to these

    sourcedir
    Artist

    Etc etc..


    so to trace one bit of the bits of information you would call this array code..

    trace (createArtist[1]);

    this would display

    Andrew Newman

    So what i'm basicly doing it trying to make the process easier now i'm no action script wizz more of a designer... so i'm wondering how i can get the following bit of code to work.

    the sName needs to be an parameter which i can define..

    and the same with the sPos..

    i'm ov not coding the thing right cause it's coming up undefined when i trace the values..

    i'm really confused... can anyone help me???


    Code:
    //** AREA POPULATION **//
    
    function populateCONTENT(sName:String,sPos:Number):Void;
    
    	_root.playMovie = sNamesourcedir[sPos]
    	_root.artistName = sNameArtist[sPos]
    	_root.medium = sNameMedium[sPos]
    	_root.about = sNameAbout[sPos]
    	_root.project = sNameProject[sPos]
    }
    trace("video file = "+sNamesourcedir[sPos])
    trace("artist name = "+sNameArtist[sPos])
    trace("medium = "+sNameMedium[sPos])
    trace("about = "+sNameAbout[sPos])
    trace("project = "+sNameProject[sPos])
    
    
    };
    //Function Called..
    
    populateCONTENT(sName=Inspire,sPos=3);

  2. #2
    Senior Member RangrJay's Avatar
    Join Date
    Sep 2005
    Location
    Las Vegas
    Posts
    163
    the ';' after your strict data type for your function doesn't belong, put an open brace '{'

    simple mistake, easy to miss
    Xero Patience Studios
    Web Design
    Software Development
    Graphic/Logo Design

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    Ok well yeah that was that... lol

    no i've got no more error messages but it's still coming up undefined...

    anyideas?

  4. #4
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    Sorry about the bad grammer there... doh...

    typo city..

    ummm.. well i know i'm doing something fundamentally wrong but just can't think what.... gonna have to get my head on and work it out.. if it's something stupid think i'm gonna eat my socks.

  5. #5
    Senior Member RangrJay's Avatar
    Join Date
    Sep 2005
    Location
    Las Vegas
    Posts
    163
    what are the names of your arrays? and how are they defined?
    Xero Patience Studios
    Web Design
    Software Development
    Graphic/Logo Design

  6. #6
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    Ok i've slightly rewrote this now... after a bit of thought... but still no joy..

    here is my full code for pulling in my content.

    Code:
     // CONTENT MANAGER
    
    //XML CONTENT MANAGER
    
    contentmanager_xml = new XML();
    contentmanager_xml.onLoad = convertXML;
    contentmanager_xml.ignoreWhite = true;
    contentmanager_xml.load("XMLDATA/contentmanagerFIN.xml");
    contentmanager_xml.onLoad = function(Success){
    	if (Success){
    	convertXML();
    		trace("Content Manager loaded")
    	}else{
    		trace("Content Manager failed to load.")
    	}
    };
    									 
    function convertXML() {
    	
    	
    	// setting up an array containing all of the attributes of the Sections
    	
    	SectionArray = new Array("Create", "Inspire", "Play");
    
    	//XML FORMAT EXAMPLE  - Create Entry
    	//<create id= "1" lastupdate ="01/04/200" 
    	//Artist = "Name" 
    	//Medium = "Video" 
    	//About = "Copy Goes Here" 
    	//Project = "StartUnit" 
    	//imagetitle = "SimpleMind" 
    	//main = "create1/images/image.jpg" 
    	//thmb="create1/thumb/thmb.jpg" 
    	//mediatitle = "SimpleMind" 
    	//sourcedir= "create/create1/video.flv" </>
    	
    	// create new Arrays so each Area will have the following arrays available
    	// Example Section "Create"
    	// CreateArtist[]; CreateMedium[]; CreateAbout[]; CreateProject[]; ETC ETC
    	// Use the arrays to hold the information pulled in from the XML file
    	for (p=0; p<SectionArray.length; p++) {
    		_root[SectionArray[p]+ "id"] = new Array();
    		_root[SectionArray[p]+ "updated"] = new Array();
    		_root[SectionArray[p]+ "ArtistName"] = new Array();
    		_root[SectionArray[p]+ "Medium"] = new Array();
    		_root[SectionArray[p]+ "About"] = new Array();
    		_root[SectionArray[p]+ "Project"] = new Array();
    		_root[SectionArray[p]+ "imagetitle"] = new Array();
    		_root[SectionArray[p]+ "main"] = new Array();
    		_root[SectionArray[p]+ "thmb"] = new Array();
    		_root[SectionArray[p]+ "mediatitle"] = new Array();
    		_root[SectionArray[p]+ "sourcedir"] = new Array();
    		_root[SectionArray[p]+ "backgroundIMG"] = new Array();
    	}
    	// create new XML holder; for the <StartUnitContent> node
    	StartUnitContentTag = new XML();
    	// create new XML holder; for the <Section> nodes
    	SectionTag = new XML();
    	// fill the StartUnitContentTag with the <StartUnitContent> node contents
    	StartUnitContentTag = contentmanager_xml.firstChild;
    		txt2.text="";
    	// check to see if the right node has been found and then continue
    	if (StartUnitContentTag.nodeName == "startunitcontent") {
    		// setting a global variable Version Number. 
    		Version = StartUnitContentTag.attributes.curVersion;
    		// fill the SectionTag with the <Section> node contents
    		SectionTag = StartUnitContentTag.childNodes;
    		// Create Loop for sections
    		for (i=0; i<SectionTag.length; i++) {
    			// set the variable Section to the First Section node
    			Section = SectionTag[i].attributes.name;
    			// set a new XML holder for each Section. e.g if the Section was Create
    			// CreateList would be the new XML holder
    			_root[Section+ "List"] = new XML();
    			// give the new XML holder some content
    			_root[Section+ "List"] = SectionTag[i].childNodes;
    			// check to see if the SectionTag has any content
    			if (SectionTag[i].hasChildNodes()) {
    				// create a loop to retrive each entry from the <Section> nodes
    				for (z=0; z<_root[Section+"List"].length; z++) {
    					
    					// create a new XML holder for each entry
    					entryTag = new XML();
    					
    					// give the new holder some content
    					entryTag = _root[Section+"List"][z];
    					
    					// get the content and place it into arrays.
    					// add arrays together, sync.
    					
    					_root[Section+"id"].push(entryTag.attributes.id);
    					_root[Section+"updated"].push(entryTag.attributes.updated);
    					_root[Section+"ArtistName"].push(entryTag.attributes.Artist);
    					_root[Section+"Medium"].push(entryTag.attributes.Medium);
    					_root[Section+"About"].push(entryTag.attributes.About);
    					_root[Section+"Project"].push(entryTag.attributes.Project);
    					_root[Section+"imagetitle"].push(entryTag.attributes.imagetitle);
    					_root[Section+"main"].push(entryTag.attributes.main);
    					_root[Section+"thmb"].push(entryTag.attributes.thmb);
    					_root[Section+"mediatitle"].push(entryTag.attributes.mediatitle);
    					_root[Section+"sourcedir"].push(entryTag.attributes.sourcedir);
    					_root[Section+"backgroundIMG"].push(entryTag.attributes.backgroundIMG);
    				}
    			}
    		} trace("the thing we are tracing is...."+Createthmb[3])
    	}	
    }
    
    // AREA POPULATION
    
    function populateCONTENT(sName:String,sPos:Number):Void {
    
    	_root.playMovie=_root[sName+"sourcedir"][sPos]
    	_root.ArtistName=_root[sName+"ArtistName"][sPos]
    	_root.Medium=_root[sName+"Medium"][sPos]
    	_root.About=_root[sName+"About"][sPos]
    	_root.Project=_root[sName+"Project"][sPos]
    }
    
    
    //Function Called..
    
    populateCONTENT("Inspire",3);

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