To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-15-2007, 09:25 PM   #1
chur
Senior Member
 
Join Date: Mar 2007
Posts: 133
[F8]How to access functions in external swfs and pass them variables?

Hi,

Im very close to the end of building my site, although i have one major issue i have to deal with.

Basically the homepage has links to different work in the portfolio and i need each of these to link to the correct sections of the external portfolio.swf (without having to create new swfs for each possibility...). I have a function called loadPortfolioSelection(); in the portfolio.swf:

function loadPortfolioSelection(selectedWork:String):Void {
currentPage = selectedWork;
this[selectedWork + "_mc"].gotoAndStop(7);
this[selectedWork + "Text_mc"].gotoAndPlay("_in");
mcLoader.loadClip(this[selectedWork+".swf"], this[selectedWork + "Loader_mc"]);
trace("It worked");
}



My problem is that i am unable to call this function from the main swf and pass it a variable.

My code inside home.swf is

portfolioLoader_mc.loadPortfolioSelection(page);

*The page variable holds the value i want (tested it with a trace(page))


I can't even trigger the trace command in loadPortfolioSelection(); so its obviously not executing this function. I've tried a number of different ways to execute the function but i just can't get it working.


Any help would be greatly appreciated.
chur is offline   Reply With Quote
Old 08-16-2007, 02:38 AM   #2
chur
Senior Member
 
Join Date: Mar 2007
Posts: 133
Ok i’ve done a bit of an update but im still having problems. I’ll try and outline everything.

Home.swf (relevant code):
PHP Code:
box2Hit_mc.onRelease = function () {
    
removeCurrentPage(currentPage); //remove current page
    
currentPage = "portfolio";
    
loadExternalSwf("portfolio");
    
portfolioLoader_mc.loadPortfolioSelection("work2"); //show the work 2 in the portfolio
}

function
loadExternalSwf(page:String):Void {
    
mcLoader.loadClip(page + ".swf",page + "Loader_mc");
    
this[page + "_mc"].gotoAndStop(7);
    
extAnimMask_mc.visible = false;
}
Portfolio.swf (relevant code):
PHP Code:
function loadPortfolioSelection(selectedWork:String):Void {
    
currentPage = selectedWork;
    
loadProject(selectedWork);
    
trace("loadPortfolioSelection Executed");
}

function
loadProject(page:String):Void {
    for(var
i=1; i<=numProjects; i++){
        if(
currentPage == "work"+i){
            
_root["work"+i+"Loader_mc"]["mainMask_mc"].gotoAndPlay("_out");
            
_root["work"+i+"Loader_mc"]["viewPrevious_mc"].gotoAndPlay("_off");
            
_root["work"+i+"Loader_mc"]["viewNext_mc"].gotoAndPlay("_off");
            
_root["work"+i+"Loader_mc"].clearAnimInterval();
            
trace(i);
        }
    }    
    
this[currentPage + "_mc"].gotoAndPlay("_out");         //remove highlighting of nav text
    
this[currentPage + "Text_mc"].gotoAndPlay("_out");   //remove text
    
mcLoader.loadClip(page + ".swf",page + "Loader_mc"); //load new project
    
this[page + "Text_mc"].gotoAndPlay("_in");             //bring new text in
    
this[page + "_mc"].gotoAndStop(7);                     //highlight nav text
    
currentPage = page;
}
Now here’s the problem. On the first box2Hit_mc.onRelease() the portfolio section loads but the work is not selected and using the trace command i found that loadPortfolioSelection() is not being called at all. However, if i go back to the homepage and click the same box again, loadPortfolioSelection() is executed (trace shows up), but the work is not shown, so loadProject is not working correctly. I then test loadProject using trace (inside the if statement in the for loop) and it shows the correct value has been passed from home.swf to portfolio.swf (page = “work2”). However for some reason the work2.swf never loads, the new text does not come in, and the nav wont highlight (so basically nothing changes).

This has been annoying me for a while now. I would be thankful for any help anyone can provide. Thx
chur is offline   Reply With Quote
Old 08-16-2007, 08:34 AM   #3
chur
Senior Member
 
Join Date: Mar 2007
Posts: 133
^bump
chur is offline   Reply With Quote
Old 08-16-2007, 05:47 PM   #4
chur
Senior Member
 
Join Date: Mar 2007
Posts: 133
^bump... I know it's a difficult problem, but surely someone knows how to fix this?
chur is offline   Reply With Quote
Old 08-16-2007, 05:53 PM   #5
Gemione
Member
 
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 80
I am having teh same problem

I have a MAIN_mc.swf with a loader component in it called mainLoader

I load other swf's into the load but I want to send them commnad

in HTML_mc.swf there is a function called show HTML

I want to be able to click on a button in MAIN_mc and have ti execute teh function in HTML_mc

kinda like
Code:
Actions.loadHTML = function(docPath){
    loadMovie("HTML_mc.swf",_root.mainLoader);
    _root.mainLoader.showHTML(docPath);
};
should mainLoader inherit teh objects and functions of the swf loaded?
Gemione is offline   Reply With Quote
Old 08-16-2007, 10:15 PM   #6
chur
Senior Member
 
Join Date: Mar 2007
Posts: 133
Gemione i think you'd be better off using a movieclip to load the swf rather than a loader component. It gives you more control over it. Then you could access it like homeMcLoader_mc.showHTML();

Im getting closer to figuring my situation out. I've tried a few things in other swfs that seem to working (with a similar principle). I'll post my solution when i work it out. Seems like nobody else has a clue...
chur is offline   Reply With Quote
Old 08-17-2007, 12:52 AM   #7
Gemione
Member
 
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 80
Maybe im dumb but I couldnt get it to load. I made a workaround though

Teh Paretn movie clip, Wehn I execute a function that I wanted to control the client MC I sent the avriable to a textfile, then the client would load that variable when it loaded. Its messy and definatly inefficient but It works.

Swf->Command->php-txt->swf

oh well.
Gemione is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:08 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.