Adobe Dreamweaver Forums



Last 10 THreads :         beginner issues (Last Post : whatisgood - Replies : 3 - Views : 4 )           »          WebHelp Compile Won't Display (Last Post : thegup55 - Replies : 2 - Views : 5 )           »          NetStream.time Inconsistent (Last Post : Semon Seos - Replies : 1 - Views : 2 )           »          Flash media Encoder can't set FPS (Last Post : Semon Seos - Replies : 4 - Views : 26 )           »          Adding buttons to a flipbook (Last Post : Semon Seos - Replies : 13 - Views : 25 )           »          Flash Website (Last Post : Semon Seos - Replies : 2 - Views : 5 )           »          Browser buttons (Last Post : Semon Seos - Replies : 3 - Views : 14 )           »          Course completion not registering in LMS (Last Post : Semon Seos - Replies : 1 - Views : 4 )           »          Keyboard Event problems (Last Post : jwlagina - Replies : 0 - Views : 1 )           »          Keyframes Ignored by AS3 (Last Post : NedWebs - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags: , , ,



Reply
  #1 (permalink)  
Old 09-05-2008, 09:11 PM
Epharian
 
Posts: n/a
Diggs:
Default How to use an Embedded Image in an arrray?

ACK!

Okay, I'm a moderately experience php coder, but pretty new to flex and
actionscript in general.

I have an application where I need to load a series of images and embed them
into the application (not at runtime), then have them accessible in an array so
that I can work through them later on in a reasonable fashion (I'm displaying
them to the user of the application multiple times, and perhaps
randomly--having them in the array is the BEST way to do this, but I need it to
be embedded since there won't need to be that many images).

What I'm having trouble with is this:

My code simply doesn't seem to work the way I think it should. The listed
code doesn't actually seem to load the images INTO the array. What am I doing
wrong?

Thanks for the help, and please let me know.






[Embed(source="avatar2.jpg")]
[Bindable]
public var img:Class;
[Embed(source="pic.gif")]
[Bindable]
public var img2:Class;
public var pics:Array = new Array(img, img2);



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-05-2008, 09:40 PM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: How to use an Embedded Image in an arrray?

This seems to work:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Embed(source="avatar2.jpg")]
[Bindable]
public var img:Class;

[Embed(source="pic.gif")]
[Bindable]
public var img2:Class;

public var pics:Array = new Array(img, img2);
]]>
</mx:Script>
<mx:Image id="image" source="{pics[0]}"/>
<mx:Button label="avatar2" click="image.source=pics[0]"/>
<mx:Button label="pic" click="image.source=pics[1]"/>
</mx:Application>

Reply With Quote
  #3 (permalink)  
Old 09-08-2008, 02:01 PM
Epharian
 
Posts: n/a
Diggs:
Default Re: How to use an Embedded Image in an arrray?

[q]Originally posted by: Greg Lafrance
This seems to work:[/q]


That's helpful--so I know that I'm approximating the right method for setting
up the array. The only question then remains--what's going wrong with the rest
of the code? Because this provides a blank page except for the labels (Thanks
in advance):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
[Embed(source="avatar2.jpg")]
[Bindable]
public var img:Class;
[Embed(source="pic.gif")]
[Bindable]
public var img2:Class;
public var pics:Array = new Array(img, img2);

]]>
</mx:Script>
<mx:Grid x="10" y="10" width="100%" height="383">
<mx:GridRow width="100%" height="100%">
<mx:GridItem width="100%" height="100%">
<mx:Label
text="Bad"
width="103"
height="32"
id="TopLeft"
enabled="true"
fontWeight="bold"
color="#0B333C"
fontSize="20"/>
</mx:GridItem>
<mx:GridItem width="100%" height="60">
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label
text="Good"
width="100%"
height="32"
id="TopRight"
enabled="true"
fontSize="20"
color="#0B333C"
fontWeight="bold"
textAlign="right"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="32">
<mx:GridItem width="100%" height="100%">
<mx:Label
text=""
id="BottomLeft"
enabled="false"
fontSize="20"
color="#0B333C"
fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%" label="Hello">
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Label
text=""
id="BottomRight"
width="100%"
enabled="false"
fontWeight="bold"
color="#0B333C"
fontSize="20"
textAlign="right"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="299">
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
<mx:Image
source="{pic[0]}"
id="pic"
width="250"
autoLoad="true"/>
</mx:GridItem>
<mx:GridItem width="100%" height="100%">
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:Application>



Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:02 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk