|
|||
|
Hi, just a quick question:
How can i get the filetype? I couldn't find it in the manual nor in the forum. When a user selects an image it can be a jpg, bmp or png (or in case of a movie: mpeg, avi). To save or copy the file to a new destination i need to know what the filetype is, the code below is hardcoded at .jpg. Is there a solution? Thanks in advance. I have something like this: Code:
var selectedPhoto = FlashPlayer.getVariable("selectedPhoto");
var path = getAppDir()+ "publish/html/images/";
var listing_image = path + selectedListing + "_" + selectedPhoto + ".jpg";
var listing_thumb = path + selectedListing + "_" + selectedPhoto + "_thumb.jpg";
var filter = "All Image Files|*.jpg;*.jpeg;*.png;*.bmp|";
var image = Dialogs.fileOpen(filter);
if (image)
{
var imgObj = Image.load(image);
if (imgObj == null) return;
Zoomfactor = 550/imgObj.width;
imgObj.zoom(Zoomfactor);
imgObj.save(listing_image);
etc etc.
|
|
|||
|
You can do that by checking the file extensions as the following code
Code:
var filter = "All Image Files|*.jpg;*.jpeg;*.png;*.bmp|";
var image = Dialogs.fileOpen(filter);
if (image)
{
var ext = image.substring(image.lastIndexOf("."));
if (ext == ".jpg")
{
trace("a jpeg file");
}
...
}
|
|
|||
|
That works great! thanks, i was searching for a special command, never thought of this.
One completely other thing: How do you open a browser window with a local file?. All browser scripts i've found here don't work without a http or www in the path. e.g. this one: function getDefaultBrowser() { var rk = new RegKey("HKCR\\.htm"); if (rk == null) return null; var rv = rk.getValue(); if (rv == null) return null; var filetype = rv.data; rk = new RegKey("HKCR\\"+filetype+"\\shell\\open\\command") ; if (rk == null) return null; rv = rk.getValue(); if (rv != null) return rv.data; return null; } var path = "file:///" + getAppDir()+ "publish\\html\\index.html"; // this doesn't work //var path = "www.derekscholte.nl"; // this does... var wnd = Shell.run(getDefaultBrowser()+path); trace(wnd); |
|
|||
|
hmmm, almost there, but now it opens two tabs in firefox, one containing: http://en.wikipedia.org/wiki/January_1 (??) And the other the intended local file.... |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|