I am new at Actionscript and when I say new, I mean yesterday...
I have this code here that opens a new link
myButton.addEventListener(MouseEvent.CLICK,goThere);
function goThere(e:MouseEvent){
var request = new URLRequest("http://www.jamessuske.com/freelance/korkis/3DLibrary.php");
navigateToURL(request);
}
How do I get this to open in a new window with sizes?
Thanks, J
I would think adding _blank
to navigateToURL
will open a new window (see docs):
function goThere(e:MouseEvent):void
{
var request = new URLRequest("http://www.jamessuske.com/freelance/korkis/3DLibrary.php");
navigateToURL(request, "_blank");
}
myButton.addEventListener(MouseEvent.CLICK, goThere);
And about sizing the window ... I think that's not possible (but hey, someone can prove me wrong ;) )
OK, maybe you can also size it by using ExternalInterface (look at example at the end) (untested):
Edit your embed html: Add
<param name="allowScriptAccess" value="always" />
to your embed html and add the following call at the start of you AS3 code:
flash.system.Security.allowDomain("*")
Then the following code should work:
function goThere(e:MouseEvent):void
{
ExternalInterface.call("open", "http://www.jamessuske.com/freelance/korkis/3DLibrary.php", "_blank", "width=300,height=400,left=100,top=200");
}
I don't believe you can control the new window size, but you can open it in a new window using the target
property.
navigateToURL( request, "_blank" );
See navigateToURL()
on the LiveDocs.
You should also note that in AS3, you must always include a datatype with every single object you create.
function goThere(e:MouseEvent):void {
var request:URLRequest = new URLRequest("http://www.jamessuske.com/freelance/korkis/3DLibrary.php");
navigateToURL(request);
}
Note the ":DATATYPE" after the variable declaration and also after the function declaration. I do not believe Flash Pro will point this out to you, but every single object you create has to be datatyped. AS3 (along with Java and most C-based languages) uses strict datatyping whereas Javascript, PHP, and AS2 use loose datatyping where an object takes the datatype of its value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With