Targeting an iFrame from Flash

  • chimiwaza
  • Novice
  • Novice
  • chimiwaza
  • Posts: 19

Post 3+ Months Ago

hey guys, was wondering if i can link a flash button to a <iframe> ? thanx in advance :oops:
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Sure, In your HTML give your Iframe a name like,
Code: [ Select ]
<iframe src="defaultPage.html" name="frameName"></iframe>


Then just target that frame with your button in flash with getURL() like so,
Code: [ Select ]
button.onPress = function(){
   getURL("pageToLoad.html", "frameName");
}
  1. button.onPress = function(){
  2.    getURL("pageToLoad.html", "frameName");
  3. }


Of course replace pageToLoad.html with your page & frameName with the name of your Iframe. :)
  • chimiwaza
  • Novice
  • Novice
  • chimiwaza
  • Posts: 19

Post 3+ Months Ago

heheheheh thanx BRO! heee im advance in html so i knew the iframe stuff thanx for that anyways :roll: .... Thanx in advance for the flash part :lol:
  • senoj2k
  • Born
  • Born
  • senoj2k
  • Posts: 2

Post 3+ Months Ago

wow thanks this is just what im after, i need an frame to load when the movie loads, does any one know how to change this code from a button press to load the iframe when the flash loads?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

in the first frame of your flash, put this code:
Code: [ Select ]
onEnterFrame = function()
{
 if (getBytesLoaded() >= getBytesTotal())
 {
   delete onEnterFrame;
   getURL("pageToLoad.html", "frameName");
   gotoAndPlay(2);
 }
}
stop();
  1. onEnterFrame = function()
  2. {
  3.  if (getBytesLoaded() >= getBytesTotal())
  4.  {
  5.    delete onEnterFrame;
  6.    getURL("pageToLoad.html", "frameName");
  7.    gotoAndPlay(2);
  8.  }
  9. }
  10. stop();
  • senoj2k
  • Born
  • Born
  • senoj2k
  • Posts: 2

Post 3+ Months Ago

:D thanks very much IceCold!
  • URanimEnigma
  • Born
  • Born
  • URanimEnigma
  • Posts: 3

Post 3+ Months Ago

I came across this forum by using google. I thought I should join seeing that it could help my website development issues. I noticed that this particular topic was created in the year 2004. But, this is two years later. I'm trying to say that, I have a similar problem but, with flash pro 8. I'm a bit new to it. Well, the code that is posted here to target an iframe using flash doesn't work with flash 8. I was wondering if someone could help me. The following code was given to me by a moderator but, it doesn't work either. I thought I'd give it for reference.

Code: [ Select ]
on (press) {
loadInFrame("page.html")
}
function LoadInFrame (html) {
getURL(html, "main")
}
  1. on (press) {
  2. loadInFrame("page.html")
  3. }
  4. function LoadInFrame (html) {
  5. getURL(html, "main")
  6. }
  • h.kleinveld
  • Born
  • Born
  • h.kleinveld
  • Posts: 1

Post 3+ Months Ago

Something I see everywhere on the web now: Flash 8 doesn't load into iFrames properly. It tends to open the file in a new window. Here is what you do:


Step 1
create a Flash file with publish settings for flash player 6, actionscript 1. Put this in the first frame:

Code: [ Select ]
_level0.loadIFrame = function(urlTarget, iframeTarget){
    getURL(urlTarget, iframeTarget);
};    
  1. _level0.loadIFrame = function(urlTarget, iframeTarget){
  2.     getURL(urlTarget, iframeTarget);
  3. };    


Step 2
load this movie into your original flash file:
Code: [ Select ]
loadMovieNum("iframeLoader.swf", 1);


Step 3
you can now use this function from anywhere in your file, for example:
Code: [ Select ]
_level0.loadIFrame("pageToLoad.html", "targetIFrame");


greets

Hein Kleinveld
newspectives.com
  • chrisrff
  • Born
  • Born
  • chrisrff
  • Posts: 1

Post 3+ Months Ago

Could I make a box with Iframe(a webpage/site) in it?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

yes, from html
  • seza
  • Born
  • Born
  • seza
  • Posts: 1

Post 3+ Months Ago

Didn't work!
It still opens in a new browser window
And I can't seem to find another solution on the web
Geez, haven't anyone noticed that version thing yet? There aren't any other threads that mention it. No other possible solutions...
  • webpepier
  • Born
  • Born
  • webpepier
  • Posts: 1

Post 3+ Months Ago

I have a problem a little bit more complicated...I have a menu made with flash embedded in an html page where I have inserted also an iframe made up by a frameset with 3 frames. I want to know how it's possible to have that when the button in flash is pressed the page is loaded in the correct target frames into the iframe....

on (release) {
getURL("page.html", "mainFrame*");
}

*mainFrame is the name of a frame into the iframe


This is the javascript I have written in flash. It works only with Firefox but it doesn't with Internet Explorer! I don't know why....
  • samedakira
  • Born
  • Born
  • samedakira
  • Posts: 1
  • Loc: Hungary

Post 3+ Months Ago

Hi

I am using flash 8, but have no problems to load into an iframe
Iam using the simple geturl action:
getURL("http://www.somesite.com", "traffic");
  • severinsmith
  • Born
  • Born
  • severinsmith
  • Posts: 2
  • Loc: Boston

Post 3+ Months Ago

Hi,
thanks so much to h.kleinveld. This problem has been a real thorn in my side, and your solution seems to have solved it. I do have one question; when I publish the iframeloader.swf, I get syntax error warnings. I am a novice at Flash, and wonder if this is an actionscript version issue, and whether or not it will cause any problems at runtime. The application seems to be runnning fine. I am using MX 2004 on a Mac, but have also seen the error on Flash 8 Pro. The error message follows.

Thanks again for this solution, and any input you might have on this message.

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: Operator '=' must be followed by an operand
   getURL(urlTarget, iframeTarget);

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Unexpected '}' encountered
};

Total ActionScript Errors: 2 Reported Errors: 2
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

severinsmith Your error has nothing to do with the version of Flash. This warning means you have malformed code and Flash doesn't know how to parse it.

If you post your code we can probably figure out the problem.
  • severinsmith
  • Born
  • Born
  • severinsmith
  • Posts: 2
  • Loc: Boston

Post 3+ Months Ago

Hi Graphixboy,
thanks for the input.

It looks like it was actually just an invisible character that remained in the code. (see h.kleinveld's post earlier in this conversation for code). I just keyed it in instead of cut/paste, and the syntax errors went away.

I am still having problems getting it too work, but at least the syntax errors are gone.

Thanks again.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Yeah Flash is touchy about how you write your code (as any good programming language should be). Glad that took care of everything.
  • mackmann
  • Born
  • Born
  • mackmann
  • Posts: 1

Post 3+ Months Ago

Please tell me what am I doing wrong


on (release)
{
getURL("blueprint_if.html#4","bp");
}

Thanks
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

don't know, what is bp? id of a iframe?
  • greasymok
  • Born
  • Born
  • greasymok
  • Posts: 1

Post 3+ Months Ago

OK, I have been trying to target iframes from flash on two different computers, and on only one of them does it work like it is supposed to. I have found however, that by using javascript, the flash getURL function can load a url into an iframe.

In the flash file, put:
Code: [ Select ]
getURL("javascript:loadPage('" + link + "','" + iframe + "')")

where link is the page you want to load and iframe is the name of the iframe

Make sure the iframe has a name defined in the html file:
Code: [ Select ]
<iframe name="mainBody" src="http://www.google.com" height=400 width=500></iframe>


Add the following code inside the html file's <head> tag:
Code: [ Select ]
<script language="javascript" type="text/javascript">
<!--
function loadPage(link, frameName) {
  frames[frameName].location.href = link;
}
// -->
</script>
  1. <script language="javascript" type="text/javascript">
  2. <!--
  3. function loadPage(link, frameName) {
  4.   frames[frameName].location.href = link;
  5. }
  6. // -->
  7. </script>

This should fix the problem, I've gotten it to work on both my machines.
  • ChadReitsma
  • Born
  • Born
  • ChadReitsma
  • Posts: 1
  • Loc: Calgary Alberta Canada

Post 3+ Months Ago

+++ FIXED +++

I got it to work by simply replacing the double-quotes around the iframe name with single quotes! - Tested in FireFox and IE

doesnt work: getURL("mypage.html","myWindow");
WORKS! getURL("mypage.html",'myWindow');

Enjoy :)
  • hercilio
  • Born
  • Born
  • hercilio
  • Posts: 1

Post 3+ Months Ago

Hi,

I tried all the ways that you talk here, and no one works. So i visited the macromedia website and update my Flash Professional 8 and it start working with the normal code:

on (release)

{

getURL("link","iframe");

}
  • niekdekker
  • Born
  • Born
  • niekdekker
  • Posts: 1

Post 3+ Months Ago

I've spent a few hours finding the solution for this problem.

After a while I found out that if I published my buttons as flashplayer 7 instead of 8, the code worked. And this would mean that macromedia just didn't program flash 8 right, that with the initial install of macromedia flash 8 this code doesn't work.

So I went to macromedia.com and I updated a lot of stuff for flash 8, and now it works! I can't tell you which install fixed this problem, I installed about 5 updates. I suggest you try them all:

http://www.adobe.com/support/flash/down ... tml#flash8
  • wpanther
  • Born
  • Born
  • wpanther
  • Posts: 1

Post 3+ Months Ago

Hi to everyone!
The fallowing simple code works correctly:

on (press) {
getURL("YOUR_URL_ADD", " YOUR_IFRAME_NAME ");
}

The problem isn't from the code if the code doesn't work correctly (opening the url on a new window instead of the iframe)
Actually, the code works correctly, but you can see it just when you upload the files on your host.
When you test the flash file locally (on your pc) the browser can't open the url on the iframe and opens it on a new windows!
Don't worry, when you upload those, browser opens the url on the iframe. You can test it now! :)
  • am9e
  • Born
  • Born
  • am9e
  • Posts: 1

Post 3+ Months Ago

Hello Everyone

I have tried everything as you guys said in here to open a link from flash in an iframe in the main page, my iframe name CONTAINER and the url is TEST.ASP, iam using Flash CS3 Pro, anyone can help me out with a working trick to get this page to be opend in the CONTAINER?

Thanks in advance!
  • Firemaster
  • Novice
  • Novice
  • Firemaster
  • Posts: 22

Post 3+ Months Ago

Hey everyone!

I know this is an old thread and I came across it this weekend. I have been looking for something like this for awhile for feature for one of the websites I run. I was wondering if put the flash in the same html document as the iframe does the flash know the frame is there? I don't all that much experience with flash so bear with me. Also by loading the iframe with flash is this only for if you are bring a iframe into the flash document? I am trying to do this for a fire department website where we are going to have the rigs (fire trucks) in the flash document and you will be able to click on the compartment to see what is in that compartment once it is clicked it will load an html file in an iframe. Every side of the truck will not be shown at once but there will be buttons to go to different scenes of the flash movie. I just want to get some advice and to see if I am on the right track.

Thanks,

Chris
  • mandee
  • Born
  • Born
  • mandee
  • Posts: 1

Post 3+ Months Ago

Hi. I kinda have the same problem with loading html files using flash buttons. I have tried both the ajax method from another forum and this iFrameLoader. Neither of them have worked. Any other ideas please?

Basically, I have a main page "frames.html" which containes my iFrame and loads my "index.html" (flash aniamted file) into the iframe. That works fine.

Now on my "index.html" file, I have flash animated buttons. I would like to have other html pages load into my iframe when I click on the flash animated buttons. Any bright ideas????
  • Firemaster
  • Novice
  • Novice
  • Firemaster
  • Posts: 22

Post 3+ Months Ago

Yea this would be great if one of flash experts out there can help us out. I also found a javascript I want to use for my iframe that will ajust the height of the iframe to the height of the html file so that there is no scroll. The thing I am wondering about is this they suggest doing this for the link markup:

Code: [ Select ]
<a href="javascript&#058;loadintoIframe('myframe', 'external.htm')">Link</a>


Does anyone also have any ideas for this besides my last post above?


Thanks,

Chris
  • bozboz
  • Novice
  • Novice
  • bozboz
  • Posts: 31
  • Loc: Brighton

Post 3+ Months Ago

Ive just been nededing to do this and simple getUrl worked fine in AS3
  • caiva
  • Born
  • Born
  • caiva
  • Posts: 3

Post 3+ Months Ago

I have a problem wiht Flash 8!!
I write:

myclip.onPress = function(){
getURL("pageToLoad.htm","iframe");
}

but it doesn't load into iFrames properly. It tends to open the file in a new window.

i did what h.kleinveld said, but dosen't work!!

i need help!!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 33 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.