Link to home
Start Free TrialLog in
Avatar of Gavyn_Elrick
Gavyn_ElrickFlag for Canada

asked on

How do I get the contents of a TileList box that is selected to appear in a MovieClip on the stage?

I currently have a TileList which is populated from an external XML file (works perfectly)

I have a MovieClip which uploads an external SWF into it (works perfectly)

The uploaded SWF has a MovieClip in it which i am using as a place holder for another image which gets uploaded and place inside it. (works perfectly)

I have added googles Drag and Drop code for TileList components to give it a nice play feel, however I wish to be able to drag an image off the TileList and onto this buried MovieClip.

I am completely at a lose on how to call the selecteditem from the tilelist as the code is all in an external as (class), I figured maybe if i can send a variable or trigger a function from the class to a function in the flash file... but nothing i do works.

Even if I can just drag the selecteditem to a non dynamically created movieclip on the stage and have it populate the movieclip on the stage I should be able to continue from there.
Avatar of blue-genie
blue-genie
Flag of South Africa image

Hi, I don't think you can actually drag an item out of a TileList.
are you not happy with simply if the user clicks on one of those images in the TileList, that image gets loaded into the clip in quesiton?
Avatar of Gavyn_Elrick

ASKER

that would be great if i could get that working i could change it to work with the drag and drop... and you should look up... wait i will send you the link

http://code.google.com/p/as3-drag-and-drop-tilelist/

thats for tilelist drag and drop.

But if you can help me with the click i would be greatful either way
I have also seen my idea already used sadly... so i know you can do what i am trying to accomplish. I can send you the link as well for that if you'd like to check it out.

P.S. I find with EE it takes forever to solve a problem cause maybe online one message gets replied too a day... is there a time maybe this weekend if possible I can connect online with you... or someone... and throw some ideas against the wall, if anyone has an interest in solving this of course.

Figure I am missing something simple or over looking something... TileList's are the bane of my existence.

I know also that EE would like us to show how we worked out our solution to help others. Well I would be glad to document how we accomplished and add it to this blog for others. But just to speed things up I would like to take it off EE and onto a faster form of communication.
i have no idea how to do the drag and drop with a tile list.
will give it a try and if i find a solution will let you know.
in terms of the other option, simply use an eventlistener to get the clicked on item

off the top of my head the syntax looks something like this (confirm in help file)
tilelist.addEventListener(MouseEvent.Click, blah);
function blah(e:Event) {
trace(e.target.content.selectedItem.label);//or whatever you called it to set the tilelist items.
//use that value to load the selected image into your required target
}


well ya i know how to use eventlisteners they are swarming through out my program.

but the selectedItem function doesn't work if its not in a class... and if its in a class i can not seem to be able to call the movieclip on the stage. Cause it was created outside the class.
p.s.

tilelist.addEventListener(MouseEvent.Click, blah);

is actually

tilelist.addEventListener(MouseEvent.CLICK, blah);

it has to be capitalized
here is the error your code gives me

ReferenceError: Error #1069: Property content not found on fl.controls.listClasses.ImageCell and there is no default value.

which is the same thing when i used it with out content

trace(e.target.selectedItem.label);

ReferenceError: Error #1069: Property selectedItem not found on fl.controls.listClasses.ImageCell and there is no default value.

so ya thats were i am at your almost catching up...

i believe...

e.target.selectedItem.label

can only be called or used inside the class... which as i mentioned... if i do that and then try and even do a call to

trace(stage.castingImage);

which is the name of the movieclip on the stage...

it errors

1119: Access of possibly undefined property castingImage through a reference with static type flash.display:Stage.

were to go from here
I'm sorry that was wrong of me

trace(stage.castingImage);  isn't corrent

trace(castingImage);   is...

outside the Class... in the FLA.. this is what trace's

[object castingImage_mc_18]

inside the Class of the Tilelist... this is what trace's

1120: Access of undefined property castingImage.

so i am not sure how i can call the movieclip cause the name...

tilelist.selectedItem.label

only works in the class and

i can only call the movieclip (castingImage) in the FLA...

*head is spinning i mustn't be doing something right
i did mine in a simple unnamed package.

whichever class you created your tileList in, that's where you're doign the event listener and getting the image selected yes.
and you should only be listening after your tilelist is populated in order for there not to be the dreaded null reference error.
what is castingImage?

how big are all your packages, zip it up if you can lets have a look.
sounds good let me get onto it i need to trim it abit will take me a bit and i will have it upload for you to check out.

Thank you!
Files that need renaming

castingImage.txt    =    castingImage.swf
dd_tile_list.txt        =    dd_tile_list.as
example.txt           =    example.xml
tilelist.txt                =    tilelist.fla


and all should work as intended so far.

Thanks again for taking a look at this
example-tilelist.zip
ok i've downloaded everything but so far i'm not getting any compile or run time errors though the file is flashing like crazy.
will have a look through the day and get back to you.
i'm missing something. tileList don't load.
let me review it i am very sorry thought it worked out on my end might have missed something
hmmm well it runs on my end i will rezi pand upload again... remember you have to have all the renamed files renamed back to the .as .fla .swf .xml that there were ment to be...

lets give it another shot

there are three of the renaming files in the first directory... the last one is buried in the com/jeremyrodgers directory

tilelist-example.zip
cool working now the previous one didn't have anything in the com/jeremyrodger dir.
i'm on it.will let you know.
the drag and drop thing needs to be looked at when i'm a bit more awake.
doing a normal  click and release  i can pull the contents of the item i clicked on.

i.e. images/f13.jpg

but i can't get this to trigger when i stop dragging, so maybe my event listener is conflicting with one of the other ones.
i also can't pull your castingImage movieclip off the stage. Maybe because its not a class that extends a displayObject. and you don't have a document class.
not sure.
when doing the hit test to see if the object was dropped onto the clip i keep getting this. does it mean anything to you?
[object castingImage_mc_1]

so when i drag it anywhere on the stage returns me a true - anywhere off the blue area, returns false.

will look at this drag and drop thing a little closer.
In reply:

i also can't pull your castingImage movieclip off the stage. Maybe because its not a class that extends a displayObject. and you don't have a document class.

-- I dont understand what your trying to do with this one. The castingImage movieclip is just there to load the external clip into... its sort of a casting couch for those members i wish to change. Its main purpose is to show like i said who customizable members, and you drag an image from the tilelist onto the castingimage which in the end will replace that image then i send that info to my server to save. Which the sending info to the server i have covered... the program is much bigger then this one little file i just removed the rest as it isn't important to my problem at hand.

when doing the hit test to see if the object was dropped onto the clip i keep getting this. does it mean anything to you?

[object castingImage_mc_1]

-- this is a trace(castingImage); statement to show i have mouse_over the buttom right head... all heads are suppose to have this but thats a simple copy and paste once i get this working right.

so when i drag it anywhere on the stage returns me a true - anywhere off the blue area, returns false.

will look at this drag and drop thing a little closer.

thanks again for sticking with me
ASKER CERTIFIED SOLUTION
Avatar of Gavyn_Elrick
Gavyn_Elrick
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial