Running Away3DTemplate

The instructions under the heading Creating an empty project for Away3D stepped you through the process of creating an empty project ready to accept code that uses the Away3D engine. In order to run the Away3DTemplate class, we now need to add that class to the empty project. We also need to specify the class as the application entry point, meaning it will be executed when the application is first run.

Adobe Flex Builder and Adobe Flash Builder

The following steps show you how to add the Away3DTemplate class to the Flex and Flash Builder projects we created earlier:

  1. When using the previous instructions to create an empty project, Flex/Flash Builder will create a default ActionScript file for you with the same name as the project, for example, Away3D.as. This file needs to be deleted, so right-click on the file in the Project Explorer | Flex Navigator pane and click on the Delete option.
  2. Click on the Yes button to confirm the deletion of the file.
  3. Click File | New | ActionScript Class.
  4. In the New ActionScript Class dialog box, type Away3DTemplate in the Name textbox and click on the Finish button.
  5. Paste the code for the Away3DTemplate class into the new Away3DTemplate.as file, overwriting any default code that may be present.
  6. Right-click on the Away3DTemplate.as file in the Project Explorer | Flex Navigator pane and click on the Set as Default Application option. The icon for the file should include a green triangle and a blue sphere.
    Adobe Flex Builder and Adobe Flash Builder
  7. To compile and run the application click Run | Run | Away3DTemplate.

FlashDevelop

The following steps show you how to add the Away3DTemplate class to the FlashDevelop project we created earlier:

  1. Using the previous instructions to create an empty project, FlashDevelop will create a default file called Main.as in the src directory. This needs to be deleted. Right-click on the file in the Project pane and click on the Delete option.
  2. Press the OK button to confirm the deletion of the file.
  3. Click File | New | AS3 Document.
  4. Paste the code for the Away3DTemplate class into the new file, overwriting any default code that may be present.
  5. Click File | Save. Save the new file as Away3DTemplate.as under the project src directory by clicking the Save button.
  6. Right-click on the Away3DTemplate.as file in the Project pane and click on the Always Compile option. The icon for the file should change to include a green arrow pointing down.
    FlashDevelop
  7. To compile and run the application click Project | Test Movie.

Adobe Flash CS4

The following steps show you how to add the Away3DTemplate class to the Adobe Flash CS4 project we created earlier:

  1. Click File | New….
  2. Select ActionScript File from the General tab and click on the OK button.
  3. Paste the code for the Away3DTemplate class into the new file.
  4. Click File | Save.
  5. Save the file as Away3DTemplate.as in the same directory as the FLA file from the previous instructions.
  6. Go back to the FLA file and click File | Publish Settings….
  7. Click on the Flash tab, and click on the Settings… button.
  8. Type in Away3DTemplate into the Document Class textbox, and click on the OK button to save the changes.
    Adobe Flash CS4
  9. Click on the OK button to close the Publish Settings window.
  10. To compile and run the application click Control | Test Movie.

Tip

If you see the ActionScript Class Warning dialog box when clicking the OK button in step 8, go back to step 5 and make sure that you saved the Away3DTemplate.as file in the same directory as the FLA file.

The end result

When you compile and run the application you will see, well, nothing. However, this is fine, because it is the expected result. The Away3DTemplate class has provided a foundation that takes care of the initialization and updating of the Away3D engine, but does not create any visible objects that will be shown on the screen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.64.66