Alex,

In addition to my earlier reply:

Alex,

I'm not quite sure what to say...

1. I don''t receive any errors,

2. there is a button visually displayed, but it does nothing.


I thought I should add the following...

As I mentioned in my original post (it was near the very bottom) I have
2 functions in the script block, one of which needs to be run upon
initialization. I am wondering if I need to put these functions into and
Actionscript class file (??) What do you think? I am very new to this.
If I do put these functions in their own AS file how (where) do I call
the function(s) to initialize it (them)?

Again, many thanks,

Tex


--- In [email protected], Alex Harui <aha...@...> wrote:
>
> Please explain what errors you are getting or what isn't working.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: [email protected] [mailto:[email protected]]
On Behalf Of tex_learning_flex
> Sent: Friday, November 13, 2009 6:25 PM
> To: [email protected]
> Subject: [flexcoders] my first Custom Component is not working
>
>
> I created a menubar in my main.mxml file and it works just fine.
>
> I next created a custom mxml component file where I moved the code,
and this is where I am having trouble.
>
> My original code (while in my main.mxml) looked like this:
>
> <mx:MenuBar
>     labelField="@label"
>     itemClick="menuHandler(event);"
>     id="menuBarButton"
>     dataProvider="{menuBarCollection}"
> />
>
>
> with the following excerpted from the script block:
>
> <mx:Script>
>     <![CDATA[
>
> import mx.collections.*;
> import mx.controls.Alert;
> import mx.controls.MenuBar;
> import mx.controls.menuClasses.IMenuBarItemRenderer;
> import mx.controls.menuClasses.MenuBarItem;
> import mx.events.MenuEvent;
>
>
> [Bindable]
>         public var ! menuBarCollection:XMLListCollection;
>
>             public var menubarXML:XMLList =
>                 <>
>                     <menuitem label="Menu bar" data="top">
>                         <menuitem label="Selection A" type="check"
data="A"/>
>                         ! <menuitem label="Selection B" type="check"
data="B"/>
>                         <menuitem label="Selection C" type="check"
data="C"/>
>                     </menuitem>
>                 </>;
>
>             // Event handler to initialize the MenuBar control.
>
>             public function initCollections():void
>             {
>                 menuBarCollection = new XMLListCollection(menubarXML);
>             }
>
>             /// Event handler for the MenuBar control's itemClick
event.
>
>             public function menuHandler(event:MenuEvent):void
>             {
>             // Don't open the Alert for a menu bar item that
>             // opens a popup submenu.
>                 if (event.it...@data != "top")
>                 {
>                     Alert.show("Label: " + event.it...@label + "\n" +
"Data: " + event.it...@data, "Clicked menu item");
>                 }
>             }
>
>     ]]>
> </mx:Script>
>
>
> I moved the above to its' own .mxml file and added the following line
to main.mxml header data:
>
>     xmlns:comp="components.*"
>
> in order to access the new component file.
>
> I now placed the following line! in place of the green< /font> code
above:
>
> <comp:MenuBar />
>
> I'm thinking that the problem lies in accessing the initCollections()
or the menuHandler(event:MenuEvent) functions, but I don't know if that
is the problem or, more importantly,  how to get past it if it is...
>

Reply via email to