A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: as+xml+lightwindow

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    293

    as+xml+lightwindow

    hi all - really hope someone can sort me out with this question i have.

    i am trying to get lightwindow to launch from my script in as3

    i have some thumbnails that are generated via xml - and when clicked the thumbnail opens a url in a new window.

    i want it to open in the lightwindow box instead.

    this is the as that i have on my thumbnails
    PHP Code:
    function p_click(me:MouseEvent
    {
    var 
    loader Loader = new Loader (); 
    var 
    request URLRequest = new URLRequest "javascript : myLightWindow.activateWindow({href: 'wall.swf', title: 'lightwindow', author: 'anon', height: 480, width: 640});" ); 
    loader load request ); 
    navigateToURL request '_parent' ); 

    but that doesn't seem to work - i am using this article as my reference for what should go in the script for the button.

    the script i used and it worked to open a url in a new window was

    PHP Code:
    function p_click(me:MouseEvent
    {
        var 
    sp:Sprite me.target as Sprite;
        var 
    s_no:Number parseInt(sp.name.slice(8,10));
        
    navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);

    that opens the url from the xml doc. this how the items in the xml look

    PHP Code:
    <thumbnail filename="name_of_thumb.jpg" url="http://www.domainname.com/folder/item.mov" target="_blank" 
            
    title="Item title" 
            
    description="some text that shows up on thumbnail mouse over" /> 
    i am really struggling with this - i have also dropped the swf into html doc for lightwindow
    and the html links - open the lightwindow up perfectly but the swf doesn't want to know.

    has anyone managed to get this working before? or know of good points of reference to make it work from a flash button/xml.

    there is no support on the stickman site - lots of config info - but not for flash?

    is it even possible in flash? anyone know?

    in summary how do i trigger lightwindow from an as3 button???

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Look into externalinterface class, since you want to open a javascript.

    Check the class here.

    http://help.adobe.com/en_US/AS3LCR/Flash_10.0/

    Here is a simple example in AS2. Just change the button script:

    http://www.flashscript.biz/utilities...8_windows.html

    When you test it html and movie have to be on the server.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    okay, been trying to work this out but i am still running into trouble getting it to work properly.

    this is the script for the click on the thumbnail

    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //array reference to the url, 
    var s_no:Number parseInt(sp.name.slice(8,10));

                var 
    urlstring:String =  
    "javascript:myLightWindow.activateWindow({"
                 
    //include the url of the video in the string //
                 
    urlstring += "href:'"+url_list[s_no]+"', "
                 
    ///tweak those parameters (i guess you can even remove them
                 
    urlstring += "title:'Sometitle', "
                 
    urlstring += "author:'author'"

                
    ///leave the line below
                 
    urlstring += "})"
                
     
    //to check that you did right trace the urlstring:
               
    trace (urlstring)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'author'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    navigateToURL(requrl_target_list[s_no]);
             } 
    it gives me the correct trace message but when i drop it into the html doc - it doesn't want to work!?

    this is the html that it is sitting in:

    PHP 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">

    <
    head>

        <
    title>LightWindowTest</title>

        <!-- 
    Meta Tags -->
        <
    meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <
    meta name="robots" content="index, follow" />
        
        <!-- 
    CSS -->
        <
    link rel="stylesheet" type="text/css" href="css/default.css" />
        <
    link rel="stylesheet" type="text/css" href="css/lightwindow.css" />
        
        <!-- 
    JavaScript-->
        <
    script type="text/javascript" src="javascript/prototype.js"></script>
        <
    script type="text/javascript" src="javascript/effects.js"></script>
        <
    script type="text/javascript" src="javascript/lightwindow.js"></script>


        <
    script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script
        
        
        <
    script type="text/javascript">
            var 
    boo = function(){
                return(
    "boo")
            }
        
        </
    script>
    </
    head>

    <
    body>
    <
    script type="text/javascript">
    AC_FL_RunContent'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','name','flashcoso','width','800','height','600','id','flashcoso','src','FlashExample','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','transparent','movie','FlashExample' ); //end AC code
    </script><noscript>
    <
    object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" name="flashcoso" width="800" height="600" id="flashcoso">
        <
    param name="movie" value="wall.swf" />
        <
    param name="quality" value="high" />
        <
    param name="wmode" value="transparent" />
        <
    embed src="wall.swf" width="800" height="600" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" name="flashcoso"></embed>
    </
    object>
    </
    noscript>

    </
    body>
    </
    html
    is there something glaringly obvious that I am missing? i just can't seem to get it work. is it something in that script and code that i am trying to combine or would it be the way my xml is written? this how i have defined the items - this is what the flash should be reading...

    PHP Code:
    <thumbnail filename="thumb_01.jpg" url="gallery/fische01.mov" target="_blank" 
            
    title="Item No. or title" 
            
    description="description of this thumbnail image and associated file" /> 
    ...been doing my best to work it out - but just not there yet...


    any help me out here?

  4. #4
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    Last edited by WWFC; 01-27-2009 at 03:57 PM.

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You cannot use navigateToURL for Javascript interaction. As I said above you need to use the ExternalInterface class and your movie would not work on your harddrive. You need to test it on your server. The Adobe language reference has a nice example when you check the ExternalInterface class.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    hi cancerinform - many thanks for the reply - appreciate your help and advice

    ...I have tested the files on a server and it didn't work - but as you have pointed out it won't because I am using navigate url.

    I have read the instructions and tried to follow them for the ExternalInterface class - but am getting a little lost with it

    instead of navigatetourl should i be using
    ExternalInterface.addCallback()

    or do I need to rewrite that somehow like this?

    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //array reference to the url
    var s_no:Number parseInt(sp.name.slice(8,10));

                var 
    urlstring:String =  
    "javascript:myLightWindow.activateWindow({"
                 
    //Now, you need to include the url of the video in the string //in this way
                 
    urlstring += "href:'"+url_list[s_no]+"', "
                 
    ///tweak those parameters (i guess you can even remove them
                 
    urlstring += "title:'Sometitle', "
                 
    urlstring += "author:'name'"

                
    ///remember to leave the line below
                 
    urlstring += "})"
                
     
    //to check that you did right trace the urlstring:
               
    trace (urlstring)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'name'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    ExternalInterface.addCallback(requrl_target_list[s_no]);
             } 
    I am not sure what and where I need to add stuff or edit my existing script?
    AS3 is a lot cleaner and stricter (which is good) - but it is something of a steep learning curve.

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...also - I don't know if this
    PHP Code:
    if (ExternalInterface.available
    is applicable to what I am trying to do and if it is here it goes

    ...man oh man - i am struggling!

  8. #8
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...okay - my head is hurting now! lol!

    I have added this:
    PHP Code:
    import flash.external.ExternalInterface
    to the start of the script along with the other imports

    and go to my onclick command that was this...
    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //array reference to the url,
    var s_no:Number parseInt(sp.name.slice(8,10));

                var 
    urlstring:String =  
    "javascript:myLightWindow.activateWindow({"
                 
    //include the url of the video in the string //
                 
    urlstring += "href:'"+url_list[s_no]+"', "
                 
    ///tweak those parameters (i guess you can even remove them
                 
    urlstring += "title:'Sometitle', "
                 
    urlstring += "author:'author'"

                
    ///leave the line below
                 
    urlstring += "})"
                
    //to check that you did right trace the urlstring:
               
    trace (urlstring)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'author'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    navigateToURL(requrl_target_list[s_no]);
             } 
    do I need to change all refs to urlstring to the new call to the externalinterface? like this?
    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //this is your array reference to the url, right?
    var s_no:Number parseInt(sp.name.slice(8,10));


                var 
    ExternalInterface.call:String =  
    "javascript:myLightWindow.activateWindow({"
                 
    //Now, you need to include the url of the video in the string //in this way
                 
    ExternalInterface.call += "href:'"+url_list[s_no]+"', "

                
    ///remember to leave the line below
                 
    ExternalInterface.call += "})"
                
     
    //to check that you did right trace the urlstring:
               
    trace (ExternalInterface.call)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    ExternalInterface.addCallback(requrl_target_list[s_no]); 
    I don't know what I need to do - is it six of one and half a dozen of the other? or have i fallen off altogether? is there more script to add elsewhere?

    ...I'm lost!

  9. #9
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I think the way you call this is wrong
    var ExternalInterface.call:String =
    "javascript:myLightWindow.activateWindow({"

    Instead as the examples show you give the function a name.

    var newWindow:String = String(ExternalInterface.call("openWindow","Stager esize.html"));

    Here the javascript function is called openWindow and the html page name to point to is Stageresize.html.
    - The right of the People to create Flash movies shall not be infringed. -

  10. #10
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ....nnnrgh! I am trying to write that line but i keep getting this error message
    [PHP]1084: Syntax error: expecting rightparen before javascript:myLightWindow.activateWindow({.

  11. #11
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    sorry this bit cut off the above for some reason!

    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //this is your array reference to the url, right?
    var s_no:Number parseInt(sp.name.slice(8,10));

    var 
    newWindow:String String(ExternalInterface.call"javascript:myLightWindow.activateWindow({"
                 
    //Now, you need to include the url of the video in the string //in this way
                 
    ExternalInterface.call += "href:'"+url_list[s_no]+"', "

                
    ///remember to leave the line below
                 
    ExternalInterface.call += "})"
                
    //to check that you did right trace the urlstring:
               
    trace (ExternalInterface.call)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    ExternalInterface.addCallback(requrl_target_list[s_no]);
             } 
    what is it that i am doing wrong???
    Last edited by WWFC; 01-30-2009 at 05:14 AM.

  12. #12
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You cannot call javascript:..... You need to have a javascript function in the HTML page. Then as I mentioned above you call the Javascript function like this:
    var newWindow:String = String(ExternalInterface.call("openWindow","page.h tml"));

    Start simple with your Javascript function to get it working and then add up.
    - The right of the People to create Flash movies shall not be infringed. -

  13. #13
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...hi cancerinform - i do have the javascript in the html page
    this is the entire html
    PHP 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">

    <
    head>

        <
    title>LightWindowTest</title>

        <!-- 
    Meta Tags -->
        <
    meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <
    meta name="robots" content="index, follow" />
        
        <!-- 
    CSS -->
        <
    link rel="stylesheet" type="text/css" href="css/default.css" />
        <
    link rel="stylesheet" type="text/css" href="css/lightwindow.css" />
        
        <!-- 
    JavaScript-->
        <
    script type="text/javascript" src="javascript/prototype.js"></script>
        <
    script type="text/javascript" src="javascript/effects.js"></script>
        <
    script type="text/javascript" src="javascript/lightwindow.js"></script>


        <
    script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script
        
        
        <
    script type="text/javascript">
            var 
    boo = function(){
                return(
    "boo")
            }
        
        </
    script>
    </
    head>

    <
    body>
    <
    script type="text/javascript">
    AC_FL_RunContent'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','name','flashcoso','width','550','height','200','id','flashcoso','src','FlashExample','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','transparent','movie','FlashExample' ); //end AC code
    </script><noscript>
    <
    object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" name="flashcoso" width="550" height="200" id="flashcoso">
        <
    param name="movie" value="FlashExample.swf" />
        <
    param name="quality" value="high" />
        <
    param name="wmode" value="transparent" />
        <
    embed src="FlashExample.swf" width="550" height="200" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" name="flashcoso"></embed>
    </
    object>
    </
    noscript>

    </
    body>
    </
    html
    in my script how do i set up the call to the javascript

    would it be as simple as removing the javascript from the line - have i made more than one error in trying to set it up???

    hope you can answer this for me - i feel like i am chasing my own tail on this!

  14. #14
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    this is a simplified version of the files - the .mov is missing from the gallery because of it's size but this is the movie that it calls...
    anyone see what i am missing!?
    Attached Files Attached Files

  15. #15
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I don't think you can call an external script located in a folder. I think you need to have it as a script in your html.

    However, I have to admit that my knowledge is limited and I am not necessarily an expert in that field.
    - The right of the People to create Flash movies shall not be infringed. -

  16. #16
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    bizarre thing is that the class below - works!!!

    but when i try to make it work with xml and then drop it into my .fla - it just does nothing!

    is there a way of changing that to work from my onclick function?

    PHP Code:
    package{
        
        
    import flash.display.*;
        
    import flash.events.*;
        
    import flash.net.*
        
    import flash.text.*;
        
        public class 
    FlashExample extends MovieClip{
        
            public var 
    videourl:String ="gallery/fische01.mov"
            
            
    public function FlashExample(){
                
    dbg.text"helloworld!"
                
    clickme.buttonMode true
                clickme
    .mouseChildrenfalse
                clickme
    .addEventListener(MouseEvent.CLICKmouseClick)
            }
            
            public function 
    mouseClick(e:Event){
                
    openVideo(videourl)
            }
        
            public function 
    openVideo(s:String){
            
                var 
    urlstring:String "javascript:myLightWindow.activateWindow({"
                
    urlstring += "href:'"+s+"', "
                
    urlstring += "title:'Sometitle', "
                
    urlstring += "author:'name'"
                
    urlstring += "})"
                            
                
    dbg.text urlstring
                
    var req:URLRequest = new URLRequest(urlstring)
                
    navigateToURL(req"_self")
            }
        }

    is it possible to have that as the onclick in the script in my fla?

  17. #17
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    navigateToURL just opens a browser window with its content. It does not load anything into your movie.
    - The right of the People to create Flash movies shall not be infringed. -

  18. #18
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...but this what is very odd! - in an fla with just a static button in and importing that class - when the swf button is clicked it 'does' load the lightwindow box with that video into the html doc - in the right way (ie as an overlay!)

    but it just doesn't like anything else. Any ideas why that is? i'm at a total loss!

    ps: apologies for my being so slow on the uptake here - so much has changed from as2!

  19. #19
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    if you look here that works a treat! (nearly - bit wonky) but that is what i want to happen on my onclick command but it just won't!

  20. #20
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...so now i get this error both locally (desktop) and online
    PHP Code:
    SecurityErrorError #2147: Forbidden protocol in URL ExternalInterface.call:myLightWindow.activateWindow({href:'gallery/fische01.movtitle:'Sometitle', author:'name'}).
        
    at global/flash.net::navigateToURL()
        
    at wall_fla::MainTimeline/p_click() 
    it tells me the same thing both if the publish settings are at local or/and network?

    this is how my script now looks
    PHP Code:
    function p_click(me:MouseEvent)
    {
        var 
    sp:Sprite me.target as Sprite;
        
    //this is your array reference to the url, right?
    var s_no:Number parseInt(sp.name.slice(8,10));

                var 
    urlstring:String =  "ExternalInterface.call:myLightWindow.activateWindow({"
                 
    //Now, you need to include the url of the video in the string //in this way
                 
    urlstring += "href:'"+url_list[s_no]+"', "
                 
    ///tweak those parameters (i guess you can even remove them
                 
    urlstring += "title:'Sometitle', "
                 
    urlstring += "author:'Fariska'"

                
    ///remember to leave the line below
                 
    urlstring += "})"
                
     
    //to check that you did right trace the urlstring:
               
    trace (urlstring)
    ////the output should be something like
    // "javascript:myLightWindow.activateWindow({ href:'YOUR URL', title:'Sometitle', author:'Fariska'})"
            
                 
    var req:URLRequest = new URLRequest(urlstring)
            
    /////and then finally go to the url:
            
    navigateToURL(requrl_target_list[s_no]);
             } 

    i feel like i've been trying to work this out for months now!!!1

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