Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

actionscript for List component

Guest
Sep 14, 2010 Sep 14, 2010

I'm trying to develop a glossary for a training course, and I've got my list component set up with all of my terms.  Now I need to program it so when the user clicks on a term, the definition pops up.  I thought there was a way to do this, but my book doesn't go into that much detail.

can anyone help?  Here is actionscripting that I found online, but it mentioned that it may not work with Actionscript 3.

import fl.controls.List;
import fl.controls.TextArea;
import flash.events.Event;
import fl.data.DataProvider;

var Glossary:List = new List();
var Definition_Text:TextArea = new TextArea();
var items:Array = [
{label:"AbbrDial", data:"Abbreviated Dialing allows you to speed-dial an index number."},
{label:"Answer", data:"Allows you to answer a call."},
{label:"Back", data:"Allows you to return to the previous Help topic."},
{label:"Barge", data:"Allows you to add yourself to a call on a shared line."},
{label:"CallBack", data:"Allows you to receive notification when a busy extension becomes available."},
];
Glossary.dataProvider = new DataProvider(items);

addChild(Glossary);
addChild(Definition_Text);

Glossary.move(150,150);
Definition_Text.move(150, 260);

Glossary.addEventListener(Event.CHANGE, changeHandler);

function changeHandler(event:Event):void {
    Definition_Text.text = event.target.selectedItem.data;
};

TOPICS
ActionScript
2.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 14, 2010 Sep 14, 2010

You don't need to build any components, just have them in the library.  The code does all the work for you.

Open a new file... copy the code you posted to frame 1 of that file's timeline... go into the components library and drag an instance of the List component onto the stage and then delete it... go into the components library and drag an instance of the TextArea component onto the stage and then delete it... run the file.

Translate
LEGEND ,
Sep 14, 2010 Sep 14, 2010

That code works fine.  You need to make sure you have the two components in your library for it to work.  To get them in the library just drag an instance of each one from the components library onto the stage.  Then you can delete them from the stage since your code will add them dynamically from the library.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 14, 2010 Sep 14, 2010

it's not working.  I can't imagine the endless possibilities of what I'm doing wrong as I'm sure there are several.  I built the components firsts, named them, put in all of the data for the terms and definitions.  then went back and did the actionscripting.  should I have done it a different way?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2010 Sep 14, 2010

You don't need to build any components, just have them in the library.  The code does all the work for you.

Open a new file... copy the code you posted to frame 1 of that file's timeline... go into the components library and drag an instance of the List component onto the stage and then delete it... go into the components library and drag an instance of the TextArea component onto the stage and then delete it... run the file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 14, 2010 Sep 14, 2010

It worked!!  Thanks Ned!  Now is there any way to make the text box bigger?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 14, 2010 Sep 14, 2010

Anytime you wonder how you can implement things you should look them up in the Flash help documentation. Display objects have properties, methods, and events that are all explained in the help docs.

In your case, you are wondering about the width and height properties...

var Definition_Text:TextArea = new TextArea();
Definition_Text.width = 300;
Definition_Text.height = 100;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 14, 2010 Sep 14, 2010

Thanks Ned.

Date: Tue, 14 Sep 2010 12:31:08 -0600

From: forums@adobe.com

To: melinda_smith3@hotmail.com

Subject: actionscript for List component

Anytime you wonder how you can implement things you should look them up in the Flash help documentation. Display objects have properties, methods, and events that are all explained in the help docs.

In your case, you are wondering about the width and height properties...

var Definition_Text:TextArea = new TextArea();

Definition_Text.width = 300;

Definition_Text.height = 100;

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 15, 2010 Sep 15, 2010

Ned, I took your advice and looked up what I needed in the Flash Help documents.  I found out how to edit the size of my project, however, for some reason when I edit my stage size to be the size of my components, it cuts off my components.  I can't figure about how to relocate my compents on the stage.

I tried using the same action scripting you gave me to resize the components, but it didn't work.  This is what I tried:

Definition_Text.X= 44.4;Definition_Text.Y= 126.3;   the progrnam won't recognize X and Y. Any suggestions?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 15, 2010 Sep 15, 2010

Case matters... x and y

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 17, 2010 Sep 17, 2010

Holy crap I was right?

Date: Wed, 15 Sep 2010 13:35:21 -0600

From: forums@adobe.com

To: melinda_smith3@hotmail.com

Subject: actionscript for List component

Case matters... x and y

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 17, 2010 Sep 17, 2010

Man....Ned, it's still not working.  Who knows what I'm doing wrong.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 17, 2010 Sep 17, 2010

Only you will know unless you share your complete code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 20, 2010 Sep 20, 2010

Yeah...I guess my code would be helpful wouldn't it?

Here it is:

import fl.controls.List;
import fl.controls.TextArea;
import flash.events.Event;
import fl.data.DataProvider;

var Glossary:List = new List();
var Definition_Text:TextArea = new TextArea();
Glossary.x= 27.3;Definition_Text.y= 18.4
Definition_Text.width = 200;Definition_Text.height = 55;
Definition_Text.x= 44.4;Definition_Text.y= 126.3
var items:Array = [
{label:"AbbrDial", data:"Abbreviated Dialing allows you to speed-dial an index number."},
{label:"Answer", data:"Allows you to answer a call."},
{label:"Back", data:"Allows you to return to the previous Help topic."},
{label:"Barge", data:"Allows you to add yourself to a call on a shared line."},
{label:"CallBack", data:"Allows you to receive notification when a busy extension becomes available."},
{label:"Cancel", data:"Allows you to cancel an action or exit a screen without applying changes."},
{label:"cBarge", data:"Conference Barge allows you to add yourself to a call on a shared line and establish a conference call."},
{label:"CFwdALL", data:"Call Forward All allow you to set up or cancel call forwarding."},
{label:"Clear", data:"Allows you to delete records or settings."},
{label:"Close", data:"Allows you to close the current window."},
{label:"ConfList", data:"Conference List allows you to view a list of conference participants."},
{label:"Confrn", data:"Conference allows you to create a conference call."},
{label:"Delete", data:"Allows you to remove characters to the right of the cursor when using EditDial."},
{label:"Details", data:"Allows you to open the Details record for a multiparty call in the Missed and Received Calls logs."},
{label:"Dial", data:"Allows you to dial an entered phone number."},
{label:"DirTrfr", data:"Direct Transfer allows you to transfer two calls to each other."},
{label:"EditDial", data:"Allows you to edit a number in a call log."},
{label:"EndCall", data:"Allows you to disconnect the current call."},
{label:"Erase", data:"Allows you to reset settings to their defaults."},
{label:"Exit", data:"Allows you to return to the previous screen."},
{label:"GPickUp", data:"Group Pick Up allows you to answer a call on an extension outside your group."},
{label:"iDivert", data:"Immediate Divert allows you to send a call to your voice message system."},
{label:"Join", data:"Allows you to join several calls on a single line to create a conference call."},
{label:"Links", data:"Allows you to access related Help topics."},
{label:"Main", data:"Allows you to display the Help main menu."},
{label:"Meet-Me", data:"Allows you to host a Meet-Me conference call."},
{label:"More", data:"Allows you to display additional softkeys."},
{label:"NewCall", data:"Allows you to make a new call."},
{label:"OPickUp", data:"Other Group Pick Up allows you to answer a call ringing in another goup that is associated with your group."},
{label:"Park", data:"Allows you to store a call using Call Park."},
{label:"PickUp", data:"Allows you to answer a call on another extension in your group."},
{label:"QRT", data:"Quality Reporting Tool allows you to submit call problems to the system administrator."},
{label:"Redial", data:"Allows you to redial the most recently dialed number."},
{label:"Remove", data:"Allows you to remove a conference participant."},
{label:"Resume", data:"Allows you to resume a call that is currently on hold."},
{label:"RmLstC", data:"Remove Last Conference Participant allows you to drop the last party added to a conference call."},
{label:"Save", data:"Allows you to save the chosen settings."},
{label:"Search", data:"Allows you to search for a directory listing."},
{label:"Select", data:"Allows you to select a menu item or a phone call."},
{label:"Trnsfer", data:"Transfer allows you to transfer a call."},
{label:"Update", data:"Allows you to refresh content and get the latest information."},
{label:"VidMode", data:"Video Mode allows you to choose a video display mode for a video conference."},
];
Glossary.dataProvider = new DataProvider(items);

addChild(Glossary);
addChild(Definition_Text);

Glossary.move(150,150);
Definition_Text.move(150, 260);

Glossary.addEventListener(Event.CHANGE, changeHandler);

function changeHandler(event:Event):void {
    Definition_Text.text = event.target.selectedItem.data;
};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2010 Sep 20, 2010

It should work just fine if you leave it alone... but later on in the code you move it elsehwre..

Definition_Text.move(150, 260);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 20, 2010 Sep 20, 2010

OH!  I didn't even see that down there!  Thanks Ned!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2010 Sep 20, 2010
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines