How to point to a file on a desktop directory in as3 in an AIR app - actionscript-3

I'm currently using this to successfully load (and play) an mp3 from a folder on my desktop in my AIR desktop program:
soundBG2.load(new URLRequest("C:/Users/User/Desktop/music/mySong.mp3"));
It works well, however I'd like to not use an explicit path. I'd like to use something like:
soundBG2.load(new URLRequest(desktopDirectory+"/music/mySong.mp3"));
...which of course doesn't work the way it's coded there, but how to I do that please?
Thank you

Figured it out:
soundBG2.load(new URLRequest(File.desktopDirectory.nativePath + "/music/mySong.mp3"));

Related

Intellij doesnt recognise symbol

My intellij can't recognise path to images and other files but when i use ctlr+left mb it finds file or image without problem. Im working with other ppl and we share it on github and only i have this problem. When i run application web pages are completely fine but when im trying to just view html file it doesnt recognise css and images. I tried creating project again, clearing cache and reinstalling ide. Photo shows files in project
how files are structured
EDIT:
Im trying to view html file clicking this and that is the result. Css and images are missing even though path seems to be correct. Problem occures on my computer. Program works on my teammate pc

First HTML Project - Broken Image

So I began studying code this month and I'm doing an online Web Development Bootcamp. My first assignment was to create a publish a simple HTML site on GitHub. I just published my site but when I go and check it out, the image is broken, which wasn't happening on the Offline version.
So this noob here needs help trying to figure out what I did wrong.
sakurach4n's first HTML project
This commonly happens when migrating from a local site to a live site.
The "src" for the image needs to be published/hosted somewhere on the web so it has a direct URL to the image, like this image of a cat: https://ichef.bbci.co.uk/news/1024/cpsprodpb/151AB/production/_111434468_gettyimages-1143489763.jpg
It works locally because that file is present on your local machine in a folder somewhere. Because the file path is relative it now searches for the image like this: https://sakurach4n.github.io/images/mafalda.png (which does not exist)

ViewerJS not loading my pdf document

As said in the instructions at the site ViewerJS Instructions, I tried to embed my file like http://localhost/site/ViewerJS#../docs/mydoc.pdf
But this is not working.
My document is in the dir like
/docs/mydoc.pdf and a link like http://localhost/site/docs/mydoc.pdf is working perfectly. In href, I usually put docs/mydoc.pdf and that works. In the same way, as said in the instructions, my document is not loading.
Any help is appreciated.
The solution is simple. Move the ViewerJS to the root directory of the site. Everything is working perfectly.
So, the viewer is accessible like
http://localhost/site/ViewerJS/#../docs/mydoc.pdf

Brackets - Live Preview not working

I found this awesome program(html editor) called Brackets and it's by Adobe.
Now reason why i got the editor was because i wanted to Live Preview PHP code, but i found out later that i needed a Wamp Server.
Now, i was in the mood of making an about page but i couldn't live preview. Live Preview Base URL is empty, and when i try to live preview, i get this: > http://puu.sh/aDkET/4209ec1192.png < and the lightning bolt is half orange(i heard it needs to be red to work). I have tried the lot... Entering as Live Preview Base URL to http(semicolon)//localhost:(insertporthere)/ <-- Wamp Server, tried only localhost, left it empty, I don't know how to make this work.. I am stuck and i basically need real preview..
Please, please help me! D: I have searched the internet looking for solutions, but no. If you can, a step-by-step tutorial would be much appreciated :)
Kind regards,
- PiguFilms
The Live Preview "Base URL" is the localhost URL that corresponds to the root folder of your project. Brackets uses this to map from a local path on disk to the server URL which serves up that same file: it takes the HTML file's path relative to the project root, appends that relative path onto the Base URL, and then launches the resulting full URL in Chrome.
So, for example:
If your page is at http://localhost/myapp/page.php and the page.php file is in a "myapp" subfolder of your project, your base URL is just http://localhost/.
If your page is at http://localhost/myapp/page.php and the page.php file is in the root of your project, your base URL is http://localhost/myapp/ (this way the path is "/page.php" relative to both bases).
If you think you have the Base URL set correctly but it's still not working, try going to the same URL manually in your browser to make sure your server is operating correctly.
More details on using Live Preview with your own local server can be found here: https://github.com/adobe/brackets/wiki/How-to-Use-Brackets#lp-custom-server.
although #ytpete's answer is the right choice for your problem but you need to do, as i say, first. In simple words, go to file(in Brackets), click open folder and now make the project directory exactly same as your local host server for php files i.e. C:\Program Files\Ampps\www\phpFiles (i am using Ampps and here 'phpFiles' is a subfolder inside which relies my php file and also html file too). Now you can follow steps shown by ytpete and you are set to live preview of your php file.
I had this problem as well. What I did was simply goto File->Open Folder... it all worked after all the necessary files were loaded into Brackets.
If you are using windows try running brackets "As administrator", worked for me
I had this same issue once I installed Xampp. This video resolved it for me. Essentially just select, File > 'Enable Experimental Live Preview' should have a check mark.
Make sure you don't have an internet bandwidth limiter (such as NetLimiter) running while using Brackets' Live preview.
I have just fixed this issue for myself, I had 'Experimental Live Preview' ticked under file. I unticked it and now it accepts my 'http://localhost/mywebsite' URL when I go to live preview.
This worked for me. I restarted my system and then unchecked "enable experimental live preview" in file.
this worked for me, and i don't remember where i saw it, but go to : cd $HOME/.local/share/applications and delete everything chrome related.
This worked for me, and i didn't dare to use live preview again.
On Ubuntu 16.04 LTS and Chrome Version 61.0.3163.100 (Official Build) (64-bit)
Put your files in the same folder where you have index.html file
I have selected the option called "reload with extension" from Bracket's debug menu and that resolved live preview issue. More details can be found here.
For everyone, this problem can be resolved by following steps:-
On menu bar, go to File --> Open Folder (folder which have your html file for live preview)
Select Folder
Select your html file from left side bar for live preview
Click on bolt icon on right (preview button)
All it melts down to the fact, that you need that folder(which have your file) selected to view your output in live preview.
Let me know, if it helps someone. :)
It is because it doesn't find the 'html' file. Live preview basically needs html file to run it .In my case, I have a project made in php , my file name is index.php,I renamed it to index.html and it works like charm :)

ActionScript 3.0: Loading external fonts (.ttf)

Is it possible to load .ttf font from bytecode without using [embed] metatag or compiling font into .swf?
Situation next: My app gets zip archive with graphics, and I want to add chance to change visualization font.
But I can't use swf-compilation in that case. Instruments: FlexSDK, FLashDevelop.
The only way to use runtime loaded ttf/otf fonts is do the same that mxmlc do: transcode font files to AS3 classes, construct the new swf, load it into Loader and get fonts classes (that is embed ttf file into newly crated swf in runtime). You have to check the swf spec and I guess the Flex SDK 4.6 sources will be helpful. May be you will be able to find implementation, I can't managed to do this.
The still is the simple way - precompile each font file to swf and include it to your graphics zip, I don't this it's too hard even for non developer profession to click the bat file (you can make the template with as file and place the sdk and build bat file, all that artist need it's place the font file with the given name near the bat file, you event can ask in bat for the name of font and replace it in the template) :)
Actually this isn't an answer, but I don't have enough reputation yet to add a comment.
I see the question is over a year old. Did the situation happen to change since then? For a VJ application I'm working on it would be nice if the users could just drop a TTF file in the resources directory to use it, rather than me having to make SWFs of all fonts that could be interesting to use - which would be way too time consuming anyway and will pose licensing issues I'd like to avoid.