(Keep in mind that I am using Flash CS-3 because the instructions will differ if you are using FlexBuilder or the SDK)
The DVD app I'm working on needs to access a locally stored xml file and hundreds of photos. If you do this with AIR, you can have the installer include all of the files -- but in this case it creates an AIR file that was 150MB -- and the resulting Shu file was 200MB! Of course, the better way is to keep the files external to the exe. To do this you need to use the built-in Shu app path variable. Here are the steps to
implement it:
1. Follow the instructions in Shu to install its swc file into your Flash CS3 components directory
2. Drag an instance of the Shu component onto your stage
3. Import the Shu classes:
import com.cjt.shu.Shu;4. Create a Shu instance:
var shu = Shu.GetInstance();5. Set the var to the appPath:
var shuAppPath:String = shu.Paths.app;Now when you want to access anything that is outside of the flash file you need to prepend this variable to the path. So if you have an xml that resides in the same directory and would normally reference it this way:
pData.loadXML("presentation.xml");you would do this instead:
pData.loadXML(shuAppPath + "presentation.xml");...or if you have a photo that loads at runtime and its in the photos folder you do the same thing. Of course, if you don't do some error checking the app will compile but won't work when you run it as an AIR app -- but everything will be fine when you create and run the Shu file.
The good news is after I finally figured it all out, it works like a charm! The user can choose a photo and download it anywhere they want. I still have to try it out on MAC before I buy the program, but at this point I'm impressed.
However, it would be great if they included some simple tutorials on how to build stuff -- I almost gave up altogether because when I compiled my first Shu file from a fully working AIR app - and put the exe in the same folder, it didn't work at all. It was only because I had worked with Zinc before that I thought it might be necessary to access files using a application directory locater - rather than being able to just reference them relative to the app itself.
No comments:
Post a Comment