Skip navigation
Nour El-Din Elba
Currently Being Moderated

Clearer question (really stuck on this)

Jul 9, 2012 10:49 PM

Me again, still looking for a solution in vain. I just want a working slideshow for each project, but I made the projects using a for loop, making it more confusing (was following a tutorial). The thing is, in the tutorial, the guy only had one picture up per project, I want many.

 

 

On my projects page(frame), I have Project Panels. Just regular blocks displaying a thumbnail image of the proect, and when clicked, it opens up a "fullProjectPanel" from the main time line.

 

This is the code for the fullProjectPanel:

 

 

 

var fullProjectPanelMulti:FullProjectPanelMulti;

 

 

// ADD FULL PROJECT PANEL ( runs when clicking on project panel(2nd frame of mainContainer, line 28))

 

function addFullPanelMulti(o:Number):void {

   

 

    fullProjectPanelMulti = new FullProjectPanelMulti;

   

    fullProjectPanelMulti.title.text = projectTitleM[o]

    fullProjectPanelMulti.info.text = projectInfoM[o]

    fullProjectPanelMulti.content.text = projectContentM[o]

    fullProjectPanelMulti.client.text = projectClientM[o]

    fullProjectPanelMulti.media.text= projectMediaM[o]

    fullProjectPanelMulti.technology.text = projectTechnologyM[o]

    fullProjectPanelMulti.link.text = projectLinkM[o]

    fullProjectPanelMulti.loadImage(projectImageM2[o]);

    fullProjectPanelMulti.loadImage2(projectImageM3[o]);

   

   

    TweenLite.from(fullProjectPanelMulti, 0.6, {alpha:0, delay:1.2});

    addChild(fullProjectPanelMulti);

   

    // indicate state

    fullProjectPanelUpMulti=true;

   

}

 

 

Now, the loadImage and loadImage2 functions are present on the fullProjectPanelMulti movieclip itself, and the code is:

 

function loadImage(imagePath:String):void

{

 

 

    var ldr:Loader = new Loader();

    var url:String = imagePath;

    var urlReq:URLRequest = new URLRequest(url);

 

    ldr.x = -35;

    ldr.y = 67;

 

    ldr.load(urlReq);

    addChild(ldr);

 

}

 

 

 

 

function loadImage2(imagePath:String):void

{

 

 

    var ldr:Loader = new Loader();

    var url:String = imagePath;

    var urlReq:URLRequest = new URLRequest(url);

 

    ldr.x = -35;

    ldr.y = 67;

 

    ldr.load(urlReq);

    addChild(ldr);

 

}

 

 

 

I have a couple of questions. First, how can there be two "ldr" with the same name? Both display the pictures they're supposed to, but they have the same name?

 

Is it because they're confined to the function?

 

Secondly, I cannot manipulate the "ldr"s at all, seeing as they only exist within the function; how can I make it so I can change them around with properties like "ldr.visible = false" not in the function.

 

Also, I don't know if this is relevant or not, but the code for accessing the XML file is:

 

 

var projectImageM:XMLList;

var projectImageM2:XMLList;

 

 

var xml:XMLLoader = new XMLLoader(this,"data.xml");

 

// FUNCTION THAT GETS CALLED FROM CLASS WHEN XML IS LOADED

function getXML(xmlData:XML):void {

 

 

projectImageM = xmlData.projectsM.project.image_path;
projectImageM2 = xmlData.projectsM.project.image_path2;

 

 

 

 

I'm sorry this is long, but I really have no idea what to do ._., any help at ALL would be appreciated. Thanks.

 
Replies
  • Currently Being Moderated
    Jul 10, 2012 4:21 AM   in reply to Nour El-Din Elba

    "supposed to, but they have the same name?

     

    Is it because they're confined to the function?

     

    Secondly, I cannot manipulate the "ldr"s at all, seeing as they only exist within the function; how can I make it so I can change them around with properties like "ldr.visible = false" not in the function."

     

     

     

    You answered your own question actually - you know the ldr's exist only within the function - which is why they can have the same name. When a variable is defined inside a function it's said to have local scope. You see this a lot with for(var i:int = 0 - i is declared in multiple functions typically. To see it outside the function you must declare it outside the function.

     

    var ldr:Loader = new Loader();

    function loadImage(imagePath:String):void

    {

         ldr.load(urlReq);

    }

    function showHide(vis:Boolean):void

    {

         ldr.visible = vis;

    }

    etc...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points