Loading ...
Sorry, an error occurred while loading the content.

RE: [flexcoders] Variable Despair - Please Help

Expand Messages
  • Robert Stuttaford
    Ah, yes, okay. You need to place all that code inside a function which you bind to the Application tag s initialize handler. So:
    Message 1 of 5 , Jan 1, 2005
    • 0 Attachment
      Ah, yes, okay. You need to place all that code inside a function which you
      bind to the Application tag's initialize handler. So:

      <?xml version="1.0" encoding="utf-8"?><!-- width="590" height="400" -->
      <mx:Application initialize="initHandler()">

      <mx:Script>
      <![CDATA[

      function initHandler () {

      // code
      }

      ]]>
      </mx:Script>
      </mx:Application>

      The reason for this is because MXML files are converted to Actionscript 2.0
      classes behind the scenes.


      -----Original Message-----
      From: Chris Phillips [mailto:cfchris@...]
      Sent: 31 December 2004 09:13 PM
      To: flexcoders@yahoogroups.com
      Subject: Re: [flexcoders] Variable Despair - Please Help


      Ok,

      I fixed that, but I'm still getting this error. (with line 11 highlighted)

      Error /FlexTests/photoGallery.mxml:11
      This statement is not permitted in a class definition.


      10: var media:Object = new Object();
      11: media.evoxMedia = new Object();
      12: media.evoxMedia.folder = "1519";



      On Fri, 31 Dec 2004 21:06:25 +0200, Robert Stuttaford
      <robert@...> wrote:
      > It's the new Array([]) syntax. You can either do
      >
      > var X : Array = new Array( "1", "2" );
      >
      > or just simply
      >
      > var X : Array = [ "1", "2" ];
      >
      > Saying it twice in one go confuses the parser :)
      >
      >
      > -----Original Message-----
      > From: Chris Phillips [mailto:cfchris@...]
      > Sent: 31 December 2004 08:59 PM
      > To: Flex Coders
      > Subject: [flexcoders] Variable Despair - Please Help
      >
      > I'm new to Flash.
      > I'm trying desperately to learn how to use actionscript, but I just
      > can't get this to work.
      > I've read the documentation and I've tried every combination I can think
      > of.
      >
      > I know it's a simple thing, but could somebody tell me why this code
      won't
      > work.
      > Please.
      > I just keep getting syntax errors trying to build my data.
      > It's only mock up data. I wanted to be able to develop this piece
      > seperately.
      >
      >
      > <?xml version="1.0" encoding="utf-8"?><!-- width="590" height="400" -->
      > <mx:Application width="585" height="475"
      >
      > xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
      > marginTop="0" marginLeft="0" marginRight="0"
      > marginBottom="0"
      > backgroundColor="#FFFFFF"
      > themeColor="haloBlue">
      >
      > <mx:Script>
      > <![CDATA[
      >
      > var media:Object = new Object();
      > media.evoxMedia = new Object();
      > media.evoxMedia.folder = "1519";
      > media.evoxMedia.images = new Array(["037", "039", "040", "041",
      > "042", "043", "044", "045", "046", "047", "048", "049", "050", "051",
      > "054", "055", "056", "057", "059", "061", "062", "063", "064", "065",
      > "066", "077", "087", "088", "089", "090"]);
      >
      > function photoURL(photo:Number) {
      > var url:String = '';
      > // images names look like "1519_st0320_037.jpg"
      > url = 'http://chris.dealerpeak.com/EVOX/' +
      > media.evoxMedia.folder +
      > '/' + media.evoxMedia.folder + '_st0320_' + photo + '.jpg';
      > return url;
      > }
      > ]]>
      > </mx:Script>
      >
      > <mx:VBox label="Gallery" width="100%" height="100%">
      > <mx:Tile width="100%" height="100%" marginTop="10" marginLeft="10"
      > marginBottom="10" verticalGap="10" horizontalGap="10">
      > <mx:Repeater id="photos"
      > dataProvider="{media.evoxMedia.images}">
      > <mx:Image width="100" height="75"
      > maintainAspectRatio="true"
      > source="{photoURL(photos.currentItem)}" />
      > </mx:Repeater>
      > </mx:Tile>
      > </mx:VBox>
      >
      > </mx:Application>
      >
      > --
      > Chris Phillips
      > www.dealerpeak.com
      > Senior Application Developer
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Sponsor
      >
      > ADVERTISEMENT
      >
      >
      > ________________________________
      > Yahoo! Groups Links
      >
      > To visit your group on the web, go to:
      > http://groups.yahoo.com/group/flexcoders/
      >
      > To unsubscribe from this group, send an email to:
      > flexcoders-unsubscribe@yahoogroups.com
      >
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      --
      Chris Phillips
      www.dealerpeak.com
      Senior Application Developer




      Yahoo! Groups Links
    • Chris Phillips
      Ok, Will do. Thank you so much! Like I said I m trying really hard to learn, but all of this OO stuff is new to me. Now that you explained it, I get it. Chris
      Message 2 of 5 , Jan 1, 2005
      • 0 Attachment
        Ok,

        Will do.
        Thank you so much!
        Like I said I'm trying really hard to learn, but all of this OO stuff
        is new to me.
        Now that you explained it, I get it.

        Chris P.



        On Sat, 1 Jan 2005 11:41:05 +0200, Robert Stuttaford
        <robert@...> wrote:
        > Ah, yes, okay. You need to place all that code inside a function which you
        > bind to the Application tag's initialize handler. So:
        >
        > <?xml version="1.0" encoding="utf-8"?><!-- width="590" height="400" -->
        > <mx:Application initialize="initHandler()">
        >
        > <mx:Script>
        > <![CDATA[
        >
        > function initHandler () {
        >
        > // code
        > }
        >
        > ]]>
        > </mx:Script>
        > </mx:Application>
        >
        > The reason for this is because MXML files are converted to Actionscript 2.0
        > classes behind the scenes.
        >
        >
        >
        > -----Original Message-----
        > From: Chris Phillips [mailto:cfchris@...]
        > Sent: 31 December 2004 09:13 PM
        > To: flexcoders@yahoogroups.com
        > Subject: Re: [flexcoders] Variable Despair - Please Help
        >
        >
        > Ok,
        >
        > I fixed that, but I'm still getting this error. (with line 11 highlighted)
        >
        > Error /FlexTests/photoGallery.mxml:11
        > This statement is not permitted in a class definition.
        >
        >
        > 10: var media:Object = new Object();
        > 11: media.evoxMedia = new Object();
        > 12: media.evoxMedia.folder = "1519";
        >
        >
        >
        > On Fri, 31 Dec 2004 21:06:25 +0200, Robert Stuttaford
        > <robert@...> wrote:
        > > It's the new Array([]) syntax. You can either do
        > >
        > > var X : Array = new Array( "1", "2" );
        > >
        > > or just simply
        > >
        > > var X : Array = [ "1", "2" ];
        > >
        > > Saying it twice in one go confuses the parser :)
        > >
        > >
        > > -----Original Message-----
        > > From: Chris Phillips [mailto:cfchris@...]
        > > Sent: 31 December 2004 08:59 PM
        > > To: Flex Coders
        > > Subject: [flexcoders] Variable Despair - Please Help
        > >
        > > I'm new to Flash.
        > > I'm trying desperately to learn how to use actionscript, but I just
        > > can't get this to work.
        > > I've read the documentation and I've tried every combination I can think
        > > of.
        > >
        > > I know it's a simple thing, but could somebody tell me why this code
        > won't
        > > work.
        > > Please.
        > > I just keep getting syntax errors trying to build my data.
        > > It's only mock up data. I wanted to be able to develop this piece
        > > seperately.
        > >
        > >
        > > <?xml version="1.0" encoding="utf-8"?><!-- width="590" height="400" -->
        > > <mx:Application width="585" height="475"
        > >
        > > xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"
        > > marginTop="0" marginLeft="0" marginRight="0"
        > > marginBottom="0"
        > > backgroundColor="#FFFFFF"
        > > themeColor="haloBlue">
        > >
        > > <mx:Script>
        > > <![CDATA[
        > >
        > > var media:Object = new Object();
        > > media.evoxMedia = new Object();
        > > media.evoxMedia.folder = "1519";
        > > media.evoxMedia.images = new Array(["037", "039", "040", "041",
        > > "042", "043", "044", "045", "046", "047", "048", "049", "050", "051",
        > > "054", "055", "056", "057", "059", "061", "062", "063", "064", "065",
        > > "066", "077", "087", "088", "089", "090"]);
        > >
        > > function photoURL(photo:Number) {
        > > var url:String = '';
        > > // images names look like "1519_st0320_037.jpg"
        > > url = 'http://chris.dealerpeak.com/EVOX/' +
        > > media.evoxMedia.folder +
        > > '/' + media.evoxMedia.folder + '_st0320_' + photo + '.jpg';
        > > return url;
        > > }
        > > ]]>
        > > </mx:Script>
        > >
        > > <mx:VBox label="Gallery" width="100%" height="100%">
        > > <mx:Tile width="100%" height="100%" marginTop="10" marginLeft="10"
        > > marginBottom="10" verticalGap="10" horizontalGap="10">
        > > <mx:Repeater id="photos"
        > > dataProvider="{media.evoxMedia.images}">
        > > <mx:Image width="100" height="75"
        > > maintainAspectRatio="true"
        > > source="{photoURL(photos.currentItem)}" />
        > > </mx:Repeater>
        > > </mx:Tile>
        > > </mx:VBox>
        > >
        > > </mx:Application>
        > >
        > > --
        > > Chris Phillips
        > > www.dealerpeak.com
        > > Senior Application Developer
        > >
        > >
        > >
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        > >
        > >
        > >
        > > Yahoo! Groups Sponsor
        > >
        > > ADVERTISEMENT
        > >
        > >
        > > ________________________________
        > > Yahoo! Groups Links
        > >
        > > To visit your group on the web, go to:
        > > http://groups.yahoo.com/group/flexcoders/
        > >
        > > To unsubscribe from this group, send an email to:
        > > flexcoders-unsubscribe@yahoogroups.com
        > >
        > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >
        >
        > --
        > Chris Phillips
        > www.dealerpeak.com
        > Senior Application Developer
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > ________________________________
        > Yahoo! Groups Links
        >
        > To visit your group on the web, go to:
        > http://groups.yahoo.com/group/flexcoders/
        >
        > To unsubscribe from this group, send an email to:
        > flexcoders-unsubscribe@yahoogroups.com
        >
        > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        --
        Chris Phillips
        www.dealerpeak.com
        Senior Application Developer
      Your message has been successfully submitted and would be delivered to recipients shortly.