RE: [Flashcoders] Loader Max Question

2011-03-23 Thread Marco Terrinoni
Many thanks for the tip Chris, I decided to try and load the assets via an
external xml file as jpgs  instead of swfs to make the application as
scalable as possible without having to recompile anything as suggested. I
still have some way to go, I've got the jpgs loading and positioned where I
want them on the stage but am still struggling to:

 

a) Convert the bitmap to a movieclip - and reference 'linkURL' attribute in
the xml file

b) add captions - I have two lines that need to be added, one for the title,
another for the date. 

 

I have followed the advice in the Gaia documentation - loading the assets
xml file into the index page in the site.xml file with the following code in
my index.as

 

var assetNodes:XMLList =
IXml(assets.projectAssets).xml.asset;

var designPage:IPageAsset =
Gaia.api.getPage(index/nav/design);

 
Gaia.api.addAssets(assetNodes, designPage);

TweenMax.to(this, 0.3,
{alpha:1, onComplete:transitionInComplete});

}

 

Then In my design.as file



}

override public function transitionIn():void


{

super.transitionIn();

TweenMax.to(this, 0.3, {
alpha:1, onComplete:transitionInComplete } );

var assetArray:Array = page.assetArray;

var len:int =
assetArray.length;

for (var i:int = 0; i  len;
i++)





{

trace(assetArray[i]);

myBitmap =
IBitmap(assetArray[i]).content;

myBitmap.visible = true;

myBitmap.x=(i % 4) * 240; 

myBitmap.y = int(i / 4) *
180 + 60; 

myBitmap.alpha = 0;

TweenMax.to(myBitmap, 0.5, {
delay:1, alpha:1, ease:Circ.easeInOut } );



}  

 

 

Should I be creating a movieclip in the design.fla file with a dynamic text
field that serves as a container for the bitmap array and create a button
array from that? If possible I'd also like to add ROLL_OVER and OUT effects
i.e. ROLL_OVER fires the caption whose y position and alpha are then tweened
in and are visible.ROLL_OUT = reverse and makes the caption invisible. 

 

Any help would be awesome

 

 

Many thanks

 

 

Marco Terrinoni - Director
MULARAM  PRODUCTIONS
web design // animation // illustration
uk: +44 7876 652 643
e:  mailto:ma...@mularam.com ma...@mularam.com  
w:  http://www.mularam.com/ www.mularam.com 

 

From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Chris Foster
Sent: 21 March 2011 21:39
To: Flash Coders List
Subject: RE: [Flashcoders] Loader Max Question

 

Hi Marco,

I've always found it much easier to let the Gaia framework manage my
loading by adding items (like SWFs, images, mp3, flv etc.) as assets to
the Gaia page. It's easier because I don't have to write code to solve
the kind of problem you're asking about...

The Gaia documentation is pretty thorough about how you can use the
assets... In the case of your SWFs it looks like you'd need to create
some buttons onstage (like a menu screen) and give them each a 'click'
event handler to make the loaded SWF visible (and to hide any other
loaded SWFs that are currently visible).

Here's the docco on using assets:
http://www.gaiaflashframework.com/wiki/index.php?title=Assets#How_To_Use
_Assets

Probably the most useful and important thing to know is that once your
SWF assets are loaded, they're positioned at 0,0 and their 'visible'
property is set to false. To display them, all you need to do is set the
'visible' property to true.

And assuming that 'captions' means a single text title for each asset,
you can place this info in an attribute of the asset node in Gaia, like
this:

asset id=mySWF src=something.swf caption=Insert Caption/

...and then access this XML via E4X by using the 'node' property of the
asset, like this:

assets.mySWF.node.@caption

...and use that to populate a textfield. Keeping the caption in the XML
means you can easily change the SWF as well as the caption without
needing to recompile anything later.

Hope that helps,
C:





 


RE: [Flashcoders] Loader Max Question

2011-03-23 Thread Chris Foster
Hi Marco,

Nice work so far!  OK, my first suggestion would be that you register
for the Gaia forum and post this kind of question there. Most of what
you're asking about here relates to best practices for working within
Gaia (with a little crossover into plain ol' AS3 knowledge). The folks
on the forum are very helpful with this kind of 'how should I be doing
this?' question.

That being said, I *think* what you want to do is treat each jpeg asset
as a Gaia 'BitmapSpriteAsset' - This next bit is straight from the Gaia
docs:

---
BitmapSpriteAsset (AS3 only)

This is a version of the BitmapAsset that you can add interactivity to
because BitmapSpriteAssets are wrapped inside a Sprite container, and
the asset provides a proxy to the Sprite methods. Set the type=sprite
in the asset node to turn a BitmapAsset into a BitmapSpriteAsset.

import com.gaiaframework.api.IBitmapSprite;
//
IBitmapSprite(assets.myBitmap).buttonMode = true;
IBitmapSprite(assets.myBitmap).addEventListener(MouseEvent.CLICK,
onClickBitmap);

---

Then you can easily create your own container MovieClip, reparent the
jpeg asset (because you can now treat it as a Sprite) into your new
MovieClip, create a textfield in your MovieClip, and create any
interactivity (via Sprite events like ) and tweening you want. Here's an
example of how to add the interactivity you want to the loaded image
(which is now treated as a Sprite)

---
public var loadedImage:BitmapSpriteAsset = new BitmapSpriteAsset();
loadedImage.addEventListener(MouseEvent.MOUSE_OVER,
myMouseOverEventHandler)
--

To access linkURL and caption attributes in yoru asset XML I think you
need your XML asset node to look like this:
asset id=myAssetID src=myAsset.jpg type=sprite
linkURL=http://www.random.com; caption=Caption text for my loaded
image/

...and in your Design.as where you have the line:
myBitmap = IBitmap(assetArray[i]).content;

you *should* be able to access the 'linkURL' and 'caption' attributes of
the node something like this:
var caption:String = assetArray[i].node.@caption

I'm a little fuzzy on the specific syntax, but I now you can definitely
access the XML content of your 'assets' XML, so try searching the Gaia
forums if my suggestion doesn't work immediately.

Hope that's some help...
C:



-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Marco
Terrinoni
Sent: Thursday, 24 March 2011 3:42 AM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] Loader Max Question

Many thanks for the tip Chris, I decided to try and load the assets via
an
external xml file as jpgs  instead of swfs to make the application as
scalable as possible without having to recompile anything as suggested.
I
still have some way to go, I've got the jpgs loading and positioned
where I
want them on the stage but am still struggling to:

 

a) Convert the bitmap to a movieclip - and reference 'linkURL' attribute
in
the xml file

b) add captions - I have two lines that need to be added, one for the
title,
another for the date. 

 

I have followed the advice in the Gaia documentation - loading the
assets
xml file into the index page in the site.xml file with the following
code in
my index.as

 

var assetNodes:XMLList =
IXml(assets.projectAssets).xml.asset;

var
designPage:IPageAsset =
Gaia.api.getPage(index/nav/design);

 
Gaia.api.addAssets(assetNodes, designPage);

TweenMax.to(this, 0.3,
{alpha:1, onComplete:transitionInComplete});

}

 

Then In my design.as file



}

override public function
transitionIn():void


{

super.transitionIn();

TweenMax.to(this, 0.3, {
alpha:1, onComplete:transitionInComplete } );

var assetArray:Array = page.assetArray;

var len:int =
assetArray.length;

for (var i:int = 0; i 
len;
i++)





{

trace(assetArray[i]);

myBitmap =
IBitmap(assetArray[i]).content;

myBitmap.visible = true;

myBitmap.x=(i % 4) *
240; 

myBitmap.y = int(i / 4)
*
180 + 60;