AS3 FDT How to instantiate an fla asset with a custom class? - flash-builder

I jsut started working at a company that uses flash builder, but I am using fdt at the moment. I am hvaing trouble getting FDT to instantiate the sprite in an fla project along with the custom class that goes with it.
Also, for some reasont he people here say instantiating a sprite like this is WRONG:
var mc:MovieClip = new MoviClip()
and this is right:
var _someClass:Class = getDfinitionByName("Linkage") as Class;
var _mc:Sprite = new _someClass() as Sprite
I cannot figure out how to instantiate the movieclip in the fla and also the as class at the same time with this method.

Is the asset a 'Sprite' or a 'MovieClip'? Although you can create Sprite assets in Flash Professional (FLA) it's likely the asset is a Movieclip.
Please confirm this.
Alao, a 'Movieclip' is a 'Sprite' since it inherits from 'Sprite'.
That way of linking is quite verbose and not typical. Are you linking the asset at compile or runtime?
Most people just export assets as a SWC. If you want to get the asset at runtime it's a different thing a bit...
Look at this post.

You use getDfinitionByName("Linkage") when your assets are loaded at runtime. If they are linked at compile time (as an swc library) then you're free to do var mc:Linkage = new Linkage(); instead.

Related

Monogame texture loading NullReferenceException

I have a working game where I am loading all the textures from a different class. It works perfectly fine for the PC version.
Now, I am trying to port it to win8 using Monogame.
If I load a texture from Game1.cs using .xnb file it works absolutely fine. However, when I try to load the same texture by using a different class, it doesn't. It gives me an NullReferenceException error on
GraphicsDevice.Clear(Color.Cornflowerblue);
HungryCoder:
I don't know how you are loading the texture from the class, however, right now MonoGame doesn't yet have a Content Pipeline like you were provided with in building and XNA Game for the PC (they are working on it), therefore, you cannot add graphic files in the same manner.
In my walkthrough of building a Windows 8 XNA game, I create my Shooter player graphic from my own Player class by passing into my Initialize function within the class the Content.Load<> with the Texture type and location:
player.Initialize(Content.Load("Graphics\player"), playerPosition);
Note the .xnb file is located in a folder Graphics within my project.
In my background, I have also created a parallaxing background from a my background class by passing in the full Content Manager to my Initialize method of my Background class as well.
bgLayer1 = new ParallaxingBackground();
bgLayer1.Initialize(Content, "Graphics\bgLayer1", GraphicsDevice.Viewport.Width, -1);
Both of these examples work within my project/game.
If you interested have posted the player code example as a part of blog tutorial series on MonoGame on Windows 8. As I complete the code for the background, I will also add the full code example for the background as well. Hope this helps.
http://blogs.msdn.com/tarawalker

Xcode: Cocos2d: Can't create world with Box2D

My project originated as the cocos2d Box2D template and I'm having issues as soon as I tried to create a world:
world = new b2World(gravity,doSleep);
Gives the error: No matching constructor for initialization of 'b2World'.
The file is .mm, I assume it's some issue about library linking maybe? If so I'm using xCode 4, how can I check the lib is properly linked?
Thanks.
You are using Box2D v2.2 or newer. The b2World constructor no longer takes two arguments, just one (gravity). You have to set doSleep separately:
world = new b2World(gravity);
world->SetAllowSleeping(doSleep);
This won't be the only change you'll need to make to transition from Box2D v2.1.x to v2.2.x. Kobold2D has a working Box2D 2.2.1 sample project, even if you don't use Kobold2D you can get updated source code for Box2D basics. In particular the GLESDebugDraw class and how to setup a screen bounding box with a body using multiple shapes.

How to create an Objective C class/framework for re-use in the team

I have a class (that inherits from a base class) and also has image assets for some UI elements. I would like to be able to wrap this up images and all, into a single file that can easily be added to future projects by myself and other members of the dev team. Is there a way to do this? Adding a documentation file, a la Apple's own that responds to cmd click within XCode would be the icing on the cake.
Cheers
Dave
You create a static library... see the following Tutorial

Convert Interface Builder code to Xcode

Is it true that everything you do in Interface Builder can be done programmatically? If your project uses Interface Builder to make the GUI, can that code be converted to native Xcode and inserted into the project?
It is true that anything you can do in Interface Builder you can do programatically. However, IB does not generate code, so there is not really anything to 'convert' to source code for your project.
Interface Builder creates archived objects -- serialized instances of class instances -- and works directly from those. While you can reuse your .xib files (which some people still insist on calling "nibs") in any number of projects, you should note that:
Your nib is already code: it's just very verbose and hard-to-read XML. This XML contains the serialized (say "archived") instances.
You cannot "convert" your xib to Objective-C code, or at least Xcode does not provide a way to do this (and I don't know who would).
If you do not have the classes that the xib expects, you will run into errors using your xib.
I wrote a utility to convert .xib files to code. It's still experimental, but should do the majority of the grunt work converting to code:
https://github.com/Raizlabs/Eject
You can try it out online:
https://eject.herokuapp.com/

SqueakSource add a resource file

I'm new to squeak/squeak source and i am writing a small game as a learning exercise. I have a few graphics that i am using for some of my sprites (mostly pngs) but i cannot figure out how to add them to my squeak source repository.
Is there a way to do add these files to my project so my team doesn't have to keep emailing images to each other.
Thanks
=== Final solution ===
Based on Lukas' advice i ended up creating a class that only hold methods which produce images. unfortunately actually writing these methods was kind of a pain (esp for large images).
So i created a helper method on the class that allows you to add an image message dynamically.
addIcon: selector fromFile: fn
| image stream |
image := ColorForm fromFileNamed: fn.
stream := WriteStream with: String new.
stream nextPutAll: ((selector asString) , (String cr), '^').
image storeOn: stream.
(IconsHolder class) compile: (stream contents) classified: 'auto-generated'.
^self.
So then if i wanted to update or add an image i could just do:
IconsHolder addImage: #image... fromFile:'image.jpg'
And it would generate a new message in IconsHolder that would generate the image from code.
Monticello does not provide support to version external resources, this has nothing to do with SqueakSource as the hosting system. Most developers put their resources (small images, scripts, resources, ...) into methods, see the classes OBMenuIcons in OmniBrowser or WAFileLibrary in Seaside for prominent examples.