Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1

    Default Opening a new browser at certain size...

    Hey guys...

    while I'm fairly new to flash, I am picking it up rather quickly... but code is my "Everest".

    I'm trying to open a browser that will be sized appropriately for a youtube.com video. I know how to point the browser to an embedded form of the video, so it won't include all the youtube gobledygook.

    I found another posting from someone who said that this code was the way to do it: (my message continues below)

    _____________________
    function launchNewWin(url, wdth, hdth, windowNewName) {
    if (windowNewName == undefined) {
    var windowNewName = "newWin";
    }
    //End if
    getURL("javascript:window.open(\""+url+"\",\""+win dowNewName+"\",\"width="+wdth+",height="+hdth+",to p=\"+((screen.availHeight/2)-("+hdth/2+"))+\",left=\"+((screen.availWidth/2)-("+wdth/2+"))); void(0);");
    }
    //Usage.... functionName(file,width,height,windowName)
    _root.launchNewWin("http://somesite.com/somefile.jpg", 700, 380, "myNewWindow");
    __________________

    But I'm so new that I don't know which part needs to be replaced with new text. I grasp that the poster meant that + signs mean "add something here", but I don't know when the ADDing ends. If someone could just help me re-write that code to open a browser about as big as a default youtube player shot... if that makes sense. It can be a little large or small, then I can play around with it to get it right.

    Thanks. I love this site! Amazing!

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    That function looks very familiar . The only thing you need to change is the parameters when you call the function...

    _root.launchNewWin("http://somesite.com/somefile.jpg", 700, 380, "myNewWindow");

    Change the bold content. If you want to call it from a button....

    myButton.onRelease=function(){
    root.launchNewWin("http://somesite.com/somefile.jpg", 700, 380, "myNewWindow");
    }


    The javascript code is designed to center the window on the users screen no matter what size of window is defined. The rest of the code should reside on the first frame of the main timeline.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  4. #3

    Default

    Well, that didn't work. Maybe this'll help you help me (a la Jerry McGuire): I currently use this actionscript which works perfectly, except that the browser opens at full size:
    ___________________________
    on (release) {
    getURL("http://www.blahblah.com");
    }
    _____________

    That's it, from beginning to end. Does that give you a better idea of what I should change it to?

    Thanks for taking the time... seriously.

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    The standard getURL method will always open the new window at full size. It's the javascript function that allows you to customize a pop up window. The javascript function should reside on the main timeline and called like I posted previously. I know it works. I use it to launch customized pop up windows from the demo section of my website. The function needs to be tested in a browser window to work correctly. If tested from flash, it should open a blank browser window to process the javascript code before opening the customized content window.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  6. #5

    Default

    Yikes. I guess I'm in over my head here. I'm just barely getting familiarized with actionscript... now when you say javascript resides on the timeline, are you saying that the script your telling me to use wouldn't be placed in the box I'm typing the actionscript? It may sound like a stupid question, but...

  7. #6
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    No question is stupid if you dont know the answer.

    There are two kinds of codeing options with Flash. Object code and frame code. Object code is exactly what the name implies. Code is placed directly onto the object on stage. Frame code is used on the first keyframe of the main timeline and applies its actions to objects by instance name. One of the advantages of Flash is the ability to achieve goals in multiple ways. Consider the code for a button to send the main timeline to a keyframe labled "myFrame".

    Object code...(placed directly onto the button)

    on(release){
    _root.gotoAndStop("myFrame");
    }

    Frame code(with the button given an instance name of "myButton")

    myButton.onRelease=function(){
    _root.gotoAndStop("myFrame");
    }

    Neither method is more correct than the other. Both methods will work. However, the advantages of frame code become much more apparent when editing. It is much easier to edit code located in a central location as opposed to having to select multiple objects to see what code they contain.

    now when you say javascript resides on the timeline, are you saying that the script your telling me to use wouldn't be placed in the box I'm typing the actionscript?
    Yes, it would. However, the first keyframe of the main timeline should be selected. Also, keep in mind that Flash uses Actionscript and only has limited commands for javascript. What happens is the function sends the javascript code to a browser window that interprets the javascript. The javascript is not parsed by the flash player. Try the code in a new test movie. Once you understand how it works, you can add it to your current project.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  8. #7

    Default

    I appreciate your help (and patience)... but let me just figure this out. I currently am using the code:
    _______________
    on (release) {
    getURL("http://www.youtube.com/exactvideofilenumber");
    }
    _____________
    That's the whole thing. That does EXACTLY what I want it to do... except that I want the pop-up to be smaller...

    width="425" height="334"></

    ...to be exact.

    I just want to make sure that you understand that I don't want to upload this video as a file in my .swf application.

    You know of no way to somehow append to the actionscript I have above to make this happen? The whole selecting the first frame and changing the script is going to be tough for me. I'm lucky I figured that much out. And you guys seem to understand (for example) if a poster means actually type "MyNewWindow" or if you're supposed to put a new name that will be the title of the window... and various other issues within the script you were generous enough to share. For example, when I tried to place the script you suggested above for a button...

    myButton.onRelease=function(){
    root.launchNewWin("http://somesite.com/somefile.jpg", 700, 380, "myNewWindow");
    }

    ...and I of course put the correct youtube.com URL. I get the error message "Symbol=read_more, Layer=Layer 4, Frame=1: Line 1: Statement must appear within on handler
    myButton.onRelease=function(){ "

    Any idea what I'm doing wrong?

  9. #8
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Statement must appear within on handler
    myButton.onRelease=function(){

    This is the error you get when trying to paste frame code onto an object(movieclip). Create a brand new test movie. Paste the function on the first frame of the movie....

    Code:
    function launchNewWin&#40;url, wdth, hdth, windowNewName&#41; &#123; 
    if &#40;windowNewName == undefined&#41; &#123; 
    var windowNewName = "newWin"; 
    &#125; 
    //End if 
    getURL&#40;"javascript&#58;window.open&#40;\""+url+"\",\""+windowNewName+"\",\"width="+wdth+",height="+hdth+",top=\"+&#40;&#40;screen.availHeight/2&#41;-&#40;"+hdth/2+"&#41;&#41;+\",left=\"+&#40;&#40;screen.availWidth/2&#41;-&#40;"+wdth/2+"&#41;&#41;&#41;; void&#40;0&#41;;"&#41;; 
    &#125;
    Now, just for testing, lets get rid of the button and let the function run when the movie first loads. Paste this directly below the function ...

    _root.launchNewWin("http://msn.com", 700, 380, "myNewWindow");

    The last parameter(myNewWindow) really only needs to be modified if you plan on using multiple windows. If you use the same window name, any pop up you open will reload the existing custom window. If you use a new window name, a new custom browser window will open. Once you get the msn site to open, try changing the path to the video file.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  10. #9

    Default

    You said: Paste the function on the first frame of the movie....

    Tell me how to do that. I click on the first frame of the top layer (I assume) so it's highlighted... then what? Right click... choose an option from above? That's how basic I am right now. I swear i'm a fast learner.

  11. #10
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Select the first frame of the movie by left clicking on it. Open the actions panel and paste the function there. The very top left of the actions panel tells you whether your pasting to an object or a frame.
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. opening pdf problem
    By runa in forum Newbies
    Replies: 5
    Last Post: 04-16-2009, 08:21 AM
  2. opening a flash doc...
    By taylormarr in forum General Flash
    Replies: 1
    Last Post: 07-02-2005, 09:46 AM
  3. Opening a new window in flash
    By tobynistic in forum Advanced Flash
    Replies: 6
    Last Post: 10-08-2004, 09:06 PM
  4. Opening html within movie
    By hammer in forum Newbies
    Replies: 0
    Last Post: 05-14-2004, 06:21 PM
  5. Problem with opening .fla files
    By eksplosyon in forum Flash Scripting
    Replies: 3
    Last Post: 06-25-2003, 07:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial