Not sure why this is happening, but try to omit the beginning forward slash and see what happens. Also, try to do that and also replace the forward slashes with backward slashes.
One other idea is that you may need to have the paths relate to some AIR specific path paradigm, such as this:
import flash.filesystem.File; var tempFiles:File = File.applicationStorageDirectory; tempFiles = tempFiles.resolvePath("images/"); trace(tempFiles.url); // app-storage:/images
import flash.filesystem.File; var directory:File = File.documentsDirectory; directory = directory.resolvePath("AIR Test"); File.createDirectory(directory); trace(directory.exists); // true
Thanks for the quick response! I tried playing with the slashes with no luck.
Also, I don't see how to apply the file system function calls to my css; I'm probably missing something silly there. Problem is, seems that approach would diverge my Flex and AIR solutions. That would be a bad thing since I'm trying to use the same code for both my Flex and AIR deployments.
The file system calls would be done in ActionScript, not in CSS.
If this post answers your question of helps, please mark it as such.
Thanks for hangin' in there with me on this.
Sure, file system calls are done in AS, which is why I'm wondering how they apply to styles.
Also, any use of file system calls would keep my Flex app from compiling.
I'm wondering if the file system calls are necessary to resolve file paths in an AIR app.
You are right, those system calls won't work in a Flex app, but you're trying to port to AIR, right?
The preferred deployment is Flex. However, I also need to provide an out-of-browser experience (some users are subject to a "disable Flash in your browser" security policy).
So, this isn't a one-way porting effort. I need to maintain both a Flex and an AIR version of the same application.
Well, considering the fact that the root tag of an AIR app is <mx:WindowedApplication> and the root of Flex is <mx:Application> that may be difficult. But perhaps you are maintaining two main app pages, and trying to keep the rest the same. In that case this may be another page that must be different.
Correct. I have two main pages that create a canvas and programmatically populate that canvas. I do this type of embedding in much more complex classes and custom components. Surely, the syntax for embedding images doesn't differ between Flex and AIR. I laid things out with the assumption there are no differences like this (the same facility needs to be used differently).
I hoped I was just making a nooB mistake. Looks like I've got a bit of restructuring to do. I suppose I could create/play with a sample mini-app just to test it out.
I think I see where you were going with the File function calls. See where AIR is looking for the assets directory, then adjust my Embed path or directory structure to match.
Well, I took your File function call suggestions, spun up a simple AIR app, and determined where AIR is looking. Applying that to my app didn't help.
I then realized that these calls would show the runtime location, but I'm having problems compiling. As I understand it, the Embed() directive puts the image in the swf, so there's no file system reference to get those images at runtime. It also means that I need to give Embed() a compile-time location for the files.
So, my next attempt was to simply give a fully-qualified path to Embed(). But of course, no luck there either.
General cry for help:
Has anyone successfully embedded an image in an AIR application through a stylesheet Embed() directive? If so, could you post the Embed() syntax you used and specify where you keep your images in your AIR workspace?
OMG! I finally found a post here (http://kyledodge.org/?cat=5&paged=2) making reference to a similar problem. In his case, a typo in one (1) file path caused the Flex compiler to flag all 160 of his Embed() directives as invalid.
In my case, one file was not copied over from my Flex build environment. When compiling for AIR, all of my Embed() directives were flagged as invalid because of that one file. Once I restored it, I got a clean compile for everything.
This seems like a compiler bug to me... sort of like saying all of your classes are whacked because of a typo in one. However, I'm still a nooB in this area so I'll take it as a lesson learned.
I read your posting with the great interest, as i am a noob as well and have come across a situation somewhat your (see below):
I have a question related to the type of thing that u r doing. Suppose I have three .swf files (call them game1.swf, game2.swf, game3.swf) . In my AIR app (running in the desktop mode, NOT via browser), I want have three buttons (assocaited with the three game.swf files), whereby when my AIR app comes up the user can click on a button which would in turn invoke one of the three games:
1. I am assuming that I can use Embed() the same way u r and have the game.swf files in assets directory.
- Any idea if this would work?
- if my AIR app (called it foo.air) is stored in c:\myApps\foo.air, where should i put my game.swf files so i won't get AIR security violation at the run time?
2. A totally unrelated question: suppose in my AIR app, I want to read a .txt file via a system/lib call.
- Any info about how to make a sys/lib call from with AIR?
- Due to AIR security mode, do i need to worry about the location of the filw, i.e., does the local .txt file MUST be in the directory/folder as the AIR bits thmselves?
Thx in advance for your help.
Sorry to disappoint, but what you're attempting is a bit more advanced than anything I've ever tried.
Re: Embed()ing swf files
I have no idea if this would work. Adding movies is out of scope for my project. Flash (Flex) libraries would be added via SWC files.
Re: reading a file from the file system
I followed this tutorial to get me going.
Thx 4 getting back 2 me. Appreciate responding to my email.