dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Calling screen res from actionscript

  1. #1
    Member
    Join Date
    Mar 2001
    Posts
    77

    resolved


    I am having trouble finding a solution to this problem..
    I have a flash movie which is 1024 wide, it is the top panel for a website. I want to display the date within this swf so it is aligned at the top right, it works fine for those that are running 1024x768, but any less and they can't see it.

    Is there any way of finding out the viewers resolution from within flash and moving the 'date movieclip' dependent on the res.

    thanks

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Posts
    179
    with flash i'm pretty sure the answer is no.. however
    you can find out the res using javascript, and load different movies accordingly unfortunatly i can't remeber the actual javascript off the top of my head but just go search for it in a javascript place and i'm sure you'll find it.
    happy hunting
    -Rui

  3. #3
    Member
    Join Date
    Oct 2001
    Posts
    44
    Prepare yourself:

    Here is the code of HTML & JavaScript:
    Code:
    <HTML>
    <HEAD>
    <TITLE>Test</TITLE>
    <script language="JavaScript">
    <!--
    function getRes(){
    // place this name "get_resolution" into the OBJECT tag in ID="get_resolution", and NAME="get_resolution" (see below)
    var FlashMovie=window.document.get_resolution; 
    var str_res=0;
    if ((screen.width == 640) && (screen.height == 480)) {
      str_res=640;
    } else if ((screen.width == 800) && (screen.height == 600)){
     str_res=800;
    	} else if ((screen.width == 1024) && (screen.height == 768)){
     str_res=1024;
    	} 
    	 FlashMovie.SetVariable("strRes",str_res); //  strRes - variable in Flash
    	 }
    //-->
    </script>
    </HEAD>
    <BODY bgcolor="#FFFFFF">
    <!-- URL's used in the movie-->
    <!-- text used in the movie-->
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
     WIDTH=550 HEIGHT=400 name="get_resolution" id="get_resolution">    <!-- IMPORTANT NAME & ID -->
     <PARAM NAME=movie VALUE="test.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="test.swf" quality=high bgcolor=#FFFFFF  WIDTH=550 HEIGHT=400 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
    </OBJECT>
    </BODY>
    </HTML>
    Then in for example 1 frame of your movie insert this
    script:

    Code:
     getURL ("JavaScript: getRes()");
    
    //and use variable strRes in Flash to get screen resolution:
    
    if (parseInt(strRes)==800){
     //some actions...
     }
    If you have any question just feel free to write...
    ZeroIQ

  4. #4
    Member
    Join Date
    Mar 2001
    Posts
    77
    Hey zeroIQ,
    thanks, what I was looking for although I haven't tried it yet It looks good enough from here..

    // place this name "get_resolution" into the OBJECT tag in ID="get_resolution", and NAME="get_resolution" (see below)
    Can you please explain the above to me in regard to this code:
    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="1024" height="100" align="top">
    <param name=movie value="roof3d.swf">
    <param name=quality value=high>
    <embed src="roof3d.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="1024" height="100" align="top">
    </embed>
    </object>


    haha.. see the smiley face appear?
    [Edited by itchyfella on 10-15-2001 at 10:07 AM]

  5. #5
    Member
    Join Date
    Oct 2001
    Posts
    44
    You only have to change this line:
    Code:
    <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/
    flash/swflash.cab#version=5,0,0,0" width="1024" 
    height="100" align="top" name="get_resolution" 
    id="get_resolution" >  <!-- see here !!!!! -->
    
    // I removed the rest to make it clear...
    
    </object>
    This NAME and ID in above tag is used to identify movie in java script:
    Code:
    var FlashMovie=window.document.get_resolution; // must be the same as NAME and ID
    I hope this will help you...

    ZeroIQ

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