Pages: [1]
  Print  
Author Topic: Using Pages Twice and Assets  (Read 571 times)
lframnes
Gaia Novice
*
Posts: 5


« on: February 01, 2010, 08:32:44 AM »

I'm having some trouble accessing assets and I'm not sure what I'm missing, perhaps I'm doing things unconventionally.  I have a Gaia site where I use one "page" in two places in the site XML.  This is because I want this page to appear on top of two different pages, so in my site XML I have this...

     <page id="index" src="index.swf" >
   <page id = 'nav" src = "nav.swf">
      <page id = "home" src = "home.swf" landing = "true">
         <page id = "content" src = "content.swf"/>
      </page>
      <page id = "page2" src = "page2.swf" landing = "true">
         <page id = "content" src = "content.swf"/>
      </page>
   </page>
   </page>

Now everything loads correctly, when I load the two instances of the content page.  The problem I'm having is with assets.  I'd like the "content.swf" pages to use jpg assets that are attached to the nav page.   This works fine when I access them via the content page under "home" but it does not work when I access them via the content page under "page2".  When I try to access them under page two I can trace the output and it shows I have a BitmapAsset asset, but if I try to access the loader property and add it to the stage I get an error saying that property must be non-null, same thing occurs if I try to get the bitmap data and make a new bitmap.

Is there something I'm missing?  How can I use the assets just fine under "home" but not under "page2"?

 
      
Logged
Nemo
Community Leader
Gaia Guru
*****
Posts: 449



WWW
« Reply #1 on: February 01, 2010, 01:34:27 PM »

not unconventionally, typical Wink

I use this solution also many times.

I don't know for shore, and I don't have how to check it right now, but I think your asset is empty because you attach it to subpage, so assets['your bitmap'] is empty after visit first content page.
So you probably need to make a copy of your bitmap and not "grab it".

Quote
How can I use the assets just fine under "home" but not under "page2"?
Just check currentBranch in content page and and get bitmap or skip
Logged

lframnes
Gaia Novice
*
Posts: 5


« Reply #2 on: February 01, 2010, 02:47:29 PM »

Well that's what's weird.  When I check assets['my bitmap'] it tells me I have a bitmapAsset and it gives the correct ID and everything, just when I try to attach it to the content page I am unable to access the loader or bitmap data of it.

When you say "copy" the bitmap, what do you mean?  Is there a way to duplicate the bitampAsset?

Logged
Ramiro
Community Leader
Gaia Addict
*****
Posts: 520


interactive pragmatism


« Reply #3 on: February 01, 2010, 05:58:13 PM »

you cannot simply "copy" a DisplayObject. In the Bitmap type scenario, you can however access its bitmapData property and use it's clone method to copy the actual pixels. Then you can create a new Bitmap instance and use the cloned BitmapData on it.

In AS2 you had the duplicateMovieClip method. In AS3 there's no such thing, and for example duplicating a movieclips involves linking it with a custom class, creating a new instance and copying each property. Since the Bitmap object basically contains a bitmap, you can do what I described above, but if the original Bitmap has properties like position, scale, rotation, alpha, filters, etc applied, you'll have to manually place them in the new Bitmap.
« Last Edit: February 01, 2010, 06:02:31 PM by Ramiro » Logged
lframnes
Gaia Novice
*
Posts: 5


« Reply #4 on: February 01, 2010, 08:16:20 PM »

Thanks for your help everything is working great now!
Logged
steven
Gaia Author
Administrator
Gaia Evangelist
*****
Posts: 3472


gaiaframework
WWW
« Reply #5 on: February 01, 2010, 10:21:23 PM »

What I would do is assign a class to the MovieClip (or Sprite and extend it), and write a public function inside it called clone() and have it copy all the props of the MovieClip into a new clip and return it.
Logged

Steven Sacks | Gaia Author
Please support Gaia by donating to the project!  Smiley
c++
Gaia User
**
Posts: 26


« Reply #6 on: February 08, 2010, 04:06:23 PM »

On the matter of cloning display objects... Here is an interesting link:

http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/display/duplicateDisplayObject.as

best
c++
Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc