A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: lightwindow and javascript from flash?

  1. #1

    lightwindow and javascript from flash?

    i am trying out the "lightwindow" script for my website. here is what i am doing.

    i have lightwindow called from flash to open an external html which holds another swf with the JW flv player.

    the only problem is i have no clue how to call light window from flash. i am not good at coding javascript from scratch and don't know where to begin.

    can someone get some framework for me to go by?

    i need to have several buttons on a flash page that all call a different file for the lightwindow.

    thanks,
    mike

  2. #2
    Junior Member
    Join Date
    Dec 2004
    Posts
    16
    Quote Originally Posted by fire_for_SiN
    i am trying out the "lightwindow" script for my website. here is what i am doing.

    i have lightwindow called from flash to open an external html which holds another swf with the JW flv player.

    the only problem is i have no clue how to call light window from flash. i am not good at coding javascript from scratch and don't know where to begin.

    can someone get some framework for me to go by?

    i need to have several buttons on a flash page that all call a different file for the lightwindow.

    thanks,
    mike
    I've managed to get it to work using this code in my button actionscript...

    Code:
    button.buttonMode = true;
    button.addEventListener(MouseEvent.CLICK, loadLightBox);
    
    function loadLightBox(event:MouseEvent) :void {
    
    	navigateToURL(new URLRequest("javascript: myLightWindow.activateWindow({href: 'box-brazil.html', class: 'lightwindow', title: 'TITLE', author: 'AUTHOR', caption: 'CAPTION'})"), "_self");

    this has been working exactly like if I called the lightbox from a html link liek this...
    Code:
    <a href="box-brazil.html" class="lightwindow" rel="[worldwide]" params="width=600" caption="Brazil -">Brazil<a/>
    This is working on my Mac browsers, but for some reason on Windows browsers it isn't displaying the lightwindow correctly. When I look at the code, it looks like it is loading everything into an iFrame for some reason. If anyone knows why it might be doing this, let me know.

  3. #3
    Junior Member
    Join Date
    Jan 2002
    Location
    D.C.
    Posts
    4
    thanks, MikeTheVike, I've been trying to do the same thing. The example code that you used is that for AS3? Asking because I can't seem to get it to work in AS2, which is what I'm working in on my particular file.

    thanks
    Urban Avenue - Avenida Urbana
    http://www.urbanavenue.com

  4. #4
    Junior Member
    Join Date
    Dec 2004
    Posts
    16
    Quote Originally Posted by mcj9678
    thanks, MikeTheVike, I've been trying to do the same thing. The example code that you used is that for AS3? Asking because I can't seem to get it to work in AS2, which is what I'm working in on my particular file.

    thanks

    yea, it's AS3, sorry, I don't know much AS2. I actually finally got this working in IE, had to edit some of the javascript files that came with the lightwindow. Since it kept loading an iframe for some reason, I searched for "iframe" in the javascript code, and changed some things so it wouldn't load one, and it worked.

    I'm not positive, but I think the code for AS2 is basically the same, but you should use getURL instead of navigateToURL.

  5. #5
    Junior Member
    Join Date
    Jan 2002
    Location
    D.C.
    Posts
    4
    thanks for the reply Mike. I figured it out using AS2. I used the following on my button that seems to work:


    on (release) {
    getURL ("javascript: myLightWindow.activateWindow({href: 'www.urbanavenue.com',title: '',params: 'lightwindow_type=external,lightwindow_width=810,l ightwindow_height=525' });")}

    However I will say that if you through class: 'whatever' in there it seems to not work.
    Urban Avenue - Avenida Urbana
    http://www.urbanavenue.com

  6. #6
    Junior Member
    Join Date
    Dec 2004
    Posts
    16
    Quote Originally Posted by mcj9678
    thanks for the reply Mike. I figured it out using AS2. I used the following on my button that seems to work:


    on (release) {
    getURL ("javascript: myLightWindow.activateWindow({href: 'www.urbanavenue.com',title: '',params: 'lightwindow_type=external,lightwindow_width=810,l ightwindow_height=525' });")}

    However I will say that if you through class: 'whatever' in there it seems to not work.

    yea, I had that in there when testing stuff, it doesn't do anything.

  7. #7
    Junior Member
    Join Date
    Sep 2008
    Posts
    1
    I am hoping some here can help as I cannot get anyone on stickman.com or expertsexchange.com to help us resolve these issues...

    Here is the page: http://whitelightconcepts.com/web-de...ent-design.php
    Click on any thumbnail image.

    Everything is coming out of the database OK and the LightWindow is generally working, but there are several display issues:

    - When loading in IE 7 or 6 and Firefox on PC, the Flash navigation on the main page (see link above) stays on top of the LightWindow.

    - On first load of a sample, the window sizes too small...on subsequent loads, it sizes correctly to try to contain as much of the page as possible.

    - There is too much space to the right of the LightWindow...it is speced at 10px, but there is clearly more there...maybe it's trying to make room for a scroll bar that is not appearing??? There also seems to be more space at the bottom as well. I don't think I missed anything in our CSS & HTML, but I have been looking at this so long that I am going bug-eyed.

    A couple of notes...we already tried changing the z-index and the wmode is already set to transparent in the lightwindow.js file.

    Any help is appreciated. Thank you so much!

  8. #8
    Junior Member
    Join Date
    Oct 2008
    Posts
    1

    add some class

    Quote Originally Posted by mcj9678
    However I will say that if you through class: 'whatever' in there it seems to not work.
    Heyo, add the class in the same fashion as other params...

    Thanx for your help, by the way...

  9. #9
    Junior Member
    Join Date
    Nov 2008
    Posts
    2

    This is driving me nutzzzzz

    This has driven me mad ...

    It works in FF fine .... I.E. of course sucks ...

    I have over 20 ++ hours invested in trying to make this solution work ...and researching ...and trying everything. No luck.

    If someone has an answer .... I WILL GLADLY RETURN THE FAVOR ....withing reason.

    I can't spend anymore time on this.............

    Below is my AS2 code that is on my MC ....and yes I have notice differences between MC and buttons. But I have changed so many thing while trying this that I don't even remember where I am. I know these are on mc's

    I swear when I was testing at some point ....that this worked in I.E. 7

    I am on XP ...and FF



    Code:
    on (press)
    {  
    	_root.GlobalSound.setVolume(0);  
    }
    on (release)
    {
    	getURL("javascript: myLightWindow.activateWindow({href: 'videoplayer_deco/videoPlayer.swf?xml_file=settings.xml',params: 'class=lightwindow,lightwindow_type=external,lightwindow_iframe_embed=true,lightwindow_width=480,lightwindow_height=400'});")
    	}
    If you have an answer ...I will be soooooooooooo gracious.

    BTW - view source of htm, I am not using any swfobject or I.E. if statements .... I usually do use the I.E. if statement ...but when I was having so many problems I changed everything.

    Perhaps by the time you view this I may change the htm back.

    ANY HELP GREATLY APPRECIATE!!

  10. #10
    Junior Member
    Join Date
    Nov 2008
    Posts
    2

    Omggggggggg Sucess!!

    I found the answer .... or at least this works ....

    Please to all using the code I have on MC ....it works fine ...

    Here was the problem----------------> to anyone who never pays much attention to doc type in your html file.

    I changed the transitional to exactly this:

    Code:
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
    <html xmlns=”http://www.w3.org/1999/xhtml”>
    Tried in I.E. 7 and BINGO BANGO !!!

    NOW THE NEXT SEPARATE "SMALL" ISSUE ...

    I am setting global sound to (0) ..when that same button is clicked. I want to resume sound when I close the the lightwindow. Is this possible ? from the lightwindow exit? or is there something I can set on the flash actionscipt to detect that lightwindow has closed???

    As it stands right now - the main fla music is set to (0) on each of the video launches, however if a new song starts all website sounds will resume.

    The mp3 player is a separate mc, I am not referencing this at all right now properly. Thats why I uses the global sound action in the first frame of the timeline to be able stop global sounds ...

    I know there is a better way to do this talking directly to the mp3 player mc. Can anyone help ?? Here is part of that code that would be the most important:

    Code:
    ///creates a new sound object called s
    var s:Sound = new Sound();
    s.onSoundComplete = playTracks;
    s.setVolume(75);
    
    var sa:Array = new Array();
    var cps:Number = -1;
    var pos:Number;
    
    ////load the xml data for the mp3 tracks 
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    {
    	var nodes:Array = this.firstChild.childNodes;
    	for(var i=0;i<nodes.length;i++)
    	{
    		sa.push(new list(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.track));
    	}
    	playTracks();
    }
    
    /////your xml file is called here, if you change the name of your xml file also change it here
    xml.load("tracks.xml");
    
    ///function for playing your tracks, note that the volume is currently set to 75, 100 =max, 0=mute
    
    function playTracks():Void
    {
    	s = new Sound();
    	s.onSoundComplete = playTracks;
    	s.setVolume(75);
    	mute.gotoAndStop("on");
    	if(cps == sa.length - 1)
    	{
    		cps = 0;
    		s.loadSound(sa[cps].earl, true);
    	}
    	else
    	{
    		s.loadSound(sa[++cps].earl, true);
    	}
    	
    	info.info2.trackInfo.text = sa[cps].track + " " ;
    	info.info2.trackInfo2.text = sa[cps].artist + " " ;
    	onOff.gotoAndStop("pause");
    	textPos = 0;
    }
    
    ///function for playing the previous track
    function playPrevious():Void
    {
       s = new Sound();
       s.onSoundComplete = playTracks;
       s.setVolume(75);
       mute.gotoAndStop("on");
       if(cps == 0)
       {
          cps = sa.length-1;
          s.loadSound(sa[cps].earl, true);
       }
       else
       {
          s.loadSound(sa[--cps].earl, true);
       }
       	info.info2.trackInfo.text = sa[cps].track + " " ;
    	info.info2.trackInfo2.text = sa[cps].artist + " " ;
       onOff.gotoAndStop("pause");
    }
    
    ///function  pauses the music
    function musicOff():Void
    {
    	pos = s.position;
    	s.stop();
    }
    
    ///function for continuing play
    function musicOn():Void
    {
    	s.start(pos/1000);
    }

    Thanks!

  11. #11
    Junior Member
    Join Date
    Feb 2009
    Posts
    1
    Web Designer I'm working on trying to get lightwindow to open over my flash site from a button in the flash. Do you have an example that I could view? I'm new to the lightwindow and don't want to invest to much time in this if something else will be easier/quicker and do the same job.

  12. #12
    Junior Member
    Join Date
    Jan 2010
    Posts
    1
    Quote Originally Posted by MikeTheVike View Post
    yea, it's AS3, sorry, I don't know much AS2. I actually finally got this working in IE, had to edit some of the javascript files that came with the lightwindow. Since it kept loading an iframe for some reason, I searched for "iframe" in the javascript code, and changed some things so it wouldn't load one, and it worked.

    I'm not positive, but I think the code for AS2 is basically the same, but you should use getURL instead of navigateToURL.
    I know this is an old thread so this might be a futile attempt, but here goes

    I was able to get lightwindow to launch from flash due to your suggestions (thank you), but it's not working in IE. Could you tell me what you did to get it to work?

    FYI: I'm getting an error in line one of my index page where the XHTML markup is declared, so I changed it to 'STRICT', but it still didn't work.

    Thanks,
    -CG

    PS: Plus I have no idea what you did in the lightwindow.js. If it's not to much of a memory bender I'd like to know what that was. I'm hoping is helps solve an issue with lightwindow not drawing its overlay properly (in all browsers). It looks fine until the window is expanded; the overlay just ends and IE doesn't like to play nice if the browser window is smaller than the image (stretchy, clippy badness). Thanks again.

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