Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2007, 04:55 PM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Get filetype

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.
Reply With Quote
  #2 (permalink)  
Old 04-15-2007, 11:37 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Get filetype

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");
}
...
}
Reply With Quote
  #3 (permalink)  
Old 04-15-2007, 11:58 AM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Get filetype

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);
Reply With Quote
  #4 (permalink)  
Old 04-15-2007, 12:03 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Get filetype

You must add a blank between the command and the argument

Code:
var wnd = Shell.run(getDefaultBrowser()+" " + path);
Reply With Quote
  #5 (permalink)  
Old 04-15-2007, 12:19 PM
Junior Member
 
Join Date: Jun 2005
Posts: 22
Default Re:Get filetype


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....
Reply With Quote
  #6 (permalink)  
Old 04-16-2007, 02:04 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Get filetype

The other tag should not be opened by swfkit. Please check your firefox settings.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:14 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.