Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AS2 / XML

Explorer ,
Jun 12, 2009 Jun 12, 2009

I posted this earlier in Data Integration but that forum seems to be a bit quiet so I thought I'd try my luck in here.

I've an XML file with data for job recruitment (position, location, salary, etc.). In my flash movie I have a scrollpane in the first frame of the root timeline which imports the position and location of all available jobs from the XML.

What I need to do now is allow the user to click on one of these jobs and take them to the second frame on the root timeline which also has a scrollpane that will load in further details for the appropriate job from the XML.

I'm sure this is pretty simple stuff but my actionscript knowledge is poor and I can't find anything in any of the tutorials I've been reading. Any suggestions or links to tutorials would be greatly appreciated.

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 15, 2009 Jun 15, 2009

that's not the intended use of the scrollpane but if your rollovers work you should be able to use an onRelease:

jobMC.data=store the data needed to be used in the next frame

jobMC.onRollOut=function(){

moreGlobalData=this.data

whatevertimeline.nextFrame();

}

and in the next frame use moreGlobalData to populate your scrollpane.

Translate
Community Expert ,
Jun 12, 2009 Jun 12, 2009

show your current code that parses the xml and populates the scrollpane.  actually, you probably should be using a list component.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2009 Jun 12, 2009

Thanks for the reply, kglad. Here's the code I'm using:

vacanciesXML = new XML();

vacanciesXML.ignoreWhite = true;

vacanciesXML.onLoad = function(success){
    if(success) {
        var depth = 0;
        var nextY = 25;
        count = 0;
        var root = this.firstChild; // The root node
        for(var i = root.firstChild; i != null; i = i.nextSibling) {
            jobMC = attachMovie ("jobclip", "job" + count, depth ++, {_y : (nextY) , _x : (1)} );
            nextY += jobMC._height - 1;
            jobMC.jobPosition.text = i.childNodes[1].firstChild.nodeValue;
            jobMC.jobLocation.text = i.childNodes[2].firstChild.nodeValue;
            count ++;
            jobMC.btn.btntxt = "Read More";
            jobMC.onRollOver  =  function(){
                this.btn.gotoAndPlay("RollOver");}
            jobMC.onRollOut  =  function(){
                this.btn.gotoAndPlay("RollOut");}
        _parent.invalidate();
    setup();
    } else {
        trace ('Error reading XML');
    }
}
           
vacanciesXML.load("http://www.supermacs.ie/recruitment.asp");

Here's what the file looks like. Could I achieve a similar design with a list component?

vacancies.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2009 Jun 12, 2009

where is the scrollpane and what's its name?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 15, 2009 Jun 15, 2009

The scrollpane is in _parent

It's called myScrollPane1 but it's not referenced in the code because this code is in a movie clip which has been loaded into the scrollpane

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 15, 2009 Jun 15, 2009

that's not the intended use of the scrollpane but if your rollovers work you should be able to use an onRelease:

jobMC.data=store the data needed to be used in the next frame

jobMC.onRollOut=function(){

moreGlobalData=this.data

whatevertimeline.nextFrame();

}

and in the next frame use moreGlobalData to populate your scrollpane.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 15, 2009 Jun 15, 2009

Thanks kglad. In the next frame, I now have the following code:

detailText.text = moreGlobalData;

Is that correct? Please excuse my noob-ness but I'm getting "undefined" in the text box when I export the swf!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 15, 2009 Jun 15, 2009

Actually, it's ok - I got it!

I just needed to put "_root." before "moreGlobalData"

Thanks so much kglad!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 15, 2009 Jun 15, 2009
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines