I am writing some code based on the following tutorial:
http://active.tutsplus.com/tutorials/3d/quick-tip-displaying-a-3d-model-with-papervision3d/
I copied the code from the example and added paths to my own assets.
[Embed(source="/Models/daeModel/cow.dae", mimeType="application/octet-stream")]
private var CowModelClass:Class;
[Embed(source="/Models/daeModel/Cow.png")]
private var CowTextureClass:Class;
[Embed(source="/Models/SkyDome/images.jpg")]
private var SkyTextureClass:Class;
[Embed(source="/Textures/grass-texture.jpg")]
private var GrassTextureClass:Class;
The assets shown above are used to display a Collada cow model standing on grass (plane) under a skydome (sphere), so my code differs slightly from the tutorial and I am loading Collada not DAE.
import org.papervision3d.objects.parsers.Collada;
I publish it in Flash CS3 and the .swf works perfectly. Cow model displays, grass plane and skydome all show up.
Unfortunately the assets are loaded at runtime because Flash CS3 does not embed.
To embed the assets I then compile the .as using mxmlc.exe using:
-static-link-runtime-shared-libraries=true
and I get no compilation errors.
However, when I run the .swf, the grass plane and the skydome appear normally with their embedded textures, but the collada model does not show.
My own debug text displays the width of the model as 0, so it looks like the model hasn't loaded. The Collada class still works fine because I am able to move the 3D co-ordinates of the model and thereby move some 3D text which is centred on the co-ordinates of the model. The text displays but the model is not visible.
By making a simple change I am able to check the model's texture 'Cow.png' by applying it to the grass plane, and it shows up fine. Because the texture is in the same folder as the model, I know that navigating the path to the model's location isn't the problem.
Does anyone know of any reason Collada models might not show after compile with mxmlc?
Am I missing any command line parameters or something obvious like that?
Failing that is there any other way of embedding this model?
Problem Solved!
Compiler mxmlc required me to define cowByteArray as XML:
//load cow model MXMLC
var cowByteArray:ByteArray = new CowModelClass ( );
cow = new Collada ( ) ;
cow.load ( new XML(cowByteArray), cowMaterialsList ) ;
Using the second code, after compiling with mxmlc, the model shows up fine!
Hope this helps somebody!
Related
I want to create a re-usable Flash MovieClip (component maybe?) that can be dragged and dropped from the library onto the Flash IDE stage (for an example, a "stop all movieclips timer component").
I've created some attractive vector icon graphics for visual reference, so that when it's dragged onto the stage, the developer can visually see the component on the stage, similar to what Google does with it's DoubleClick components. It's not important for these icon graphics to be seen at runtime however, and I'd like their visual portions to not be compiled at runtime to save on filesize.
I'm often asked to create visually rich Flash units in extremely small file sizes. So basically I want my movieclip icon components to not add to filesize (except for the code portion), not compile and render visually but still have the code within them run.
How can I achieve this? Would creating them as components do anything for my issue? Is this even do-able?
Components are definitely the best way to achieve visually represented imported code, however it would be much easier, more compatible and more reliable to just use an imported code library...
Make a seperate .as file, put it in com/mycompany/animation in your swf folder (or use a global classpath), and add this code:
package com.mycompany.animation {
class MyTimerUtils {
public static function stopAllClipsAfterTime(ms){
setInterval(MyTimerUtils.stopAllClips, ms);
}
public static function stopAllClips(){
//etc
}
}
}
Then when you want to use it in a project, just put this code on frame 1 of your main timeline:
import code.mycompany.animation.MyTimerUtils;
MyTimerUtils.stopAllClipsAfterTime(3000); // 3 seconds
What could be easier? If another developer wants to know if a piece of code is implemented they need only look at the first few lines of code.
Hi I have made a tile based game using a tutorial from this site http://www.wildbunny.co.uk/blog/2011...m-game-part-1/ My game is complete but I want to add a preloader to it.
A little background for a hopefully better understanding.
FlashDevelop is where all of my as3 files and classes are and I can also test my game here and I works fine.
Flash CS6 is where I have only one scene "scene 1" with one frame on it, this frame has all of my tile based images ( movieClips ) and animations in squares, if I double click a movieClip ( for example "player" ) it will go inside and I have got lots of frames ( jumping, running etc ).
I can't test my game from here, It shows errors (scenes are NAN). I think that's normal not sure - maybe off topic anyway.
I have looked on the internet for a tutorial on preloaders suiting my situation but can't find any using flash with flashDevelop and AS3.
You create a brand new project "Actionscript 3 with preloader", FD will generate you a preloader class *.as file, and a main class file with a [frame] directive in it. Copy the preloader *.as file into your current project, copy the directive from new project's Main.as into your project's Main.as, change the package name if needed in both places (in preloader's getDefinitionByName() call and in the directive - fully qualified class names required), add whatever visuals you want to your preloader class, and you're set.
The directive in my case looked like this:
[Frame(factoryClass="Geologist.Preloader")]
The package is Geologist, and the startup() function of the preloader was like this:
private function startup():void
{
var mainClass:Class = getDefinitionByName("Geologist.Main") as Class;
var theStage:Stage = this.stage;
theStage.addChild(new mainClass() as DisplayObject);
theStage.removeChild(this);
}
I am building an app using Starling and have imported the scaffold project however whenever I call getTextureAtlas() it doesn't show the image
this.mLogo = new Image(Assets.getAtlasTexture("powered_by_starling"));
this.mLogo.x = 0;
this.mLogo.y = 0;
this.addChild(this.mLogo);
There are no errors so I am guessing it can find the texture. If I change the name to something that doesn't exist it throws an error 'texture cannot be null'. I am also using
Assets.contentScaleFactor = Starling.current.contentScaleFactor;
and everything is pretty much a standard import of the scaffold as is however I am using Feathers UI screen navigator but I haven't had a blank image issue on other projects.
Edit: I can't seem to get the sprite to work within a class that extends feathers.controls.Screen
Is getAtlasTexture a function that you wrote? Are you using starlings asset manager? If that's the case, you will need a instance of that class, not static method call.
Anyway, try using the Texture class and the static method it offers. You don't need atlas(sprite sheet) for a Image - you will need it however for MovieClip.
Texture.fromBitmap
Texture.fromBitmapData
.... and others, check documentation
If your graphics are embedded, then use this:
var _img:Image = new Image(Texture.fromBitmap(new Assets.EmbeddedGraphic()));
Are you using atf? because the same happened to me until I used png and then it worked
I'm trying to build an app allowing the user to arrange different shapes, add text, and export the result as a vector file.
I've been looking into as3swf libraries and especially the SVGShapeExporter class.
It works fine if you load an swf in the app and try to export it on the fly into an svg file but I'd like to work with movieClips instead of loaded swfs.
Since as3swf.SWF objects are based on ByteArrays, I've been trying to get a ByteArray for my MovieClip but it seems to be empty.
Any idea?
Thanks
I'm making a website for a client where they purchased a flash template that was written in "AS 1.0 & AS 2.0" and then asked me to add a googlemap to the contact us page. However, the googlemap API only works in AS3. My options were to translate the entire website to AS3 OR to make an AS3 file that imported the AS2 website and then added the googlemap bit.
I decided to go with option 2 since it seemed easier...
Anyway, I'm using the Loader class in the AS3 file.
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("main_v8.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader);
The problem is the AS2 swf file uses XML to load the background images. It works on its own but when loaded into the AS3 file the background images do not appear. All the buttons and external links work, its just the loading of the XML.
I've been looking all over for help on this and while there are lots of people with issues playing AS2 swf in AS3 I couldn't find anything to help with this.
Any advise or solutions would be appreciated!
Thanks!
Havent face such a problem but, if you find out the problem you ca solve it. You can check some conditions:
check network for , does xml loaded. (might be crossdomain problem)
check if images loaded. ( as3 security problem)
check as2 file really inits. ( you can use as3 bridge to as2)