The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
We're doing a matching game for one of my classes, and one problem we're having is creating an image array to randomize the images. We're using Adobe Flex to do this. Anyway, we create an image array like this:
public function loadPics():void {
for (var i = 0; i < 10; i++) {
picArray[i] = new String("domino" + (i+1) + ".PNG");
}
}
the problem is that the "source" needs a string (it needs to be in quotations), and what this means is that when we pass it an array item, it thinks "picArray[0]" is the name of the image. What we need it to do is look at the string value in the picArray, and use that instead. Is their a way to do this?
{} will call for an object value, whereas without {} that means you are either referencing a string or a function name if you include () at the end.
Also consider embedding your domino pictures in the SWF so they load up on application init, instead of when they are "called" by the grid. That will make for a more responsive app, especially if it's being hosted online. Your teacher will give you bonus points!
Oh you would only do it bindable if you could specify it as a datasource for the control. Sorry, I deleted that part from my post after I read about the control. Doesn't look like you can bind to a Grid. Although that shouldn't stop it from working... but if you aren't binding it you may as well not add that.
Also, don't use getItemAt().. kinda pointless
picArray[0] should work fine and is faster.
If you do that, and it still doesn't show up, make sure your images are in the right place.. for Flex Builder, root directory is the same as your MXML file. Also try setting AutoLoad="true" on the image control tag.
hint
picArray[i] = new String("domino" + (i+1) + ".PNG");
is a bit overkill. Actionscript knows when you are doing a string, the same thing can be written
Still nothing :? Even with the images in the root folder and everything.
Thank you for the help, I'm probably on the right track but something small is getting in the way. I'll continue looking at it and ask around tomorrow and see what I can find.
Verify that creationComplete is actually firing when you want it to. I usually use the init event instead since I know that will fire before my control contents will be rendered.
It's possible that your image controls are being printed out, and they are getting empty strings as file paths because creationComplete is firing after they are created. Strings in AS3 are passed by value, not by reference, so if they aren't populated yet, you would get nothing.
Unless there's a good reason, you should be just populating that array on application init, not on control init.
Posts
{} will call for an object value, whereas without {} that means you are either referencing a string or a function name if you include () at the end.
Also consider embedding your domino pictures in the SWF so they load up on application init, instead of when they are "called" by the grid. That will make for a more responsive app, especially if it's being hosted online. Your teacher will give you bonus points!
we also talk about other random shit and clown upon each other
I declare the pic array like so:
Use this to give the array a list of image names to use.
Then use it like this to call the image.
No errors, but the image isn't showing up. Am I missing something?
Also, don't use getItemAt().. kinda pointless
picArray[0] should work fine and is faster.
If you do that, and it still doesn't show up, make sure your images are in the right place.. for Flex Builder, root directory is the same as your MXML file. Also try setting AutoLoad="true" on the image control tag.
hint
is a bit overkill. Actionscript knows when you are doing a string, the same thing can be written
we also talk about other random shit and clown upon each other
Thank you for the help, I'm probably on the right track but something small is getting in the way. I'll continue looking at it and ask around tomorrow and see what I can find.
It's possible that your image controls are being printed out, and they are getting empty strings as file paths because creationComplete is firing after they are created. Strings in AS3 are passed by value, not by reference, so if they aren't populated yet, you would get nothing.
Unless there's a good reason, you should be just populating that array on application init, not on control init.
we also talk about other random shit and clown upon each other