[swfmill] (flash8) add linkage to jpg/png directly - *STILL* possible ? + Fonts (Text version of previous post)
Luke Schreur
luke at back.net.au
Tue Jul 18 19:20:41 EDT 2006
Hi Martin,
>> Okay... That's your're final answer i bet :-)
I'm sorry, but there's not more I can do if you want to use swfmill.
As with your bitmap manager, the whole point of having a bitmap in the
library is that you can create multiple instances of the same bitmap and
having it in memory only once. With your bitmap manager, placing the
same bitmap on screen multiple times means that the same bitmap has to
be loaded multiple times, which is offcourse a waste of memory.
The only reason why Flash 8 supports a linkage ID on a bitmap since
version 8 is that the compiler just creates a MovieClip wrapper around
the bitmap at compile time when you have a linkage ID set on the bitmap.
So, in the end you just end up with the same situation.
>> Anyway thanks for your help. Luke, do you know about the 2 other
>> questions (Font smoothing, project maintenance)?
Sorry, can't help you there.
Good luck with your project!
- Luke
-----Original Message-----
From: swfmill-bounces at osflash.org [mailto:swfmill-bounces at osflash.org]
On Behalf Of MARTIN Pierre
Sent: Tuesday, 18 July 2006 23:05
To: swfmill at osflash.org
Subject: Re: [swfmill] (flash8) add linkage to jpg/png directly -
*STILL* possible ? + Fonts (Text version of previous post)
Okay... That's your're final answer i bet :-)
Originaly i was asking if there was a way to do this, not if swfmill
*was* like the flash IDE, or if what i wanted to achieve was present
since flash 8 or what. So please readers, don't consider this as *the*
answer, if someone has another guess i'm interested. And since i read
just here:
http://www.osflash.org/pipermail/swfmill_osflash.org/2005-October/000264
that there is a version which is supposed to handle a "bitmap" importing
with direct linkage function, i'm really exited to know if it was true
or not :-)
Now just for those who needs the function, attached is a very simple
class which handles bitmap loading. Each time you ask for a bitmap it is
loaded but *NOT* unloaded. So when you ask for the same bitmap twice, it
is much more faster to get it if it was cached to memory. Be careful
thought, it *can* consume a lot of memory if you misstake with the cache
parametter. It can be used like this:
CBitmapManager.GetBitmap("bmpPipo"); // Loads the bitmap named
"bmpPipo" and cache it for later calls.
CBitmapManager.GetBitmap("bmpPipo", false); // Loads the bitmap named
"bmpPipo" but doesn't "cache" it.
import flash.display.BitmapData;
// The simple Bitmap Loader class. Handles caching of requested bitmaps.
class com.CreativeHazard.UI.CBitmapManager {
// Set to true if you compile with the Macromedia's compiler.
private static var REAL_MM_FLASH :Boolean = false;
// A simple array which will hold "cached" bitmaps.
private var alLoaded :Array = null;
// The current singleton instance.
private static var cInstance :CBitmapManager = new
CBitmapManager();
// Main constructor, which is private to avoid external
instanciation.
private function CBitmapManager() {
alLoaded = new Array();
}
// Returns a requested Bitmap from it's "linkage" ID. If bCache
isn't given, it's defaulted to true.
public static function GetBitmap(szID:String, bCache:Boolean)
:BitmapData {
// Look up for an existing version of the bitmap in the cache
array.
if (cInstance.alLoaded[szID]!=undefined)
return cInstance.alLoaded[szID];
// Default the caching parametter.
if (bCache==undefined)
bCache = true;
var cToRet :BitmapData;
// If compiling with MM, just load the bitmap from it's linkage
ID.
if (REAL_MM_FLASH) {
cToRet = BitmapData.loadBitmap(szID);
// The given linkage ID was wrong. Stop here.
if (cToRet==undefined)
return undefined;
}
// If compiling with MTASC, the bitmap linkage ID doesn't exist.
// SWFMill has put the bitmap in a container with the linkage
ID.
else {
// Load the container.
var mcLoader :MovieClip = _root.attachMovie(szID,
"mcLoader", _root.getNextHighestDepth());
// If undefined, the
if (mcLoader==undefined)
return undefined;
// Initialize the bitmap planes depending on the loaded MC
size.
cToRet = new
BitmapData(mcLoader._width, mcLoader._height, true, 0x0);
// Draw the loaded MC into our bitmap planes.
cToRet.draw(mcLoader);
// Remove the loaded MC from the stage.
mcLoader.removeMovieClip();
}
// If the caching argument was true, store the result.
if (bCache)
cInstance.alLoaded[szID] = cToRet;
// All done!
return cToRet;
}
// Internal singleton method. Just returns the existing instance or
Instanciate it.
private static function GetInstance() :CBitmapManager {
return cInstance;
}
}
Anyway thanks for your help. Luke, do you know about the 2 other
questions (Font smoothing, project maintenance)?
Friendly regards, and good big mega hyper luck with the project...
Pierre.
P.S.: Do you actually need additionnal developpers on this project, or
is your team "full" yet? Just to know ;-)
Luke Schreur wrote:
>>> While in the MMFlash IDE, when i place a picture in the library
>>> and assign it a "linkage" name, it is then accessible directly
>>> with this name.
>>>
>
> Well, swfmill isn't the Flash IDE. Also, this feature only exists in
the
> Flash IDE since version 8.
>
>
>>> That's kind of dirty
>>>
>
> There is nothing dirty about it. It is just the way it works :)
>
>
> -----Original Message-----
> From: swfmill-bounces at osflash.org [mailto:swfmill-bounces at osflash.org]
> On Behalf Of MARTIN Pierre
> Sent: Tuesday, 18 July 2006 11:44
> To: swfmill at osflash.org
> Subject: Re: [swfmill] (flash8) add linkage to jpg/png directly -
> *STILL* possible ? + Fonts (Text version of previous post)
>
> Well, it's almost this :-)
>
> Actually, my library looks like this (don't mind the "bitmap-id"
stuff,
> it's only some late testing):
> <?xml version="1.0" encoding="iso-8859-1" ?>
> <movie version="9" width="640" height="480" framerate="31">
> <background color="#646464"/>
> <library>
> <frame>
> <clip id="imgPanelB" bitmap-id="imgPanelB"
> import="library/Artwork/Bottom.png"/>
> <clip id="imgPanelT" bitmap-id="imgPanelT"
> import="library/Artwork/Top.png"/>
> <clip id="imgPanelL" bitmap-id="imgPanelL"
> import="library/Artwork/Left.png"/>
> <clip id="imgPanelR" bitmap-id="imgPanelR"
> import="library/Artwork/Right.png"/>
> <clip id="imgPanelBL" bitmap-id="imgPanelBL"
> import="library/Artwork/BottomLeft.png"/>
> <clip id="imgPanelBR" bitmap-id="imgPanelBR"
> import="library/Artwork/BottomRight.png"/>
> <clip id="imgPanelTL" bitmap-id="imgPanelTL"
> import="library/Artwork/TopLeft.png"/>
> <clip id="imgPanelTR" bitmap-id="imgPanelTR"
> import="library/Artwork/TopRight.png"/>
> <clip id="imgPanelTR" bitmap-id="imgPanelTR"
> import="library/Artwork/TopRight.png"/>
> <clip id="imgPanelRH" bitmap-id="imgPanelRH"
> import="library/Artwork/ResizeHandle.png"/>
> <font id="Fnt_Generic_10"
> import="library/Artwork/Arial.ttf"/>
> </frame>
> </library>
> </movie>
>
> While in the MMFlash IDE, when i place a picture in the library and
> assign it a "linkage" name, it is then accessible directly with this
> name. Eg: Bitmap.loadBitmap("linkage_name"). The problem with my
SWFMill
>
> is that the bitmap is put *in* a movieclip, which name is the
specified
> linkage ID. So my flash workaround is what you told, loading the MC
> first, then getting the bitmap.
> That's kind of dirty, and since i want my sources to be compilable
> either from MMFlash and mtasc + swfmill, i had to code this:
> private function GetBitmap(szID:String) :BitmapData {
> if (CClientGameEngine.REALMMCFLASH) {
> return BitmapData.loadBitmap(szID);
> } else {
> var mcLoader :MovieClip = _root["mcLoader"];
> mcLoader = _root.attachMovie(szID, "mcLoader",
> _root.getNextHighestDepth());
> var bitLoad :BitmapData = new
> BitmapData(mcLoader._width, mcLoader._height, true, 0x0);
> bitLoad.draw(mcLoader);
> mcLoader.removeMovieClip();
> return bitLoad;
> }
> }
>
> What i want to achieve is to really have the bitmap "named" with the
> linkage string, exactly like it would be in MMCFlash...
>
> Well, anyway thanks for your answer. Hope you will have another idea
:-)
>
> Pierre
>
> Luke Schreur wrote:
>
>> I hope this is what you are trying to do. In the first frame you
>>
> create
>
>> your library (similar to Flash's export in first frame). Then you
>>
> import
>
>> a bitmap into your library. Then you place the bitmap inside a
library
>> movieclip. Now you can attach the movieclip to the stage or whatever.
>>
> I
>
>> did this from the top of my head so there could be typos:
>>
>> <?xml version="1.0" encoding="iso-8859-1" ?>
>> <movie width="320" height="240" framerate="12">
>> <background color="#ffffff"/>
>>
>> <frame>
>> <library>
>> <clip id="foo"
>> import="library/foo.jpg"/>
>> <clip id="FooClip">
>> <place id="foo"
>> name="myFooInstance" x="10" y="10" depth="1" />
>> </clip>
>> </library>
>> </frame>
>> </movie>
>>
>> In AS2.0
>>
>> attachMovie("FooClip", "myFooClip", 0);
>>
>> Hope this helps...
>>
>> -----Original Message-----
>> From: swfmill-bounces at osflash.org
[mailto:swfmill-bounces at osflash.org]
>> On Behalf Of MARTIN Pierre
>> Sent: Tuesday, 18 July 2006 10:48
>> To: swfmill at osflash.org
>> Subject: [swfmill] (flash8) add linkage to jpg/png directly - *STILL*
>> possible ? + Fonts (Text version of previous post)
>>
>> Sorry, last post seemt to be a bit tricky to read because of my HTML
>> formating... Here is a text version so everybody will be able to read
>>
> it
>
>> in the archive.
>>
>>
>>
>
------------------------------------------------------------------------
>
>> --------
>>
>> Hello list people,
>>
>> I'm trying to understand the how to use SWFMill to use bitmaps in my
>> movieclips, accessed from AS2 only.
>> I have tried a lot of workarounds, and have currently one which works
>> with the SWFMill "bug" (Which attach the bitmap within a container).
>>
>> Recently, i have found this post:
>>
>>
>
http://www.osflash.org/pipermail/swfmill_osflash.org/2005-October/000264
>
>> .html
>> and so have tried to make the attached 0.2.11.1 version to work the
>>
> way
>
>> i want.
>> Anyway, and after a ton of tests, i can't manage it to attach my
>>
> bitmap
>
>> the proper way.
>>
>> So my question is, is it a solved issue? Have i to keep my
>> movieclip-container-size-detection-loadbitmap-tricky workaround?
>>
>> Another question, very simple. Is it possible to avoid the "smooth"
>> effect when using SWFMill imported fonts? For instance, if i want to
>>
> get
>
>> an embeded version of the "Arial" (Some of windows default fonts)
size
>>
>
>
>> 10 in my SWF, what is the trick to avoid antialiasing?
>>
>> Last question, because the online "official" version is still the
>> 0.2.11, and because i only have found the 0.2.11.1 version with a
luck
>>
>
>
>> on the mailing list, i really appreciate if someone can tell me where
>>
> to
>
>> get latest versions. If this developpement is dead, is Dan now
>>
> involved
>
>> in another, more recent, similar project i can use? I know a bit
about
>>
>
>
>> HAXE, but it seems very unstable and "fragile", and i really wish to
>> keep my FLAME set up as it is now...
>>
>> Anyway, thanks a lot for any kind of answer.
>> Friend regards,
>> Pierre.
>> P.S.: Please excuse my poor english. BTW i'm french and the french
>>
> lack
>
>> of documentation really hurts ;-)
>>
>> _______________________________________________
>> swfmill mailing list
>> swfmill at osflash.org
>> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>>
>>
>>
>
> _______________________________________________
> swfmill mailing list
> swfmill at osflash.org
> http://osflash.org/mailman/listinfo/swfmill_osflash.org
>
>
More information about the swfmill
mailing list