-
is it possible to attach a bitmap from the library?
Hi,
playing around with my site and decided I would like my preloader to work on top of an image instead of loading the clip with the image once the preloader reaches 100, but I can't get it to work even though the preloader is in a layer on top of the movie clip (if I use it).
I noticed a bitmap has the checkboxes when clicking on its properties, but I wouldn't know how to attach it in the first frame of my swf. Is there a method to do so? I can't seem to find it...
thanks,
P.D. I'm not attaching my file because it's too heavy, but I hope my question is clear.
Used to have a movie clip with 4 bitmaps distributed in 4 frames where it would stop on a chosen one, but if I use it in the same frame as the preloader, like I mentioned above, the preloader doesn't show visible even if the percentage traces right. So I tried using a bitmap instead and then it works. The problem is I need to use a different image depending on the code in its frame.
-
You only need to use bitmap when you're trying to utilize the gpu over the cpu. The bitmap checkbox is to try to convert the clip to bitmap. You can get lucky checking it but you do need to know bitmapdata to know if it's working.
When you convert to bitmap, it's sort of "flattening" the layers. Maybe that's why.
Here's as2 preloader code. I used to use a preloader scene (first), stop on this code, then the code goes to the main scene.
Code:
stop();
clearInterval(intPageLoader);
intPageLoader = setInterval(fPreLoader, 20);
function fPreLoader() {
var totalBytes = _root.getBytesTotal();
var loadedBytes = _root.getBytesLoaded();
//loadBlocker.mcLoadBan = "Loading Graphics:";
var getPercent = int((loadedBytes / totalBytes) * 100);
if (totalBytes > 100) {
if (getPercent > 99) {
clearInterval(intPageLoader);
mcPreloader.mcLoadPercent = "100%";
mcPreloader.preLoadBar._width = 200;
trace("page loaded");
gotoAndPlay("Scene 1", 1);
} else if (getPercent >= 1) {
mcPreloader.mcLoadPercent = getPercent + "%";
mcPreloader.preLoadBar._width = 2 * getPercent;
} else {
mcPreloader.mcLoadPercent = "Connecting";
mcPreloader.preLoadBar._width = 1;
}
}
updateAfterEvent();
}
-
Thanks, Moot,
Excuse me for not fully understanding your code. What does this line do? loadBlocker.mcLoadBan = "Loading Graphics:";
The code I use for preloading works well for my bar. I was only worried about knowing if you could attach an image just like you attach a movie clip. I guess it's not as easy...
I will try to post a lighter fla in time to clear my inquiry. I just want the preloading bar on top of an image out of four possible ones.
I used to have :
Code:
var today = new Date();
var dat = today.getDate();
var month = today.getMonth() + 1;
var dayN = today.getDay();
var select:Number = undefined;
if (dat >= 20 && month == 12 || month == 1 || month == 2 || dat <= 21 && month == 3)
{
select = 4;
}
else if (dat >= 19 && month == 3 || month == 4 || month == 5 || dat <= 20 && month == 6)
{
select = 2;
}
else if (dat >= 20 && month == 6 || month == 7 || month == 8 || dat <= 21 && month == 9)
{
select = 1;
}
else if (dat >= 21 && month == 9 || month == 10 || month == 11 || dat <= 22 && month == 12)
{
select = 3;
}
backGround.gotoAndStop(select);
this and then a movie clip with the four images in it, but the preloader doesn't show if I use a movie clip. And it's in a higher layer. I mean it's on top of the clip with the images...
Code:
onEnterFrame = function ()
{
var percent_loaded = Math.floor(getBytesLoaded() / getBytesTotal() * 100);
mainLoadBar.gotoAndStop(percent_loaded);
percent_txt.text = percent_loaded + "%";
if (percent_loaded == 100)
{
delete onEnterFrame;
gotoAndPlay("needed frame");
}
};
Anyway, thank you. Until soon
-
HI again,
I came up with an fla I could attach... the commented code in frame 1 will not work. Frame 3 is what I would like to achieve on frame 1 so the preloading bar shows on top of the image...
Attachment 74931
-
.
Hi Cap,
As for attaching an image from the library, like so
PHP Code:
import flash.display.BitmapData;
var myBitmapData:BitmapData = BitmapData.loadBitmap("image in Library AS Linkage Name");
backGround.attachBitmap(myBitmapData, 1);
from your code I believe "backGround" is where you are wanting to load the image from the library.
If not you can also create the empty clip at run time to load it into, like so
PHP Code:
import flash.display.BitmapData;
var myBitmapData:BitmapData = BitmapData.loadBitmap("image in Library AS Linkage Name");
var newEmpty:MovieClip = this.createEmptyMovieClip("newEmpty", this.getNextHighestDepth());
newEmpty.attachBitmap(myBitmapData, 1);
P.S don't you find the below code slightly confusing ???
PHP Code:
if (dat >= 20 && month == 12 || month == 1 || month == 2 || dat <= 21 && month == 3)
{
select = 4;
}
else if (dat >= 19 && month == 3 || month == 4 || month == 5 || dat <= 20 && month == 6)
{
select = 2;
}
else if (dat >= 20 && month == 6 || month == 7 || month == 8 || dat <= 21 && month == 9)
{
select = 1;
}
else if (dat >= 21 && month == 9 || month == 10 || month == 11 || dat <= 22 && month == 12)
{
select = 3;
}
Last edited by fruitbeard; 05-26-2014 at 02:07 PM.
-
Hi, Fruit,
long time! Thanks. That's what I wanted to know about attaching an image, but you still need to embed it in a movie clip.
My deduction was attaching any of the 4 images as bare images since an image on stage on a layer beneath the loadbar does let you see it.
mmmm... can't see anything on the code straight away.
-
.
Hi,
No you don't need to load it into a movieclip,
import flash.display.BitmapData;
var myBitmapData:BitmapData = BitmapData.loadBitmap("library Image AS Linkage Name");
attachBitmap(myBitmapData, this.getNextHighestDepth());
-
Oh, oh !!
got it now. Thanks
-
.
Hi Cap,
That code I asked you about was your code from your loader thing, are you trying to change the picture according to astrology dates (zodiac signs)??
It's just the code looks a little messed up and confusing, perhaps this might be more readable
PHP Code:
if (dat == 21 || dat == 22 && (month == 12 || month == 1 || month == 2 || month == 3))
{
select = 4;
trace(select);
}
else if (dat == 19 || dat == 20 && (month == 3 || month == 4 || month == 5 || month == 6))
{
select = 2;
trace(select);
}
else if (dat == 20 || dat == 21 && (month == 6 || month == 7 || month == 8 || month == 9))
{
select = 1;
trace(select);
}
else if (dat == 21 || dat == 22 && (month == 9 || month == 10 || month == 11 || month == 12))
{
select = 2;
trace(select);
}
else
{
trace(dat);
}
even with either your version or mine, it will still have conflicts, such as. dat = 21 & month = 9.
perhaps I am seeing things, I'm sure you know what you're doing.
Fruit
-
Attaching bitmaps, or anything, directly to the stage is just a bad practice. Later, you'll never do it. It is most efficient (real world work) to put everything in clips.
Yes, you can do everything, every last thing, with code. But that is terribly inefficient and efficiency is everything.
Your if/else statements are bad because you are doing so many tests. If dat does not equal 21 (dat==21 fails), you don't need to do the following 5 tests of that if statement. == are terrible decision makers too. If you can use > or <, do. I don't know what the numbers mean so I can't help more.
-
Hi, thanks.
I'm beginning to understand about the image deal, I think.. thanks again.
As for the code, it represents the seasons of the year. I have been thinking about it all day. Surely, there will be an easier or simpler way to write that. I was/am confused... I thought I was getting strings from the date object. Do you mean you can code it say: getting the result between two dates omitting part of the code (the months between the first and last date).
-
No worries ever about "getting" anything or whatever. I show you what I think is the best code because that is what I need when I'm learning.
When I was talking about the if/else statements, I was talking about the logic. Your if statement has unnecessary tests in it. If the season's change at a certain day, test for that day.
if(dayOfTheYear < 60){
season = 0;
}else if(dayOfTheYear < 120){
season = 1;
... etc.
It's a math problem. You always want to use the most simple numbers and equations.
-
Hi, Fruit,
Ok. I was confused. I see simplifying things makes it easier on all sides. i understand that. Makes sense.
But I've just run into another problem I can't even dream of understanding. I'm attaching a Fla. with the old code. I want to understand your example before using it. If I replace the text fields with images (I can't leave in the file because of the weight), I promise even if the movie goes to the frame, it doesn't show it. Sorry about that...
I was trying to upload the fla, but it's too heavy.... will be posting it later
Last edited by capdetrons; 05-27-2014 at 12:19 PM.
-
Hi,
shrunk down my file...
I've even tried to break the image apart. Does this make any sense to you?
Attachment 74933
-
Hi again, Fruit or whoever...
I really am sorry posting so much, but I promise I am not making anything up... I've just retried with different images and everything's fine. I can't see what must have happened with my other pictures. I had them linked but I checked them out...
Could it be a caché issue?
Attachment 74935
-
Good night again.
I don't mean to give anyone a headache with my post about this issue. I was just thinking it's to odd for me.
I wish I could attach my file in here, but it's over 2 MB with only one picture. I decided to post again after shrinking the same color picture's size and it does show. It's a JPG file and nothing but the size special to it. The original one is 1346 X 688 px.
I know bizarre things happen from time to time and I was about to forget about it, but I know I will have a hard time sleeping if I can't understand this one issue. I needed to post again.
Thanks.
P.S I'll gladly send the file to anyone who wishes to see it if needed
-
I can't run AS2 so I can be missing stuff.
You have to stop using frames in your coding - gotoAndStop, gotoAndPlay. Only use those to start animations.
You should have only one text field (it doesn't change in font or dimension). Put the textfield into a clip - mcText or something. Then update the textfield instead of placing separate textfields on separate frames.
Did you embed the fonts? It doesn't show any embedded. If you use dynamic text, which you should, you need to embed the fonts otherwise the text will not appear.
-
Hi thanks for the reply, moot,
but it's not about the texts in the attached fla. I tried to lighten it up weightwise to be able to post it and the text is there to represent the images that should be in their place.
The images in there are JPGs and I thought it could have something to do with all my practicing with the bitmap attaching and linking... I've kept trying and I decided to test decreasing the width and height of these images and they do appear normally. They're on stage. The fact of being larger should not affect the swf should it?
In my previous wep page these images are inside a clip and the actionscript behaves just right stopping at the desired frame and showing the picture.
-
determined to understand this if it has an explanation
Hi,
I bet my posts may sound confusing because of my poor english so I'm attaching a couple of files where you have a clip stopping at a frame with a picture controlled from the main timeline working fine.
If I use the same coding and the same picture in the main timeline and on stage, the picture doesn't show. I ended up thinking it could be due to its size because I shrunk it and it showed...
I believe zip files can't be attached here so I'm attaching a couple of files with text boxes in place of the alleged pictures
Attachment 74937Attachment 74939
If the answer to this is too technical for me to understand don't bother replying. I mean if it can be due to file formats or perhaps, its size. I simply believe it doesn't make any logical sense and I wonder whether my PC has a virus. I will give it up anyway, because I don't think I will end up animating my preloader that way. It's only curiosity.
-
If you don't include the whole file, we can't look at your issue. So we're stuck with your description of your issue.
How big is the image you're trying to load?
If you load anything into a movieclip, it has to be an empty movieclip - 1 frame, nothing in it. If there's anything in the movieclip, you can have issues.
Last edited by moot; 05-29-2014 at 06:47 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|